2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
4 #ifndef _ASM_POWERPC_HW_IRQ_H
5 #define _ASM_POWERPC_HW_IRQ_H
9 #include <linux/errno.h>
10 #include <linux/compiler.h>
11 #include <asm/ptrace.h>
12 #include <asm/processor.h>
17 * PACA flags in paca->irq_happened.
19 * This bits are set when interrupts occur while soft-disabled
20 * and allow a proper replay. Additionally, PACA_IRQ_HARD_DIS
21 * is set whenever we manually hard disable.
23 #define PACA_IRQ_HARD_DIS 0x01
24 #define PACA_IRQ_DBELL 0x02
25 #define PACA_IRQ_EE 0x04
26 #define PACA_IRQ_DEC 0x08 /* Or FIT */
27 #define PACA_IRQ_EE_EDGE 0x10 /* BookE only */
29 #endif /* CONFIG_PPC64 */
33 extern void __replay_interrupt(unsigned int vector);
35 extern void timer_interrupt(struct pt_regs *);
40 static inline unsigned long arch_local_save_flags(void)
47 : "i" (offsetof(struct paca_struct, soft_enabled)));
52 static inline unsigned long arch_local_irq_disable(void)
54 unsigned long flags, zero;
57 "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
58 : "=r" (flags), "=&r" (zero)
59 : "i" (offsetof(struct paca_struct, soft_enabled))
65 extern void arch_local_irq_restore(unsigned long);
67 static inline void arch_local_irq_enable(void)
69 arch_local_irq_restore(1);
72 static inline unsigned long arch_local_irq_save(void)
74 return arch_local_irq_disable();
77 static inline bool arch_irqs_disabled_flags(unsigned long flags)
82 static inline bool arch_irqs_disabled(void)
84 return arch_irqs_disabled_flags(arch_local_save_flags());
87 #ifdef CONFIG_PPC_BOOK3E
88 #define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory")
89 #define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory")
91 #define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
92 #define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
95 static inline void hard_irq_disable(void)
98 get_paca()->soft_enabled = 0;
99 get_paca()->irq_happened |= PACA_IRQ_HARD_DIS;
102 /* include/linux/interrupt.h needs hard_irq_disable to be a macro */
103 #define hard_irq_disable hard_irq_disable
105 static inline bool lazy_irq_pending(void)
107 return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
111 * This is called by asynchronous interrupts to conditionally
112 * re-enable hard interrupts when soft-disabled after having
113 * cleared the source of the interrupt
115 static inline void may_hard_irq_enable(void)
117 get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
118 if (!(get_paca()->irq_happened & PACA_IRQ_EE))
122 static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
127 extern bool prep_irq_for_idle(void);
129 #else /* CONFIG_PPC64 */
131 #define SET_MSR_EE(x) mtmsr(x)
133 static inline unsigned long arch_local_save_flags(void)
138 static inline void arch_local_irq_restore(unsigned long flags)
140 #if defined(CONFIG_BOOKE)
141 asm volatile("wrtee %0" : : "r" (flags) : "memory");
147 static inline unsigned long arch_local_irq_save(void)
149 unsigned long flags = arch_local_save_flags();
151 asm volatile("wrteei 0" : : : "memory");
153 SET_MSR_EE(flags & ~MSR_EE);
158 static inline void arch_local_irq_disable(void)
161 asm volatile("wrteei 0" : : : "memory");
163 arch_local_irq_save();
167 static inline void arch_local_irq_enable(void)
170 asm volatile("wrteei 1" : : : "memory");
172 unsigned long msr = mfmsr();
173 SET_MSR_EE(msr | MSR_EE);
177 static inline bool arch_irqs_disabled_flags(unsigned long flags)
179 return (flags & MSR_EE) == 0;
182 static inline bool arch_irqs_disabled(void)
184 return arch_irqs_disabled_flags(arch_local_save_flags());
187 #define hard_irq_disable() arch_local_irq_disable()
189 static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
191 return !(regs->msr & MSR_EE);
194 static inline void may_hard_irq_enable(void) { }
196 #endif /* CONFIG_PPC64 */
198 #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
201 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
202 * or should we not care like we do now ? --BenH.
206 #endif /* __ASSEMBLY__ */
207 #endif /* __KERNEL__ */
208 #endif /* _ASM_POWERPC_HW_IRQ_H */