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 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 19 | static inline unsigned long arch_local_save_flags(void) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 20 | { |
Hugh Dickins | ef2b343 | 2006-11-10 21:32:40 +0000 | [diff] [blame] | 21 | unsigned long flags; |
| 22 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 23 | asm volatile( |
| 24 | "lbz %0,%1(13)" |
| 25 | : "=r" (flags) |
| 26 | : "i" (offsetof(struct paca_struct, soft_enabled))); |
Hugh Dickins | ef2b343 | 2006-11-10 21:32:40 +0000 | [diff] [blame] | 27 | |
| 28 | return flags; |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 29 | } |
| 30 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 31 | static inline unsigned long arch_local_irq_disable(void) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 32 | { |
Hugh Dickins | ef2b343 | 2006-11-10 21:32:40 +0000 | [diff] [blame] | 33 | unsigned long flags, zero; |
| 34 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 35 | asm volatile( |
| 36 | "li %1,0; lbz %0,%2(13); stb %1,%2(13)" |
| 37 | : "=r" (flags), "=&r" (zero) |
| 38 | : "i" (offsetof(struct paca_struct, soft_enabled)) |
| 39 | : "memory"); |
Hugh Dickins | ef2b343 | 2006-11-10 21:32:40 +0000 | [diff] [blame] | 40 | |
| 41 | return flags; |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 42 | } |
| 43 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 44 | extern void arch_local_irq_restore(unsigned long); |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 45 | extern void iseries_handle_interrupts(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 47 | static inline void arch_local_irq_enable(void) |
| 48 | { |
| 49 | arch_local_irq_restore(1); |
| 50 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 52 | static inline unsigned long arch_local_irq_save(void) |
| 53 | { |
| 54 | return arch_local_irq_disable(); |
| 55 | } |
| 56 | |
| 57 | static inline bool arch_irqs_disabled_flags(unsigned long flags) |
| 58 | { |
| 59 | return flags == 0; |
| 60 | } |
| 61 | |
| 62 | static inline bool arch_irqs_disabled(void) |
| 63 | { |
| 64 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
| 65 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 67 | #ifdef CONFIG_PPC_BOOK3E |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 68 | #define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory"); |
| 69 | #define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory"); |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 70 | #else |
Benjamin Herrenschmidt | d9ada91 | 2012-03-02 11:33:52 +1100 | [diff] [blame^] | 71 | #define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1) |
| 72 | #define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1) |
Benjamin Herrenschmidt | 2d27cfd | 2009-07-23 23:15:59 +0000 | [diff] [blame] | 73 | #endif |
Benjamin Herrenschmidt | e1fa2e1 | 2007-05-10 22:22:45 -0700 | [diff] [blame] | 74 | |
| 75 | #define hard_irq_disable() \ |
| 76 | do { \ |
| 77 | __hard_irq_disable(); \ |
| 78 | get_paca()->soft_enabled = 0; \ |
| 79 | get_paca()->hard_enabled = 0; \ |
| 80 | } while(0) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 81 | |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 82 | static inline bool arch_irq_disabled_regs(struct pt_regs *regs) |
| 83 | { |
| 84 | return !regs->softe; |
| 85 | } |
| 86 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 87 | #else /* CONFIG_PPC64 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 89 | #define SET_MSR_EE(x) mtmsr(x) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 91 | static inline unsigned long arch_local_save_flags(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 93 | return mfmsr(); |
| 94 | } |
Paul Mackerras | 4c75f84 | 2009-06-12 02:00:50 +0000 | [diff] [blame] | 95 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 96 | static inline void arch_local_irq_restore(unsigned long flags) |
| 97 | { |
| 98 | #if defined(CONFIG_BOOKE) |
| 99 | asm volatile("wrtee %0" : : "r" (flags) : "memory"); |
| 100 | #else |
| 101 | mtmsr(flags); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 102 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 105 | static inline unsigned long arch_local_irq_save(void) |
| 106 | { |
| 107 | unsigned long flags = arch_local_save_flags(); |
| 108 | #ifdef CONFIG_BOOKE |
| 109 | asm volatile("wrteei 0" : : : "memory"); |
| 110 | #else |
| 111 | SET_MSR_EE(flags & ~MSR_EE); |
| 112 | #endif |
| 113 | return flags; |
| 114 | } |
| 115 | |
| 116 | static inline void arch_local_irq_disable(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | { |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 118 | #ifdef CONFIG_BOOKE |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 119 | asm volatile("wrteei 0" : : : "memory"); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 120 | #else |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 121 | arch_local_irq_save(); |
| 122 | #endif |
| 123 | } |
Paul Mackerras | 4c75f84 | 2009-06-12 02:00:50 +0000 | [diff] [blame] | 124 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 125 | static inline void arch_local_irq_enable(void) |
| 126 | { |
| 127 | #ifdef CONFIG_BOOKE |
| 128 | asm volatile("wrteei 1" : : : "memory"); |
| 129 | #else |
| 130 | unsigned long msr = mfmsr(); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 131 | SET_MSR_EE(msr | MSR_EE); |
| 132 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | } |
| 134 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 135 | static inline bool arch_irqs_disabled_flags(unsigned long flags) |
Steven Rostedt | e0eca07 | 2008-05-14 23:49:43 -0400 | [diff] [blame] | 136 | { |
| 137 | return (flags & MSR_EE) == 0; |
| 138 | } |
| 139 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 140 | static inline bool arch_irqs_disabled(void) |
| 141 | { |
| 142 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
| 143 | } |
| 144 | |
| 145 | #define hard_irq_disable() arch_local_irq_disable() |
| 146 | |
Benjamin Herrenschmidt | a546498 | 2012-03-07 16:48:45 +1100 | [diff] [blame] | 147 | static inline bool arch_irq_disabled_regs(struct pt_regs *regs) |
| 148 | { |
| 149 | return !(regs->msr & MSR_EE); |
| 150 | } |
| 151 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 152 | #endif /* CONFIG_PPC64 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Thomas Gleixner | 089fb44 | 2011-01-21 06:12:28 +0000 | [diff] [blame] | 154 | #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST |
| 155 | |
Ingo Molnar | c0ad90a | 2006-06-29 02:24:44 -0700 | [diff] [blame] | 156 | /* |
| 157 | * interrupt-retrigger: should we handle this via lost interrupts and IPIs |
| 158 | * or should we not care like we do now ? --BenH. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | */ |
Thomas Gleixner | 353bca5 | 2009-03-10 14:46:30 +0000 | [diff] [blame] | 160 | struct irq_chip; |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 161 | |
| 162 | #endif /* __KERNEL__ */ |
| 163 | #endif /* _ASM_POWERPC_HW_IRQ_H */ |