[PATCH] headers_check: move inclusion of <linux/linkage.h> in <asm-i386/signal.h>
[linux-2.6] / include / asm-powerpc / 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 <asm/ptrace.h>
11 #include <asm/processor.h>
12
13 extern void timer_interrupt(struct pt_regs *);
14
15 #ifdef CONFIG_PPC_ISERIES
16
17 extern unsigned long local_get_flags(void);
18 extern unsigned long local_irq_disable(void);
19 extern void local_irq_restore(unsigned long);
20
21 #define local_irq_enable()      local_irq_restore(1)
22 #define local_save_flags(flags) ((flags) = local_get_flags())
23 #define local_irq_save(flags)   ((flags) = local_irq_disable())
24
25 #define irqs_disabled()         (local_get_flags() == 0)
26
27 #else
28
29 #if defined(CONFIG_BOOKE)
30 #define SET_MSR_EE(x)   mtmsr(x)
31 #define local_irq_restore(flags)        __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
32 #elif defined(__powerpc64__)
33 #define SET_MSR_EE(x)   __mtmsrd(x, 1)
34 #define local_irq_restore(flags) do { \
35         __asm__ __volatile__("": : :"memory"); \
36         __mtmsrd((flags), 1); \
37 } while(0)
38 #else
39 #define SET_MSR_EE(x)   mtmsr(x)
40 #define local_irq_restore(flags)        mtmsr(flags)
41 #endif
42
43 static inline void local_irq_disable(void)
44 {
45 #ifdef CONFIG_BOOKE
46         __asm__ __volatile__("wrteei 0": : :"memory");
47 #else
48         unsigned long msr;
49         __asm__ __volatile__("": : :"memory");
50         msr = mfmsr();
51         SET_MSR_EE(msr & ~MSR_EE);
52 #endif
53 }
54
55 static inline void local_irq_enable(void)
56 {
57 #ifdef CONFIG_BOOKE
58         __asm__ __volatile__("wrteei 1": : :"memory");
59 #else
60         unsigned long msr;
61         __asm__ __volatile__("": : :"memory");
62         msr = mfmsr();
63         SET_MSR_EE(msr | MSR_EE);
64 #endif
65 }
66
67 static inline void local_irq_save_ptr(unsigned long *flags)
68 {
69         unsigned long msr;
70         msr = mfmsr();
71         *flags = msr;
72 #ifdef CONFIG_BOOKE
73         __asm__ __volatile__("wrteei 0": : :"memory");
74 #else
75         SET_MSR_EE(msr & ~MSR_EE);
76 #endif
77         __asm__ __volatile__("": : :"memory");
78 }
79
80 #define local_save_flags(flags) ((flags) = mfmsr())
81 #define local_irq_save(flags)   local_irq_save_ptr(&flags)
82 #define irqs_disabled()         ((mfmsr() & MSR_EE) == 0)
83
84 #endif /* CONFIG_PPC_ISERIES */
85
86 #define mask_irq(irq)                                           \
87         ({                                                      \
88                 irq_desc_t *desc = get_irq_desc(irq);           \
89                 if (desc->chip && desc->chip->disable)  \
90                         desc->chip->disable(irq);               \
91         })
92 #define unmask_irq(irq)                                         \
93         ({                                                      \
94                 irq_desc_t *desc = get_irq_desc(irq);           \
95                 if (desc->chip && desc->chip->enable)   \
96                         desc->chip->enable(irq);                \
97         })
98 #define ack_irq(irq)                                            \
99         ({                                                      \
100                 irq_desc_t *desc = get_irq_desc(irq);           \
101                 if (desc->chip && desc->chip->ack)      \
102                         desc->chip->ack(irq);           \
103         })
104
105 /*
106  * interrupt-retrigger: should we handle this via lost interrupts and IPIs
107  * or should we not care like we do now ? --BenH.
108  */
109 struct hw_interrupt_type;
110
111 #endif  /* __KERNEL__ */
112 #endif  /* _ASM_POWERPC_HW_IRQ_H */