]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/asm-x86_64/irqflags.h
ieee1394: merge from Linus
[mirror_ubuntu-artful-kernel.git] / include / asm-x86_64 / irqflags.h
1 /*
2 * include/asm-x86_64/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 * Interrupt control:
16 */
17
18 static inline unsigned long __raw_local_save_flags(void)
19 {
20 unsigned long flags;
21
22 __asm__ __volatile__(
23 "# __raw_save_flags\n\t"
24 "pushfq ; popq %q0"
25 : "=g" (flags)
26 : /* no input */
27 : "memory"
28 );
29
30 return flags;
31 }
32
33 #define raw_local_save_flags(flags) \
34 do { (flags) = __raw_local_save_flags(); } while (0)
35
36 static inline void raw_local_irq_restore(unsigned long flags)
37 {
38 __asm__ __volatile__(
39 "pushq %0 ; popfq"
40 : /* no output */
41 :"g" (flags)
42 :"memory", "cc"
43 );
44 }
45
46 #ifdef CONFIG_X86_VSMP
47
48 /*
49 * Interrupt control for the VSMP architecture:
50 */
51
52 static inline void raw_local_irq_disable(void)
53 {
54 unsigned long flags = __raw_local_save_flags();
55
56 raw_local_irq_restore((flags & ~(1 << 9)) | (1 << 18));
57 }
58
59 static inline void raw_local_irq_enable(void)
60 {
61 unsigned long flags = __raw_local_save_flags();
62
63 raw_local_irq_restore((flags | (1 << 9)) & ~(1 << 18));
64 }
65
66 static inline int raw_irqs_disabled_flags(unsigned long flags)
67 {
68 return !(flags & (1<<9)) || (flags & (1 << 18));
69 }
70
71 #else /* CONFIG_X86_VSMP */
72
73 static inline void raw_local_irq_disable(void)
74 {
75 __asm__ __volatile__("cli" : : : "memory");
76 }
77
78 static inline void raw_local_irq_enable(void)
79 {
80 __asm__ __volatile__("sti" : : : "memory");
81 }
82
83 static inline int raw_irqs_disabled_flags(unsigned long flags)
84 {
85 return !(flags & (1 << 9));
86 }
87
88 #endif
89
90 /*
91 * For spinlocks, etc.:
92 */
93
94 static inline unsigned long __raw_local_irq_save(void)
95 {
96 unsigned long flags = __raw_local_save_flags();
97
98 raw_local_irq_disable();
99
100 return flags;
101 }
102
103 #define raw_local_irq_save(flags) \
104 do { (flags) = __raw_local_irq_save(); } while (0)
105
106 static inline int raw_irqs_disabled(void)
107 {
108 unsigned long flags = __raw_local_save_flags();
109
110 return raw_irqs_disabled_flags(flags);
111 }
112
113 /*
114 * Used in the idle loop; sti takes one instruction cycle
115 * to complete:
116 */
117 static inline void raw_safe_halt(void)
118 {
119 __asm__ __volatile__("sti; hlt" : : : "memory");
120 }
121
122 /*
123 * Used when interrupts are already enabled or to
124 * shutdown the processor:
125 */
126 static inline void halt(void)
127 {
128 __asm__ __volatile__("hlt": : :"memory");
129 }
130
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
140
141 #endif