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