[PATCH] lockdep: irqtrace subsystem, i386 support
[pandora-kernel.git] / include / asm-i386 / irqflags.h
1 /*
2  * include/asm-i386/irqflags.h
3  *
4  * IRQ flags handling
5  *
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_*() macros from the lowlevel headers.
9  */
10 #ifndef _ASM_IRQFLAGS_H
11 #define _ASM_IRQFLAGS_H
12
13 #define raw_local_save_flags(x) do { typecheck(unsigned long,x); __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */); } while (0)
14 #define raw_local_irq_restore(x) do { typecheck(unsigned long,x); __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc"); } while (0)
15 #define raw_local_irq_disable() __asm__ __volatile__("cli": : :"memory")
16 #define raw_local_irq_enable()  __asm__ __volatile__("sti": : :"memory")
17 /* used in the idle loop; sti takes one instruction cycle to complete */
18 #define raw_safe_halt()         __asm__ __volatile__("sti; hlt": : :"memory")
19 /* used when interrupts are already enabled or to shutdown the processor */
20 #define halt()                  __asm__ __volatile__("hlt": : :"memory")
21
22 #define raw_irqs_disabled_flags(flags)  (!((flags) & (1<<9)))
23
24 /* For spinlocks etc */
25 #define raw_local_irq_save(x)   __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
26
27 /*
28  * Do the CPU's IRQ-state tracing from assembly code. We call a
29  * C function, so save all the C-clobbered registers:
30  */
31 #ifdef CONFIG_TRACE_IRQFLAGS
32
33 # define TRACE_IRQS_ON                          \
34         pushl %eax;                             \
35         pushl %ecx;                             \
36         pushl %edx;                             \
37         call trace_hardirqs_on;                 \
38         popl %edx;                              \
39         popl %ecx;                              \
40         popl %eax;
41
42 # define TRACE_IRQS_OFF                         \
43         pushl %eax;                             \
44         pushl %ecx;                             \
45         pushl %edx;                             \
46         call trace_hardirqs_off;                \
47         popl %edx;                              \
48         popl %ecx;                              \
49         popl %eax;
50
51 #else
52 # define TRACE_IRQS_ON
53 # define TRACE_IRQS_OFF
54 #endif
55
56 #endif