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> |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 10 | #include <linux/compiler.h> |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 11 | #include <asm/ptrace.h> |
| 12 | #include <asm/processor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Kumar Gala | c7aeffc | 2005-09-19 09:30:27 -0500 | [diff] [blame] | 14 | extern void timer_interrupt(struct pt_regs *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 16 | #ifdef CONFIG_PPC64 |
| 17 | #include <asm/paca.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 19 | static inline unsigned long local_get_flags(void) |
| 20 | { |
Hugh Dickins | ef2b343 | 2006-11-10 21:32:40 +0000 | [diff] [blame] | 21 | unsigned long flags; |
| 22 | |
| 23 | __asm__ __volatile__("lbz %0,%1(13)" |
| 24 | : "=r" (flags) |
| 25 | : "i" (offsetof(struct paca_struct, soft_enabled))); |
| 26 | |
| 27 | return flags; |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | static inline unsigned long local_irq_disable(void) |
| 31 | { |
Hugh Dickins | ef2b343 | 2006-11-10 21:32:40 +0000 | [diff] [blame] | 32 | unsigned long flags, zero; |
| 33 | |
| 34 | __asm__ __volatile__("li %1,0; lbz %0,%2(13); stb %1,%2(13)" |
| 35 | : "=r" (flags), "=&r" (zero) |
| 36 | : "i" (offsetof(struct paca_struct, soft_enabled)) |
| 37 | : "memory"); |
| 38 | |
| 39 | return flags; |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 40 | } |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | extern void local_irq_restore(unsigned long); |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 43 | extern void iseries_handle_interrupts(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #define local_irq_enable() local_irq_restore(1) |
| 46 | #define local_save_flags(flags) ((flags) = local_get_flags()) |
| 47 | #define local_irq_save(flags) ((flags) = local_irq_disable()) |
| 48 | |
| 49 | #define irqs_disabled() (local_get_flags() == 0) |
| 50 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 51 | #define hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) |
| 52 | #define hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #else |
| 55 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 56 | #if defined(CONFIG_BOOKE) |
| 57 | #define SET_MSR_EE(x) mtmsr(x) |
| 58 | #define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 59 | #else |
| 60 | #define SET_MSR_EE(x) mtmsr(x) |
| 61 | #define local_irq_restore(flags) mtmsr(flags) |
| 62 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | static inline void local_irq_disable(void) |
| 65 | { |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 66 | #ifdef CONFIG_BOOKE |
| 67 | __asm__ __volatile__("wrteei 0": : :"memory"); |
| 68 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | unsigned long msr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | __asm__ __volatile__("": : :"memory"); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 71 | msr = mfmsr(); |
| 72 | SET_MSR_EE(msr & ~MSR_EE); |
| 73 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static inline void local_irq_enable(void) |
| 77 | { |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 78 | #ifdef CONFIG_BOOKE |
| 79 | __asm__ __volatile__("wrteei 1": : :"memory"); |
| 80 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | unsigned long msr; |
| 82 | __asm__ __volatile__("": : :"memory"); |
| 83 | msr = mfmsr(); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 84 | SET_MSR_EE(msr | MSR_EE); |
| 85 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 88 | static inline void local_irq_save_ptr(unsigned long *flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | { |
| 90 | unsigned long msr; |
| 91 | msr = mfmsr(); |
| 92 | *flags = msr; |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 93 | #ifdef CONFIG_BOOKE |
| 94 | __asm__ __volatile__("wrteei 0": : :"memory"); |
| 95 | #else |
| 96 | SET_MSR_EE(msr & ~MSR_EE); |
| 97 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | __asm__ __volatile__("": : :"memory"); |
| 99 | } |
| 100 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 101 | #define local_save_flags(flags) ((flags) = mfmsr()) |
| 102 | #define local_irq_save(flags) local_irq_save_ptr(&flags) |
| 103 | #define irqs_disabled() ((mfmsr() & MSR_EE) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Michael Ellerman | 143db67 | 2006-11-26 17:36:15 +1100 | [diff] [blame^] | 105 | #define hard_irq_enable() local_irq_enable() |
| 106 | #define hard_irq_disable() local_irq_disable() |
| 107 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 108 | #endif /* CONFIG_PPC64 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
| 110 | #define mask_irq(irq) \ |
| 111 | ({ \ |
| 112 | irq_desc_t *desc = get_irq_desc(irq); \ |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 113 | if (desc->chip && desc->chip->disable) \ |
| 114 | desc->chip->disable(irq); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | }) |
| 116 | #define unmask_irq(irq) \ |
| 117 | ({ \ |
| 118 | irq_desc_t *desc = get_irq_desc(irq); \ |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 119 | if (desc->chip && desc->chip->enable) \ |
| 120 | desc->chip->enable(irq); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | }) |
| 122 | #define ack_irq(irq) \ |
| 123 | ({ \ |
| 124 | irq_desc_t *desc = get_irq_desc(irq); \ |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 125 | if (desc->chip && desc->chip->ack) \ |
| 126 | desc->chip->ack(irq); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | }) |
| 128 | |
Ingo Molnar | c0ad90a | 2006-06-29 02:24:44 -0700 | [diff] [blame] | 129 | /* |
| 130 | * interrupt-retrigger: should we handle this via lost interrupts and IPIs |
| 131 | * or should we not care like we do now ? --BenH. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | */ |
| 133 | struct hw_interrupt_type; |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 134 | |
| 135 | #endif /* __KERNEL__ */ |
| 136 | #endif /* _ASM_POWERPC_HW_IRQ_H */ |