Merge tag 'fcoe' into fixes
[cascardo/linux.git] / arch / ia64 / include / asm / irqflags.h
1 /*
2  * IRQ flags defines.
3  *
4  * Copyright (C) 1998-2003 Hewlett-Packard Co
5  *      David Mosberger-Tang <davidm@hpl.hp.com>
6  * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
7  * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
8  */
9
10 #ifndef _ASM_IA64_IRQFLAGS_H
11 #define _ASM_IA64_IRQFLAGS_H
12
13 #include <asm/pal.h>
14
15 #ifdef CONFIG_IA64_DEBUG_IRQ
16 extern unsigned long last_cli_ip;
17 static inline void arch_maybe_save_ip(unsigned long flags)
18 {
19         if (flags & IA64_PSR_I)
20                 last_cli_ip = ia64_getreg(_IA64_REG_IP);
21 }
22 #else
23 #define arch_maybe_save_ip(flags) do {} while (0)
24 #endif
25
26 /*
27  * - clearing psr.i is implicitly serialized (visible by next insn)
28  * - setting psr.i requires data serialization
29  * - we need a stop-bit before reading PSR because we sometimes
30  *   write a floating-point register right before reading the PSR
31  *   and that writes to PSR.mfl
32  */
33
34 static inline unsigned long arch_local_save_flags(void)
35 {
36         ia64_stop();
37 #ifdef CONFIG_PARAVIRT
38         return ia64_get_psr_i();
39 #else
40         return ia64_getreg(_IA64_REG_PSR);
41 #endif
42 }
43
44 static inline unsigned long arch_local_irq_save(void)
45 {
46         unsigned long flags = arch_local_save_flags();
47
48         ia64_stop();
49         ia64_rsm(IA64_PSR_I);
50         arch_maybe_save_ip(flags);
51         return flags;
52 }
53
54 static inline void arch_local_irq_disable(void)
55 {
56 #ifdef CONFIG_IA64_DEBUG_IRQ
57         arch_local_irq_save();
58 #else
59         ia64_stop();
60         ia64_rsm(IA64_PSR_I);
61 #endif
62 }
63
64 static inline void arch_local_irq_enable(void)
65 {
66         ia64_stop();
67         ia64_ssm(IA64_PSR_I);
68         ia64_srlz_d();
69 }
70
71 static inline void arch_local_irq_restore(unsigned long flags)
72 {
73 #ifdef CONFIG_IA64_DEBUG_IRQ
74         unsigned long old_psr = arch_local_save_flags();
75 #endif
76         ia64_intrin_local_irq_restore(flags & IA64_PSR_I);
77         arch_maybe_save_ip(old_psr & ~flags);
78 }
79
80 static inline bool arch_irqs_disabled_flags(unsigned long flags)
81 {
82         return (flags & IA64_PSR_I) == 0;
83 }
84
85 static inline bool arch_irqs_disabled(void)
86 {
87         return arch_irqs_disabled_flags(arch_local_save_flags());
88 }
89
90 static inline void arch_safe_halt(void)
91 {
92         arch_local_irq_enable();
93         ia64_pal_halt_light();  /* PAL_HALT_LIGHT */
94 }
95
96
97 #endif /* _ASM_IA64_IRQFLAGS_H */