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_*() functions from the lowlevel headers. |
---|
9 | */ |
---|
10 | #ifndef _ASM_IRQFLAGS_H |
---|
11 | #define _ASM_IRQFLAGS_H |
---|
12 | |
---|
13 | #ifndef __ASSEMBLY__ |
---|
14 | |
---|
15 | /* |
---|
16 | * The use of 'barrier' in the following reflects their use as local-lock |
---|
17 | * operations. Reentrancy must be prevented (e.g., __cli()) /before/ following |
---|
18 | * critical operations are executed. All critical operations must complete |
---|
19 | * /before/ reentrancy is permitted (e.g., __sti()). Alpha architecture also |
---|
20 | * includes these barriers, for example. |
---|
21 | */ |
---|
22 | |
---|
23 | #define __raw_local_save_flags() (current_vcpu_info()->evtchn_upcall_mask) |
---|
24 | |
---|
25 | #define raw_local_save_flags(flags) \ |
---|
26 | do { (flags) = __raw_local_save_flags(); } while (0) |
---|
27 | |
---|
28 | #define raw_local_irq_restore(x) \ |
---|
29 | do { \ |
---|
30 | vcpu_info_t *_vcpu; \ |
---|
31 | barrier(); \ |
---|
32 | _vcpu = current_vcpu_info(); \ |
---|
33 | if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \ |
---|
34 | barrier(); /* unmask then check (avoid races) */ \ |
---|
35 | if (unlikely(_vcpu->evtchn_upcall_pending)) \ |
---|
36 | force_evtchn_callback(); \ |
---|
37 | } \ |
---|
38 | } while (0) |
---|
39 | |
---|
40 | #define raw_local_irq_disable() \ |
---|
41 | do { \ |
---|
42 | current_vcpu_info()->evtchn_upcall_mask = 1; \ |
---|
43 | barrier(); \ |
---|
44 | } while (0) |
---|
45 | |
---|
46 | #define raw_local_irq_enable() \ |
---|
47 | do { \ |
---|
48 | vcpu_info_t *_vcpu; \ |
---|
49 | barrier(); \ |
---|
50 | _vcpu = current_vcpu_info(); \ |
---|
51 | _vcpu->evtchn_upcall_mask = 0; \ |
---|
52 | barrier(); /* unmask then check (avoid races) */ \ |
---|
53 | if (unlikely(_vcpu->evtchn_upcall_pending)) \ |
---|
54 | force_evtchn_callback(); \ |
---|
55 | } while (0) |
---|
56 | |
---|
57 | /* |
---|
58 | * Used in the idle loop; sti takes one instruction cycle |
---|
59 | * to complete: |
---|
60 | */ |
---|
61 | void raw_safe_halt(void); |
---|
62 | |
---|
63 | /* |
---|
64 | * Used when interrupts are already enabled or to |
---|
65 | * shutdown the processor: |
---|
66 | */ |
---|
67 | void halt(void); |
---|
68 | |
---|
69 | static inline int raw_irqs_disabled_flags(unsigned long flags) |
---|
70 | { |
---|
71 | return (flags != 0); |
---|
72 | } |
---|
73 | |
---|
74 | #define raw_irqs_disabled() \ |
---|
75 | ({ \ |
---|
76 | unsigned long flags = __raw_local_save_flags(); \ |
---|
77 | \ |
---|
78 | raw_irqs_disabled_flags(flags); \ |
---|
79 | }) |
---|
80 | |
---|
81 | /* |
---|
82 | * For spinlocks, etc: |
---|
83 | */ |
---|
84 | #define __raw_local_irq_save() \ |
---|
85 | ({ \ |
---|
86 | unsigned long flags = __raw_local_save_flags(); \ |
---|
87 | \ |
---|
88 | raw_local_irq_disable(); \ |
---|
89 | \ |
---|
90 | flags; \ |
---|
91 | }) |
---|
92 | |
---|
93 | #define raw_local_irq_save(flags) \ |
---|
94 | do { (flags) = __raw_local_irq_save(); } while (0) |
---|
95 | |
---|
96 | #endif /* __ASSEMBLY__ */ |
---|
97 | |
---|
98 | /* |
---|
99 | * Do the CPU's IRQ-state tracing from assembly code. We call a |
---|
100 | * C function, so save all the C-clobbered registers: |
---|
101 | */ |
---|
102 | #ifdef CONFIG_TRACE_IRQFLAGS |
---|
103 | |
---|
104 | # define TRACE_IRQS_ON \ |
---|
105 | pushl %eax; \ |
---|
106 | pushl %ecx; \ |
---|
107 | pushl %edx; \ |
---|
108 | call trace_hardirqs_on; \ |
---|
109 | popl %edx; \ |
---|
110 | popl %ecx; \ |
---|
111 | popl %eax; |
---|
112 | |
---|
113 | # define TRACE_IRQS_OFF \ |
---|
114 | pushl %eax; \ |
---|
115 | pushl %ecx; \ |
---|
116 | pushl %edx; \ |
---|
117 | call trace_hardirqs_off; \ |
---|
118 | popl %edx; \ |
---|
119 | popl %ecx; \ |
---|
120 | popl %eax; |
---|
121 | |
---|
122 | #else |
---|
123 | # define TRACE_IRQS_ON |
---|
124 | # define TRACE_IRQS_OFF |
---|
125 | #endif |
---|
126 | |
---|
127 | #endif |
---|