4 * This file gets included from lowlevel asm headers too, to provide
5 * wrapped versions of the local_irq_*() APIs, based on the
6 * raw_local_irq_*() functions from the lowlevel headers.
8 #ifndef _ASM_IRQFLAGS_H
9 #define _ASM_IRQFLAGS_H
10 #include <asm/processor-flags.h>
13 static inline unsigned long native_save_fl(void)
16 asm volatile("pushfl ; popl %0":"=g" (f
): /* no input */);
20 static inline void native_restore_fl(unsigned long f
)
22 asm volatile("pushl %0 ; popfl": /* no output */
27 static inline void native_irq_disable(void)
29 asm volatile("cli": : :"memory");
32 static inline void native_irq_enable(void)
34 asm volatile("sti": : :"memory");
37 static inline void native_safe_halt(void)
39 asm volatile("sti; hlt": : :"memory");
42 static inline void native_halt(void)
44 asm volatile("hlt": : :"memory");
46 #endif /* __ASSEMBLY__ */
48 #ifdef CONFIG_PARAVIRT
49 #include <asm/paravirt.h>
53 static inline unsigned long __raw_local_save_flags(void)
55 return native_save_fl();
58 static inline void raw_local_irq_restore(unsigned long flags
)
60 native_restore_fl(flags
);
63 static inline void raw_local_irq_disable(void)
68 static inline void raw_local_irq_enable(void)
74 * Used in the idle loop; sti takes one instruction cycle
77 static inline void raw_safe_halt(void)
83 * Used when interrupts are already enabled or to
84 * shutdown the processor:
86 static inline void halt(void)
94 static inline unsigned long __raw_local_irq_save(void)
96 unsigned long flags
= __raw_local_save_flags();
98 raw_local_irq_disable();
104 #define DISABLE_INTERRUPTS(clobbers) cli
105 #define ENABLE_INTERRUPTS(clobbers) sti
106 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
107 #define INTERRUPT_RETURN iret
108 #define GET_CR0_INTO_EAX movl %cr0, %eax
109 #endif /* __ASSEMBLY__ */
110 #endif /* CONFIG_PARAVIRT */
113 #define raw_local_save_flags(flags) \
114 do { (flags) = __raw_local_save_flags(); } while (0)
116 #define raw_local_irq_save(flags) \
117 do { (flags) = __raw_local_irq_save(); } while (0)
119 static inline int raw_irqs_disabled_flags(unsigned long flags
)
121 return !(flags
& X86_EFLAGS_IF
);
124 static inline int raw_irqs_disabled(void)
126 unsigned long flags
= __raw_local_save_flags();
128 return raw_irqs_disabled_flags(flags
);
132 * makes the traced hardirq state match with the machine state
134 * should be a rarely used function, only in places where its
135 * otherwise impossible to know the irq state, like in traps.
137 static inline void trace_hardirqs_fixup_flags(unsigned long flags
)
139 if (raw_irqs_disabled_flags(flags
))
140 trace_hardirqs_off();
145 static inline void trace_hardirqs_fixup(void)
147 unsigned long flags
= __raw_local_save_flags();
149 trace_hardirqs_fixup_flags(flags
);
151 #endif /* __ASSEMBLY__ */
154 * Do the CPU's IRQ-state tracing from assembly code. We call a
155 * C function, so save all the C-clobbered registers:
157 #ifdef CONFIG_TRACE_IRQFLAGS
159 # define TRACE_IRQS_ON \
163 call trace_hardirqs_on; \
168 # define TRACE_IRQS_OFF \
172 call trace_hardirqs_off; \
178 # define TRACE_IRQS_ON
179 # define TRACE_IRQS_OFF
182 #ifdef CONFIG_DEBUG_LOCK_ALLOC
183 # define LOCKDEP_SYS_EXIT \
187 call lockdep_sys_exit; \
192 # define LOCKDEP_SYS_EXIT