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 | |
Benjamin Herrenschmidt | e1fa2e1 | 2007-05-10 22:22:45 -0700 | [diff] [blame] | 51 | #define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) |
| 52 | #define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) |
| 53 | |
| 54 | #define hard_irq_disable() \ |
| 55 | do { \ |
| 56 | __hard_irq_disable(); \ |
| 57 | get_paca()->soft_enabled = 0; \ |
| 58 | get_paca()->hard_enabled = 0; \ |
| 59 | } while(0) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #else |
| 62 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 63 | #if defined(CONFIG_BOOKE) |
| 64 | #define SET_MSR_EE(x) mtmsr(x) |
| 65 | #define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 66 | #else |
| 67 | #define SET_MSR_EE(x) mtmsr(x) |
| 68 | #define local_irq_restore(flags) mtmsr(flags) |
| 69 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | static inline void local_irq_disable(void) |
| 72 | { |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 73 | #ifdef CONFIG_BOOKE |
| 74 | __asm__ __volatile__("wrteei 0": : :"memory"); |
| 75 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | unsigned long msr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | __asm__ __volatile__("": : :"memory"); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 78 | msr = mfmsr(); |
| 79 | SET_MSR_EE(msr & ~MSR_EE); |
| 80 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | static inline void local_irq_enable(void) |
| 84 | { |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 85 | #ifdef CONFIG_BOOKE |
| 86 | __asm__ __volatile__("wrteei 1": : :"memory"); |
| 87 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | unsigned long msr; |
| 89 | __asm__ __volatile__("": : :"memory"); |
| 90 | msr = mfmsr(); |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 91 | SET_MSR_EE(msr | MSR_EE); |
| 92 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 95 | static inline void local_irq_save_ptr(unsigned long *flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { |
| 97 | unsigned long msr; |
| 98 | msr = mfmsr(); |
| 99 | *flags = msr; |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 100 | #ifdef CONFIG_BOOKE |
| 101 | __asm__ __volatile__("wrteei 0": : :"memory"); |
| 102 | #else |
| 103 | SET_MSR_EE(msr & ~MSR_EE); |
| 104 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | __asm__ __volatile__("": : :"memory"); |
| 106 | } |
| 107 | |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 108 | #define local_save_flags(flags) ((flags) = mfmsr()) |
| 109 | #define local_irq_save(flags) local_irq_save_ptr(&flags) |
| 110 | #define irqs_disabled() ((mfmsr() & MSR_EE) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Michael Ellerman | 143db67 | 2006-11-26 17:36:15 +1100 | [diff] [blame] | 112 | #define hard_irq_enable() local_irq_enable() |
| 113 | #define hard_irq_disable() local_irq_disable() |
| 114 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 115 | #endif /* CONFIG_PPC64 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
Ingo Molnar | c0ad90a | 2006-06-29 02:24:44 -0700 | [diff] [blame] | 117 | /* |
| 118 | * interrupt-retrigger: should we handle this via lost interrupts and IPIs |
| 119 | * or should we not care like we do now ? --BenH. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | */ |
| 121 | struct hw_interrupt_type; |
Kumar Gala | b671ad2 | 2005-09-21 16:52:55 -0500 | [diff] [blame] | 122 | |
| 123 | #endif /* __KERNEL__ */ |
| 124 | #endif /* _ASM_POWERPC_HW_IRQ_H */ |