1 /* SPDX-License-Identifier: GPL-2.0 */
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>
11 #ifndef _ASM_IA64_IRQFLAGS_H
12 #define _ASM_IA64_IRQFLAGS_H
15 #include <asm/kregs.h>
17 #ifdef CONFIG_IA64_DEBUG_IRQ
18 extern unsigned long last_cli_ip
;
19 static inline void arch_maybe_save_ip(unsigned long flags
)
21 if (flags
& IA64_PSR_I
)
22 last_cli_ip
= ia64_getreg(_IA64_REG_IP
);
25 #define arch_maybe_save_ip(flags) do {} while (0)
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
36 static inline unsigned long arch_local_save_flags(void)
39 return ia64_getreg(_IA64_REG_PSR
);
42 static inline unsigned long arch_local_irq_save(void)
44 unsigned long flags
= arch_local_save_flags();
48 arch_maybe_save_ip(flags
);
52 static inline void arch_local_irq_disable(void)
54 #ifdef CONFIG_IA64_DEBUG_IRQ
55 arch_local_irq_save();
62 static inline void arch_local_irq_enable(void)
69 static inline void arch_local_irq_restore(unsigned long flags
)
71 #ifdef CONFIG_IA64_DEBUG_IRQ
72 unsigned long old_psr
= arch_local_save_flags();
74 ia64_intrin_local_irq_restore(flags
& IA64_PSR_I
);
75 arch_maybe_save_ip(old_psr
& ~flags
);
78 static inline bool arch_irqs_disabled_flags(unsigned long flags
)
80 return (flags
& IA64_PSR_I
) == 0;
83 static inline bool arch_irqs_disabled(void)
85 return arch_irqs_disabled_flags(arch_local_save_flags());
88 static inline void arch_safe_halt(void)
90 arch_local_irq_enable();
91 ia64_pal_halt_light(); /* PAL_HALT_LIGHT */
95 #endif /* _ASM_IA64_IRQFLAGS_H */