2 * include/asm-i386/irqflags.h
6 * This file gets included from lowlevel asm headers too, to provide
7 * wrapped versions of the local_irq_*() APIs, based on the
8 * raw_local_irq_*() functions from the lowlevel headers.
10 #ifndef _ASM_IRQFLAGS_H
11 #define _ASM_IRQFLAGS_H
14 static inline unsigned long native_save_fl(void)
17 asm volatile("pushfl ; popl %0":"=g" (f): /* no input */);
21 static inline void native_restore_fl(unsigned long f)
23 asm volatile("pushl %0 ; popfl": /* no output */
28 static inline void native_irq_disable(void)
30 asm volatile("cli": : :"memory");
33 static inline void native_irq_enable(void)
35 asm volatile("sti": : :"memory");
38 static inline void native_safe_halt(void)
40 asm volatile("sti; hlt": : :"memory");
43 static inline void native_halt(void)
45 asm volatile("hlt": : :"memory");
47 #endif /* __ASSEMBLY__ */
49 #ifdef CONFIG_PARAVIRT
50 #include <asm/paravirt.h>
54 static inline unsigned long __raw_local_save_flags(void)
56 return native_save_fl();
59 static inline void raw_local_irq_restore(unsigned long flags)
61 native_restore_fl(flags);
64 static inline void raw_local_irq_disable(void)
69 static inline void raw_local_irq_enable(void)
75 * Used in the idle loop; sti takes one instruction cycle
78 static inline void raw_safe_halt(void)
84 * Used when interrupts are already enabled or to
85 * shutdown the processor:
87 static inline void halt(void)
95 static inline unsigned long __raw_local_irq_save(void)
97 unsigned long flags = __raw_local_save_flags();
99 raw_local_irq_disable();
105 #define DISABLE_INTERRUPTS(clobbers) cli
106 #define ENABLE_INTERRUPTS(clobbers) sti
107 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
108 #define INTERRUPT_RETURN iret
109 #define GET_CR0_INTO_EAX movl %cr0, %eax
110 #endif /* __ASSEMBLY__ */
111 #endif /* CONFIG_PARAVIRT */
114 #define raw_local_save_flags(flags) \
115 do { (flags) = __raw_local_save_flags(); } while (0)
117 #define raw_local_irq_save(flags) \
118 do { (flags) = __raw_local_irq_save(); } while (0)
120 static inline int raw_irqs_disabled_flags(unsigned long flags)
122 return !(flags & (1 << 9));
125 static inline int raw_irqs_disabled(void)
127 unsigned long flags = __raw_local_save_flags();
129 return raw_irqs_disabled_flags(flags);
131 #endif /* __ASSEMBLY__ */
134 * Do the CPU's IRQ-state tracing from assembly code. We call a
135 * C function, so save all the C-clobbered registers:
137 #ifdef CONFIG_TRACE_IRQFLAGS
139 # define TRACE_IRQS_ON \
143 call trace_hardirqs_on; \
148 # define TRACE_IRQS_OFF \
152 call trace_hardirqs_off; \
158 # define TRACE_IRQS_ON
159 # define TRACE_IRQS_OFF