1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2006, 2010
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7 #ifndef __ASM_IRQFLAGS_H
8 #define __ASM_IRQFLAGS_H
10 #include <linux/types.h>
12 #define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8))
14 /* store then OR system mask. */
15 #define __arch_local_irq_stosm(__or) \
17 unsigned long __mask; \
20 : "=Q" (__mask) : "i" (__or) : "memory"); \
24 /* store then AND system mask. */
25 #define __arch_local_irq_stnsm(__and) \
27 unsigned long __mask; \
30 : "=Q" (__mask) : "i" (__and) : "memory"); \
34 /* set system mask. */
35 static inline notrace
void __arch_local_irq_ssm(unsigned long flags
)
37 asm volatile("ssm %0" : : "Q" (flags
) : "memory");
40 static inline notrace
unsigned long arch_local_save_flags(void)
42 return __arch_local_irq_stnsm(0xff);
45 static inline notrace
unsigned long arch_local_irq_save(void)
47 return __arch_local_irq_stnsm(0xfc);
50 static inline notrace
void arch_local_irq_disable(void)
52 arch_local_irq_save();
55 static inline notrace
void arch_local_irq_enable(void)
57 __arch_local_irq_stosm(0x03);
60 /* This only restores external and I/O interrupt state */
61 static inline notrace
void arch_local_irq_restore(unsigned long flags
)
63 /* only disabled->disabled and disabled->enabled is valid */
64 if (flags
& ARCH_IRQ_ENABLED
)
65 arch_local_irq_enable();
68 static inline notrace
bool arch_irqs_disabled_flags(unsigned long flags
)
70 return !(flags
& ARCH_IRQ_ENABLED
);
73 static inline notrace
bool arch_irqs_disabled(void)
75 return arch_irqs_disabled_flags(arch_local_save_flags());
78 #endif /* __ASM_IRQFLAGS_H */