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