1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_GENERIC_IRQFLAGS_H
3 #define __ASM_GENERIC_IRQFLAGS_H
6 * All architectures should implement at least the first two functions,
7 * usually inline assembly will be the best way.
9 #ifndef ARCH_IRQ_DISABLED
10 #define ARCH_IRQ_DISABLED 0
11 #define ARCH_IRQ_ENABLED 1
14 /* read interrupt enabled status */
15 #ifndef arch_local_save_flags
16 unsigned long arch_local_save_flags(void);
19 /* set interrupt enabled status */
20 #ifndef arch_local_irq_restore
21 void arch_local_irq_restore(unsigned long flags);
24 /* get status and disable interrupts */
25 #ifndef arch_local_irq_save
26 static inline unsigned long arch_local_irq_save(void)
29 flags = arch_local_save_flags();
30 arch_local_irq_restore(ARCH_IRQ_DISABLED);
36 #ifndef arch_irqs_disabled_flags
37 static inline int arch_irqs_disabled_flags(unsigned long flags)
39 return flags == ARCH_IRQ_DISABLED;
43 /* unconditionally enable interrupts */
44 #ifndef arch_local_irq_enable
45 static inline void arch_local_irq_enable(void)
47 arch_local_irq_restore(ARCH_IRQ_ENABLED);
51 /* unconditionally disable interrupts */
52 #ifndef arch_local_irq_disable
53 static inline void arch_local_irq_disable(void)
55 arch_local_irq_restore(ARCH_IRQ_DISABLED);
59 /* test hardware interrupt enable bit */
60 #ifndef arch_irqs_disabled
61 static inline int arch_irqs_disabled(void)
63 return arch_irqs_disabled_flags(arch_local_save_flags());
67 #endif /* __ASM_GENERIC_IRQFLAGS_H */