x86: remove more bogus filenames in comments.
[powerpc.git] / include / asm-x86 / irqflags_64.h
1 /*
2  * IRQ flags handling
3  *
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>
11
12 #ifndef __ASSEMBLY__
13 /*
14  * Interrupt control:
15  */
16
17 static inline unsigned long __raw_local_save_flags(void)
18 {
19         unsigned long flags;
20
21         __asm__ __volatile__(
22                 "# __raw_save_flags\n\t"
23                 "pushfq ; popq %q0"
24                 : "=g" (flags)
25                 : /* no input */
26                 : "memory"
27         );
28
29         return flags;
30 }
31
32 #define raw_local_save_flags(flags) \
33                 do { (flags) = __raw_local_save_flags(); } while (0)
34
35 static inline void raw_local_irq_restore(unsigned long flags)
36 {
37         __asm__ __volatile__(
38                 "pushq %0 ; popfq"
39                 : /* no output */
40                 :"g" (flags)
41                 :"memory", "cc"
42         );
43 }
44
45 #ifdef CONFIG_X86_VSMP
46
47 /*
48  * Interrupt control for the VSMP architecture:
49  */
50
51 static inline void raw_local_irq_disable(void)
52 {
53         unsigned long flags = __raw_local_save_flags();
54
55         raw_local_irq_restore((flags & ~X86_EFLAGS_IF) | X86_EFLAGS_AC);
56 }
57
58 static inline void raw_local_irq_enable(void)
59 {
60         unsigned long flags = __raw_local_save_flags();
61
62         raw_local_irq_restore((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC));
63 }
64
65 static inline int raw_irqs_disabled_flags(unsigned long flags)
66 {
67         return !(flags & X86_EFLAGS_IF) || (flags & X86_EFLAGS_AC);
68 }
69
70 #else /* CONFIG_X86_VSMP */
71
72 static inline void raw_local_irq_disable(void)
73 {
74         __asm__ __volatile__("cli" : : : "memory");
75 }
76
77 static inline void raw_local_irq_enable(void)
78 {
79         __asm__ __volatile__("sti" : : : "memory");
80 }
81
82 static inline int raw_irqs_disabled_flags(unsigned long flags)
83 {
84         return !(flags & X86_EFLAGS_IF);
85 }
86
87 #endif
88
89 /*
90  * For spinlocks, etc.:
91  */
92
93 static inline unsigned long __raw_local_irq_save(void)
94 {
95         unsigned long flags = __raw_local_save_flags();
96
97         raw_local_irq_disable();
98
99         return flags;
100 }
101
102 #define raw_local_irq_save(flags) \
103                 do { (flags) = __raw_local_irq_save(); } while (0)
104
105 static inline int raw_irqs_disabled(void)
106 {
107         unsigned long flags = __raw_local_save_flags();
108
109         return raw_irqs_disabled_flags(flags);
110 }
111
112 /*
113  * makes the traced hardirq state match with the machine state
114  *
115  * should be a rarely used function, only in places where its
116  * otherwise impossible to know the irq state, like in traps.
117  */
118 static inline void trace_hardirqs_fixup_flags(unsigned long flags)
119 {
120         if (raw_irqs_disabled_flags(flags))
121                 trace_hardirqs_off();
122         else
123                 trace_hardirqs_on();
124 }
125
126 static inline void trace_hardirqs_fixup(void)
127 {
128         unsigned long flags = __raw_local_save_flags();
129
130         trace_hardirqs_fixup_flags(flags);
131 }
132 /*
133  * Used in the idle loop; sti takes one instruction cycle
134  * to complete:
135  */
136 static inline void raw_safe_halt(void)
137 {
138         __asm__ __volatile__("sti; hlt" : : : "memory");
139 }
140
141 /*
142  * Used when interrupts are already enabled or to
143  * shutdown the processor:
144  */
145 static inline void halt(void)
146 {
147         __asm__ __volatile__("hlt": : :"memory");
148 }
149
150 #else /* __ASSEMBLY__: */
151 # ifdef CONFIG_TRACE_IRQFLAGS
152 #  define TRACE_IRQS_ON         call trace_hardirqs_on_thunk
153 #  define TRACE_IRQS_OFF        call trace_hardirqs_off_thunk
154 # else
155 #  define TRACE_IRQS_ON
156 #  define TRACE_IRQS_OFF
157 # endif
158 # ifdef CONFIG_DEBUG_LOCK_ALLOC
159 #  define LOCKDEP_SYS_EXIT      call lockdep_sys_exit_thunk
160 #  define LOCKDEP_SYS_EXIT_IRQ  \
161         TRACE_IRQS_ON; \
162         sti; \
163         SAVE_REST; \
164         LOCKDEP_SYS_EXIT; \
165         RESTORE_REST; \
166         cli; \
167         TRACE_IRQS_OFF;
168 # else
169 #  define LOCKDEP_SYS_EXIT
170 #  define LOCKDEP_SYS_EXIT_IRQ
171 # endif
172 #endif
173
174 #endif