diff options
| -rw-r--r-- | include/asm-i386/irqflags.h | 95 |
1 files changed, 83 insertions, 12 deletions
diff --git a/include/asm-i386/irqflags.h b/include/asm-i386/irqflags.h index ca777e894c92..e1bdb97c07fa 100644 --- a/include/asm-i386/irqflags.h +++ b/include/asm-i386/irqflags.h | |||
| @@ -5,24 +5,95 @@ | |||
| 5 | * | 5 | * |
| 6 | * This file gets included from lowlevel asm headers too, to provide | 6 | * This file gets included from lowlevel asm headers too, to provide |
| 7 | * wrapped versions of the local_irq_*() APIs, based on the | 7 | * wrapped versions of the local_irq_*() APIs, based on the |
| 8 | * raw_local_irq_*() macros from the lowlevel headers. | 8 | * raw_local_irq_*() functions from the lowlevel headers. |
| 9 | */ | 9 | */ |
| 10 | #ifndef _ASM_IRQFLAGS_H | 10 | #ifndef _ASM_IRQFLAGS_H |
| 11 | #define _ASM_IRQFLAGS_H | 11 | #define _ASM_IRQFLAGS_H |
| 12 | 12 | ||
| 13 | #define raw_local_save_flags(x) do { typecheck(unsigned long,x); __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */); } while (0) | 13 | #ifndef __ASSEMBLY__ |
| 14 | #define raw_local_irq_restore(x) do { typecheck(unsigned long,x); __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc"); } while (0) | ||
| 15 | #define raw_local_irq_disable() __asm__ __volatile__("cli": : :"memory") | ||
| 16 | #define raw_local_irq_enable() __asm__ __volatile__("sti": : :"memory") | ||
| 17 | /* used in the idle loop; sti takes one instruction cycle to complete */ | ||
| 18 | #define raw_safe_halt() __asm__ __volatile__("sti; hlt": : :"memory") | ||
| 19 | /* used when interrupts are already enabled or to shutdown the processor */ | ||
| 20 | #define halt() __asm__ __volatile__("hlt": : :"memory") | ||
| 21 | 14 | ||
| 22 | #define raw_irqs_disabled_flags(flags) (!((flags) & (1<<9))) | 15 | static inline unsigned long __raw_local_save_flags(void) |
| 16 | { | ||
| 17 | unsigned long flags; | ||
| 23 | 18 | ||
| 24 | /* For spinlocks etc */ | 19 | __asm__ __volatile__( |
| 25 | #define raw_local_irq_save(x) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory") | 20 | "pushfl ; popl %0" |
| 21 | : "=g" (flags) | ||
| 22 | : /* no input */ | ||
| 23 | ); | ||
| 24 | |||
| 25 | return flags; | ||
| 26 | } | ||
| 27 | |||
| 28 | #define raw_local_save_flags(flags) \ | ||
| 29 | do { (flags) = __raw_local_save_flags(); } while (0) | ||
| 30 | |||
| 31 | static inline void raw_local_irq_restore(unsigned long flags) | ||
| 32 | { | ||
| 33 | __asm__ __volatile__( | ||
| 34 | "pushl %0 ; popfl" | ||
| 35 | : /* no output */ | ||
| 36 | :"g" (flags) | ||
| 37 | :"memory", "cc" | ||
| 38 | ); | ||
| 39 | } | ||
| 40 | |||
| 41 | static inline void raw_local_irq_disable(void) | ||
| 42 | { | ||
| 43 | __asm__ __volatile__("cli" : : : "memory"); | ||
| 44 | } | ||
| 45 | |||
| 46 | static inline void raw_local_irq_enable(void) | ||
| 47 | { | ||
| 48 | __asm__ __volatile__("sti" : : : "memory"); | ||
| 49 | } | ||
| 50 | |||
| 51 | /* | ||
| 52 | * Used in the idle loop; sti takes one instruction cycle | ||
| 53 | * to complete: | ||
| 54 | */ | ||
| 55 | static inline void raw_safe_halt(void) | ||
| 56 | { | ||
| 57 | __asm__ __volatile__("sti; hlt" : : : "memory"); | ||
| 58 | } | ||
| 59 | |||
| 60 | /* | ||
| 61 | * Used when interrupts are already enabled or to | ||
| 62 | * shutdown the processor: | ||
| 63 | */ | ||
| 64 | static inline void halt(void) | ||
| 65 | { | ||
| 66 | __asm__ __volatile__("hlt": : :"memory"); | ||
| 67 | } | ||
| 68 | |||
| 69 | static inline int raw_irqs_disabled_flags(unsigned long flags) | ||
| 70 | { | ||
| 71 | return !(flags & (1 << 9)); | ||
| 72 | } | ||
| 73 | |||
| 74 | static inline int raw_irqs_disabled(void) | ||
| 75 | { | ||
| 76 | unsigned long flags = __raw_local_save_flags(); | ||
| 77 | |||
| 78 | return raw_irqs_disabled_flags(flags); | ||
| 79 | } | ||
| 80 | |||
| 81 | /* | ||
| 82 | * For spinlocks, etc: | ||
| 83 | */ | ||
| 84 | static inline unsigned long __raw_local_irq_save(void) | ||
| 85 | { | ||
| 86 | unsigned long flags = __raw_local_save_flags(); | ||
| 87 | |||
| 88 | raw_local_irq_disable(); | ||
| 89 | |||
| 90 | return flags; | ||
| 91 | } | ||
| 92 | |||
| 93 | #define raw_local_irq_save(flags) \ | ||
| 94 | do { (flags) = __raw_local_irq_save(); } while (0) | ||
| 95 | |||
| 96 | #endif /* __ASSEMBLY__ */ | ||
| 26 | 97 | ||
| 27 | /* | 98 | /* |
| 28 | * Do the CPU's IRQ-state tracing from assembly code. We call a | 99 | * Do the CPU's IRQ-state tracing from assembly code. We call a |
