IB/mthca: Query port fix
[linux-2.6/verdex.git] / include / asm-x86_64 / irqflags.h
blobcce6937e87c08a999510d16b692c8961ded0f774
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
13 #ifndef __ASSEMBLY__
15 * Interrupt control:
18 static inline unsigned long __raw_local_save_flags(void)
20 unsigned long flags;
22 __asm__ __volatile__(
23 "# __raw_save_flags\n\t"
24 "pushfq ; popq %q0"
25 : "=g" (flags)
26 : /* no input */
27 : "memory"
30 return flags;
33 #define raw_local_save_flags(flags) \
34 do { (flags) = __raw_local_save_flags(); } while (0)
36 static inline void raw_local_irq_restore(unsigned long flags)
38 __asm__ __volatile__(
39 "pushq %0 ; popfq"
40 : /* no output */
41 :"g" (flags)
42 :"memory", "cc"
46 #ifdef CONFIG_X86_VSMP
49 * Interrupt control for the VSMP architecture:
52 static inline void raw_local_irq_disable(void)
54 unsigned long flags = __raw_local_save_flags();
56 raw_local_irq_restore((flags & ~(1 << 9)) | (1 << 18));
59 static inline void raw_local_irq_enable(void)
61 unsigned long flags = __raw_local_save_flags();
63 raw_local_irq_restore((flags | (1 << 9)) & ~(1 << 18));
66 static inline int raw_irqs_disabled_flags(unsigned long flags)
68 return !(flags & (1<<9)) || (flags & (1 << 18));
71 #else /* CONFIG_X86_VSMP */
73 static inline void raw_local_irq_disable(void)
75 __asm__ __volatile__("cli" : : : "memory");
78 static inline void raw_local_irq_enable(void)
80 __asm__ __volatile__("sti" : : : "memory");
83 static inline int raw_irqs_disabled_flags(unsigned long flags)
85 return !(flags & (1 << 9));
88 #endif
91 * For spinlocks, etc.:
94 static inline unsigned long __raw_local_irq_save(void)
96 unsigned long flags = __raw_local_save_flags();
98 raw_local_irq_disable();
100 return flags;
103 #define raw_local_irq_save(flags) \
104 do { (flags) = __raw_local_irq_save(); } while (0)
106 static inline int raw_irqs_disabled(void)
108 unsigned long flags = __raw_local_save_flags();
110 return raw_irqs_disabled_flags(flags);
114 * Used in the idle loop; sti takes one instruction cycle
115 * to complete:
117 static inline void raw_safe_halt(void)
119 __asm__ __volatile__("sti; hlt" : : : "memory");
123 * Used when interrupts are already enabled or to
124 * shutdown the processor:
126 static inline void halt(void)
128 __asm__ __volatile__("hlt": : :"memory");
131 #else /* __ASSEMBLY__: */
132 # ifdef CONFIG_TRACE_IRQFLAGS
133 # define TRACE_IRQS_ON call trace_hardirqs_on_thunk
134 # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk
135 # else
136 # define TRACE_IRQS_ON
137 # define TRACE_IRQS_OFF
138 # endif
139 #endif
141 #endif