]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/powerpc/include/asm/hw_irq.h
531ba00fcbabca368e80d1313e29a8b47d80643d
[karo-tx-linux.git] / arch / powerpc / include / asm / hw_irq.h
1 /*
2  * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
3  */
4 #ifndef _ASM_POWERPC_HW_IRQ_H
5 #define _ASM_POWERPC_HW_IRQ_H
6
7 #ifdef __KERNEL__
8
9 #include <linux/errno.h>
10 #include <linux/compiler.h>
11 #include <asm/ptrace.h>
12 #include <asm/processor.h>
13
14 extern void timer_interrupt(struct pt_regs *);
15
16 #ifdef CONFIG_PPC64
17 #include <asm/paca.h>
18
19 static inline unsigned long arch_local_save_flags(void)
20 {
21         unsigned long flags;
22
23         asm volatile(
24                 "lbz %0,%1(13)"
25                 : "=r" (flags)
26                 : "i" (offsetof(struct paca_struct, soft_enabled)));
27
28         return flags;
29 }
30
31 static inline unsigned long arch_local_irq_disable(void)
32 {
33         unsigned long flags, zero;
34
35         asm volatile(
36                 "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
37                 : "=r" (flags), "=&r" (zero)
38                 : "i" (offsetof(struct paca_struct, soft_enabled))
39                 : "memory");
40
41         return flags;
42 }
43
44 extern void arch_local_irq_restore(unsigned long);
45 extern void iseries_handle_interrupts(void);
46
47 static inline void arch_local_irq_enable(void)
48 {
49         arch_local_irq_restore(1);
50 }
51
52 static inline unsigned long arch_local_irq_save(void)
53 {
54         return arch_local_irq_disable();
55 }
56
57 static inline bool arch_irqs_disabled_flags(unsigned long flags)
58 {
59         return flags == 0;
60 }
61
62 static inline bool arch_irqs_disabled(void)
63 {
64         return arch_irqs_disabled_flags(arch_local_save_flags());
65 }
66
67 #ifdef CONFIG_PPC_BOOK3E
68 #define __hard_irq_enable()     asm volatile("wrteei 1" : : : "memory");
69 #define __hard_irq_disable()    asm volatile("wrteei 0" : : : "memory");
70 #else
71 #define __hard_irq_enable()     __mtmsrd(mfmsr() | MSR_EE, 1)
72 #define __hard_irq_disable()    __mtmsrd(mfmsr() & ~MSR_EE, 1)
73 #endif
74
75 #define  hard_irq_disable()                     \
76         do {                                    \
77                 __hard_irq_disable();           \
78                 get_paca()->soft_enabled = 0;   \
79                 get_paca()->hard_enabled = 0;   \
80         } while(0)
81
82 static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
83 {
84         return !regs->softe;
85 }
86
87 #else /* CONFIG_PPC64 */
88
89 #define SET_MSR_EE(x)   mtmsr(x)
90
91 static inline unsigned long arch_local_save_flags(void)
92 {
93         return mfmsr();
94 }
95
96 static inline void arch_local_irq_restore(unsigned long flags)
97 {
98 #if defined(CONFIG_BOOKE)
99         asm volatile("wrtee %0" : : "r" (flags) : "memory");
100 #else
101         mtmsr(flags);
102 #endif
103 }
104
105 static inline unsigned long arch_local_irq_save(void)
106 {
107         unsigned long flags = arch_local_save_flags();
108 #ifdef CONFIG_BOOKE
109         asm volatile("wrteei 0" : : : "memory");
110 #else
111         SET_MSR_EE(flags & ~MSR_EE);
112 #endif
113         return flags;
114 }
115
116 static inline void arch_local_irq_disable(void)
117 {
118 #ifdef CONFIG_BOOKE
119         asm volatile("wrteei 0" : : : "memory");
120 #else
121         arch_local_irq_save();
122 #endif
123 }
124
125 static inline void arch_local_irq_enable(void)
126 {
127 #ifdef CONFIG_BOOKE
128         asm volatile("wrteei 1" : : : "memory");
129 #else
130         unsigned long msr = mfmsr();
131         SET_MSR_EE(msr | MSR_EE);
132 #endif
133 }
134
135 static inline bool arch_irqs_disabled_flags(unsigned long flags)
136 {
137         return (flags & MSR_EE) == 0;
138 }
139
140 static inline bool arch_irqs_disabled(void)
141 {
142         return arch_irqs_disabled_flags(arch_local_save_flags());
143 }
144
145 #define hard_irq_disable()              arch_local_irq_disable()
146
147 static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
148 {
149         return !(regs->msr & MSR_EE);
150 }
151
152 #endif /* CONFIG_PPC64 */
153
154 #define ARCH_IRQ_INIT_FLAGS     IRQ_NOREQUEST
155
156 /*
157  * interrupt-retrigger: should we handle this via lost interrupts and IPIs
158  * or should we not care like we do now ? --BenH.
159  */
160 struct irq_chip;
161
162 #endif  /* __KERNEL__ */
163 #endif  /* _ASM_POWERPC_HW_IRQ_H */