revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / include / asm-x86 / irqflags_32.h
blob98b21b9bdce884ea2c245212310a47e488c7b159
1 /*
2 * IRQ flags handling
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.
7 */
8 #ifndef _ASM_IRQFLAGS_H
9 #define _ASM_IRQFLAGS_H
10 #include <asm/processor-flags.h>
12 #ifndef __ASSEMBLY__
13 static inline unsigned long native_save_fl(void)
15 unsigned long f;
16 asm volatile("pushfl ; popl %0":"=g" (f): /* no input */);
17 return f;
20 static inline void native_restore_fl(unsigned long f)
22 asm volatile("pushl %0 ; popfl": /* no output */
23 :"g" (f)
24 :"memory", "cc");
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>
50 #else
51 #ifndef __ASSEMBLY__
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)
65 native_irq_disable();
68 static inline void raw_local_irq_enable(void)
70 native_irq_enable();
74 * Used in the idle loop; sti takes one instruction cycle
75 * to complete:
77 static inline void raw_safe_halt(void)
79 native_safe_halt();
83 * Used when interrupts are already enabled or to
84 * shutdown the processor:
86 static inline void halt(void)
88 native_halt();
92 * 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 #else
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 */
112 #ifndef __ASSEMBLY__
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();
141 else
142 trace_hardirqs_on();
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 \
160 pushl %eax; \
161 pushl %ecx; \
162 pushl %edx; \
163 call trace_hardirqs_on; \
164 popl %edx; \
165 popl %ecx; \
166 popl %eax;
168 # define TRACE_IRQS_OFF \
169 pushl %eax; \
170 pushl %ecx; \
171 pushl %edx; \
172 call trace_hardirqs_off; \
173 popl %edx; \
174 popl %ecx; \
175 popl %eax;
177 #else
178 # define TRACE_IRQS_ON
179 # define TRACE_IRQS_OFF
180 #endif
182 #ifdef CONFIG_DEBUG_LOCK_ALLOC
183 # define LOCKDEP_SYS_EXIT \
184 pushl %eax; \
185 pushl %ecx; \
186 pushl %edx; \
187 call lockdep_sys_exit; \
188 popl %edx; \
189 popl %ecx; \
190 popl %eax;
191 #else
192 # define LOCKDEP_SYS_EXIT
193 #endif
195 #endif