blob: ce0f7db63c1673a1435d93e7906a27bb9cb947cd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 */
Kumar Galab671ad22005-09-21 16:52:55 -05004#ifndef _ASM_POWERPC_HW_IRQ_H
5#define _ASM_POWERPC_HW_IRQ_H
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/errno.h>
Kumar Galab671ad22005-09-21 16:52:55 -050010#include <asm/ptrace.h>
11#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Kumar Galac7aeffc2005-09-19 09:30:27 -050013extern void timer_interrupt(struct pt_regs *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15#ifdef CONFIG_PPC_ISERIES
16
17extern unsigned long local_get_flags(void);
18extern unsigned long local_irq_disable(void);
19extern 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
Kumar Galab671ad22005-09-21 16:52:55 -050029#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#define local_irq_restore(flags) do { \
35 __asm__ __volatile__("": : :"memory"); \
36 __mtmsrd((flags), 1); \
37} while(0)
Kumar Galab671ad22005-09-21 16:52:55 -050038#else
39#define SET_MSR_EE(x) mtmsr(x)
40#define local_irq_restore(flags) mtmsr(flags)
41#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43static inline void local_irq_disable(void)
44{
Kumar Galab671ad22005-09-21 16:52:55 -050045#ifdef CONFIG_BOOKE
46 __asm__ __volatile__("wrteei 0": : :"memory");
47#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 unsigned long msr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 __asm__ __volatile__("": : :"memory");
Kumar Galab671ad22005-09-21 16:52:55 -050050 msr = mfmsr();
51 SET_MSR_EE(msr & ~MSR_EE);
52#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
55static inline void local_irq_enable(void)
56{
Kumar Galab671ad22005-09-21 16:52:55 -050057#ifdef CONFIG_BOOKE
58 __asm__ __volatile__("wrteei 1": : :"memory");
59#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 unsigned long msr;
61 __asm__ __volatile__("": : :"memory");
62 msr = mfmsr();
Kumar Galab671ad22005-09-21 16:52:55 -050063 SET_MSR_EE(msr | MSR_EE);
64#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
Kumar Galab671ad22005-09-21 16:52:55 -050067static inline void local_irq_save_ptr(unsigned long *flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
69 unsigned long msr;
70 msr = mfmsr();
71 *flags = msr;
Kumar Galab671ad22005-09-21 16:52:55 -050072#ifdef CONFIG_BOOKE
73 __asm__ __volatile__("wrteei 0": : :"memory");
74#else
75 SET_MSR_EE(msr & ~MSR_EE);
76#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 __asm__ __volatile__("": : :"memory");
78}
79
Kumar Galab671ad22005-09-21 16:52:55 -050080#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84#endif /* CONFIG_PPC_ISERIES */
85
86#define mask_irq(irq) \
87 ({ \
88 irq_desc_t *desc = get_irq_desc(irq); \
89 if (desc->handler && desc->handler->disable) \
90 desc->handler->disable(irq); \
91 })
92#define unmask_irq(irq) \
93 ({ \
94 irq_desc_t *desc = get_irq_desc(irq); \
95 if (desc->handler && desc->handler->enable) \
96 desc->handler->enable(irq); \
97 })
98#define ack_irq(irq) \
99 ({ \
100 irq_desc_t *desc = get_irq_desc(irq); \
101 if (desc->handler && desc->handler->ack) \
102 desc->handler->ack(irq); \
103 })
104
105/* Should we handle this via lost interrupts and IPIs or should we don't care like
106 * we do now ? --BenH.
107 */
108struct hw_interrupt_type;
109static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
Kumar Galab671ad22005-09-21 16:52:55 -0500110
111#endif /* __KERNEL__ */
112#endif /* _ASM_POWERPC_HW_IRQ_H */