Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[wrt350n-kernel.git] / include / asm-x86_64 / irqflags.h
blob86e70fe23659bded0499fc85b0bb359aa7e3387c
1 /*
2 * include/asm-x86_64/irqflags.h
4 * IRQ flags handling
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.
9 */
10 #ifndef _ASM_IRQFLAGS_H
11 #define _ASM_IRQFLAGS_H
12 #include <asm/processor-flags.h>
14 #ifndef __ASSEMBLY__
16 * Interrupt control:
19 static inline unsigned long __raw_local_save_flags(void)
21 unsigned long flags;
23 __asm__ __volatile__(
24 "# __raw_save_flags\n\t"
25 "pushfq ; popq %q0"
26 : "=g" (flags)
27 : /* no input */
28 : "memory"
31 return flags;
34 #define raw_local_save_flags(flags) \
35 do { (flags) = __raw_local_save_flags(); } while (0)
37 static inline void raw_local_irq_restore(unsigned long flags)
39 __asm__ __volatile__(
40 "pushq %0 ; popfq"
41 : /* no output */
42 :"g" (flags)
43 :"memory", "cc"
47 #ifdef CONFIG_X86_VSMP
50 * Interrupt control for the VSMP architecture:
53 static inline void raw_local_irq_disable(void)
55 unsigned long flags = __raw_local_save_flags();
57 raw_local_irq_restore((flags & ~X86_EFLAGS_IF) | X86_EFLAGS_AC);
60 static inline void raw_local_irq_enable(void)
62 unsigned long flags = __raw_local_save_flags();
64 raw_local_irq_restore((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC));
67 static inline int raw_irqs_disabled_flags(unsigned long flags)
69 return !(flags & X86_EFLAGS_IF) || (flags & X86_EFLAGS_AC);
72 #else /* CONFIG_X86_VSMP */
74 static inline void raw_local_irq_disable(void)
76 __asm__ __volatile__("cli" : : : "memory");
79 static inline void raw_local_irq_enable(void)
81 __asm__ __volatile__("sti" : : : "memory");
84 static inline int raw_irqs_disabled_flags(unsigned long flags)
86 return !(flags & X86_EFLAGS_IF);
89 #endif
92 * For spinlocks, etc.:
95 static inline unsigned long __raw_local_irq_save(void)
97 unsigned long flags = __raw_local_save_flags();
99 raw_local_irq_disable();
101 return flags;
104 #define raw_local_irq_save(flags) \
105 do { (flags) = __raw_local_irq_save(); } while (0)
107 static inline int raw_irqs_disabled(void)
109 unsigned long flags = __raw_local_save_flags();
111 return raw_irqs_disabled_flags(flags);
115 * Used in the idle loop; sti takes one instruction cycle
116 * to complete:
118 static inline void raw_safe_halt(void)
120 __asm__ __volatile__("sti; hlt" : : : "memory");
124 * Used when interrupts are already enabled or to
125 * shutdown the processor:
127 static inline void halt(void)
129 __asm__ __volatile__("hlt": : :"memory");
132 #else /* __ASSEMBLY__: */
133 # ifdef CONFIG_TRACE_IRQFLAGS
134 # define TRACE_IRQS_ON call trace_hardirqs_on_thunk
135 # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk
136 # else
137 # define TRACE_IRQS_ON
138 # define TRACE_IRQS_OFF
139 # endif
140 #endif
142 #endif