Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | */ |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 4 | #ifndef _ASM_POWERPC_HW_IRQ_H |
| 5 | #define _ASM_POWERPC_HW_IRQ_H |
| 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/errno.h> |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 10 | #include <asm/ptrace.h> |
| 11 | #include <asm/processor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Kumar Gala | c7aeffc | 2005-09-19 09:30:27 -0500 | [diff] [blame] | 13 | extern void timer_interrupt(struct pt_regs *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 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) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #define local_irq_restore(flags) do { \ |
| 35 | __asm__ __volatile__("": : :"memory"); \ |
| 36 | __mtmsrd((flags), 1); \ |
| 37 | } while(0) |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 38 | #else |
| 39 | #define SET_MSR_EE(x) mtmsr(x) |
| 40 | #define local_irq_restore(flags) mtmsr(flags) |
| 41 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | static inline void local_irq_disable(void) |
| 44 | { |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 45 | #ifdef CONFIG_BOOKE |
| 46 | __asm__ __volatile__("wrteei 0": : :"memory"); |
| 47 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | unsigned long msr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | __asm__ __volatile__("": : :"memory"); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 50 | msr = mfmsr(); |
| 51 | SET_MSR_EE(msr & ~MSR_EE); |
| 52 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static inline void local_irq_enable(void) |
| 56 | { |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 57 | #ifdef CONFIG_BOOKE |
| 58 | __asm__ __volatile__("wrteei 1": : :"memory"); |
| 59 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | unsigned long msr; |
| 61 | __asm__ __volatile__("": : :"memory"); |
| 62 | msr = mfmsr(); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 63 | SET_MSR_EE(msr | MSR_EE); |
| 64 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 67 | static inline void local_irq_save_ptr(unsigned long *flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | { |
| 69 | unsigned long msr; |
| 70 | msr = mfmsr(); |
| 71 | *flags = msr; |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 72 | #ifdef CONFIG_BOOKE |
| 73 | __asm__ __volatile__("wrteei 0": : :"memory"); |
| 74 | #else |
| 75 | SET_MSR_EE(msr & ~MSR_EE); |
| 76 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | __asm__ __volatile__("": : :"memory"); |
| 78 | } |
| 79 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 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) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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->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 | */ |
| 108 | struct hw_interrupt_type; |
| 109 | static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 110 | |
| 111 | #endif /* __KERNEL__ */ |
| 112 | #endif /* _ASM_POWERPC_HW_IRQ_H */ |