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