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>
17 static inline unsigned long __raw_local_save_flags(void)
22 "# __raw_save_flags\n\t"
32 #define raw_local_save_flags(flags) \
33 do { (flags) = __raw_local_save_flags(); } while (0)
35 static inline void raw_local_irq_restore(unsigned long flags)
45 #ifdef CONFIG_X86_VSMP
48 * Interrupt control for the VSMP architecture:
51 static inline void raw_local_irq_disable(void)
53 unsigned long flags = __raw_local_save_flags();
55 raw_local_irq_restore((flags & ~X86_EFLAGS_IF) | X86_EFLAGS_AC);
58 static inline void raw_local_irq_enable(void)
60 unsigned long flags = __raw_local_save_flags();
62 raw_local_irq_restore((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC));
65 static inline int raw_irqs_disabled_flags(unsigned long flags)
67 return !(flags & X86_EFLAGS_IF) || (flags & X86_EFLAGS_AC);
70 #else /* CONFIG_X86_VSMP */
72 static inline void raw_local_irq_disable(void)
74 __asm__ __volatile__("cli" : : : "memory");
77 static inline void raw_local_irq_enable(void)
79 __asm__ __volatile__("sti" : : : "memory");
82 static inline int raw_irqs_disabled_flags(unsigned long flags)
84 return !(flags & X86_EFLAGS_IF);
90 * For spinlocks, etc.:
93 static inline unsigned long __raw_local_irq_save(void)
95 unsigned long flags = __raw_local_save_flags();
97 raw_local_irq_disable();
102 #define raw_local_irq_save(flags) \
103 do { (flags) = __raw_local_irq_save(); } while (0)
105 static inline int raw_irqs_disabled(void)
107 unsigned long flags = __raw_local_save_flags();
109 return raw_irqs_disabled_flags(flags);
113 * makes the traced hardirq state match with the machine state
115 * should be a rarely used function, only in places where its
116 * otherwise impossible to know the irq state, like in traps.
118 static inline void trace_hardirqs_fixup_flags(unsigned long flags)
120 if (raw_irqs_disabled_flags(flags))
121 trace_hardirqs_off();
126 static inline void trace_hardirqs_fixup(void)
128 unsigned long flags = __raw_local_save_flags();
130 trace_hardirqs_fixup_flags(flags);
133 * Used in the idle loop; sti takes one instruction cycle
136 static inline void raw_safe_halt(void)
138 __asm__ __volatile__("sti; hlt" : : : "memory");
142 * Used when interrupts are already enabled or to
143 * shutdown the processor:
145 static inline void halt(void)
147 __asm__ __volatile__("hlt": : :"memory");
150 #else /* __ASSEMBLY__: */
151 # ifdef CONFIG_TRACE_IRQFLAGS
152 # define TRACE_IRQS_ON call trace_hardirqs_on_thunk
153 # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk
155 # define TRACE_IRQS_ON
156 # define TRACE_IRQS_OFF
158 # ifdef CONFIG_DEBUG_LOCK_ALLOC
159 # define LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
160 # define LOCKDEP_SYS_EXIT_IRQ \
169 # define LOCKDEP_SYS_EXIT
170 # define LOCKDEP_SYS_EXIT_IRQ