]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu> | |
1da177e4 | 3 | */ |
b671ad2b KG |
4 | #ifndef _ASM_POWERPC_HW_IRQ_H |
5 | #define _ASM_POWERPC_HW_IRQ_H | |
6 | ||
1da177e4 | 7 | #ifdef __KERNEL__ |
1da177e4 | 8 | |
1da177e4 | 9 | #include <linux/errno.h> |
d04c56f7 | 10 | #include <linux/compiler.h> |
b671ad2b KG |
11 | #include <asm/ptrace.h> |
12 | #include <asm/processor.h> | |
1da177e4 | 13 | |
c7aeffc4 | 14 | extern void timer_interrupt(struct pt_regs *); |
1da177e4 | 15 | |
d04c56f7 PM |
16 | #ifdef CONFIG_PPC64 |
17 | #include <asm/paca.h> | |
18 | ||
19 | static inline unsigned long local_get_flags(void) | |
20 | { | |
ef2b343e HD |
21 | unsigned long flags; |
22 | ||
23 | __asm__ __volatile__("lbz %0,%1(13)" | |
24 | : "=r" (flags) | |
25 | : "i" (offsetof(struct paca_struct, soft_enabled))); | |
26 | ||
27 | return flags; | |
d04c56f7 PM |
28 | } |
29 | ||
945feb17 | 30 | static inline unsigned long raw_local_irq_disable(void) |
d04c56f7 | 31 | { |
ef2b343e HD |
32 | unsigned long flags, zero; |
33 | ||
34 | __asm__ __volatile__("li %1,0; lbz %0,%2(13); stb %1,%2(13)" | |
35 | : "=r" (flags), "=&r" (zero) | |
36 | : "i" (offsetof(struct paca_struct, soft_enabled)) | |
37 | : "memory"); | |
38 | ||
39 | return flags; | |
d04c56f7 | 40 | } |
1da177e4 | 41 | |
945feb17 | 42 | extern void raw_local_irq_restore(unsigned long); |
d04c56f7 | 43 | extern void iseries_handle_interrupts(void); |
1da177e4 | 44 | |
945feb17 BH |
45 | #define raw_local_irq_enable() raw_local_irq_restore(1) |
46 | #define raw_local_save_flags(flags) ((flags) = local_get_flags()) | |
47 | #define raw_local_irq_save(flags) ((flags) = raw_local_irq_disable()) | |
1da177e4 | 48 | |
945feb17 BH |
49 | #define raw_irqs_disabled() (local_get_flags() == 0) |
50 | #define raw_irqs_disabled_flags(flags) ((flags) == 0) | |
1da177e4 | 51 | |
e1fa2e13 BH |
52 | #define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) |
53 | #define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) | |
54 | ||
55 | #define hard_irq_disable() \ | |
56 | do { \ | |
57 | __hard_irq_disable(); \ | |
58 | get_paca()->soft_enabled = 0; \ | |
59 | get_paca()->hard_enabled = 0; \ | |
60 | } while(0) | |
d04c56f7 | 61 | |
e0eca07b SR |
62 | static inline int irqs_disabled_flags(unsigned long flags) |
63 | { | |
64 | return flags == 0; | |
65 | } | |
66 | ||
1da177e4 LT |
67 | #else |
68 | ||
b671ad2b KG |
69 | #if defined(CONFIG_BOOKE) |
70 | #define SET_MSR_EE(x) mtmsr(x) | |
71 | #define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") | |
b671ad2b KG |
72 | #else |
73 | #define SET_MSR_EE(x) mtmsr(x) | |
74 | #define local_irq_restore(flags) mtmsr(flags) | |
75 | #endif | |
1da177e4 LT |
76 | |
77 | static inline void local_irq_disable(void) | |
78 | { | |
b671ad2b KG |
79 | #ifdef CONFIG_BOOKE |
80 | __asm__ __volatile__("wrteei 0": : :"memory"); | |
81 | #else | |
1da177e4 | 82 | unsigned long msr; |
1da177e4 | 83 | __asm__ __volatile__("": : :"memory"); |
b671ad2b KG |
84 | msr = mfmsr(); |
85 | SET_MSR_EE(msr & ~MSR_EE); | |
86 | #endif | |
1da177e4 LT |
87 | } |
88 | ||
89 | static inline void local_irq_enable(void) | |
90 | { | |
b671ad2b KG |
91 | #ifdef CONFIG_BOOKE |
92 | __asm__ __volatile__("wrteei 1": : :"memory"); | |
93 | #else | |
1da177e4 LT |
94 | unsigned long msr; |
95 | __asm__ __volatile__("": : :"memory"); | |
96 | msr = mfmsr(); | |
b671ad2b KG |
97 | SET_MSR_EE(msr | MSR_EE); |
98 | #endif | |
1da177e4 LT |
99 | } |
100 | ||
b671ad2b | 101 | static inline void local_irq_save_ptr(unsigned long *flags) |
1da177e4 LT |
102 | { |
103 | unsigned long msr; | |
104 | msr = mfmsr(); | |
105 | *flags = msr; | |
b671ad2b KG |
106 | #ifdef CONFIG_BOOKE |
107 | __asm__ __volatile__("wrteei 0": : :"memory"); | |
108 | #else | |
109 | SET_MSR_EE(msr & ~MSR_EE); | |
110 | #endif | |
1da177e4 LT |
111 | __asm__ __volatile__("": : :"memory"); |
112 | } | |
113 | ||
b671ad2b KG |
114 | #define local_save_flags(flags) ((flags) = mfmsr()) |
115 | #define local_irq_save(flags) local_irq_save_ptr(&flags) | |
116 | #define irqs_disabled() ((mfmsr() & MSR_EE) == 0) | |
1da177e4 | 117 | |
143db67a ME |
118 | #define hard_irq_enable() local_irq_enable() |
119 | #define hard_irq_disable() local_irq_disable() | |
120 | ||
e0eca07b SR |
121 | static inline int irqs_disabled_flags(unsigned long flags) |
122 | { | |
123 | return (flags & MSR_EE) == 0; | |
124 | } | |
125 | ||
d04c56f7 | 126 | #endif /* CONFIG_PPC64 */ |
1da177e4 | 127 | |
c0ad90a3 IM |
128 | /* |
129 | * interrupt-retrigger: should we handle this via lost interrupts and IPIs | |
130 | * or should we not care like we do now ? --BenH. | |
1da177e4 LT |
131 | */ |
132 | struct hw_interrupt_type; | |
b671ad2b KG |
133 | |
134 | #endif /* __KERNEL__ */ | |
135 | #endif /* _ASM_POWERPC_HW_IRQ_H */ |