2 * Copyright IBM Corp. 2006, 2010
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 #ifndef __ASM_IRQFLAGS_H
7 #define __ASM_IRQFLAGS_H
9 #include <linux/types.h>
11 #define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8))
13 /* store then OR system mask. */
14 #define __arch_local_irq_stosm(__or) \
16 unsigned long __mask; \
19 : "=Q" (__mask) : "i" (__or) : "memory"); \
23 /* store then AND system mask. */
24 #define __arch_local_irq_stnsm(__and) \
26 unsigned long __mask; \
29 : "=Q" (__mask) : "i" (__and) : "memory"); \
33 /* set system mask. */
34 static inline notrace
void __arch_local_irq_ssm(unsigned long flags
)
36 asm volatile("ssm %0" : : "Q" (flags
) : "memory");
39 static inline notrace
unsigned long arch_local_save_flags(void)
41 return __arch_local_irq_stnsm(0xff);
44 static inline notrace
unsigned long arch_local_irq_save(void)
46 return __arch_local_irq_stnsm(0xfc);
49 static inline notrace
void arch_local_irq_disable(void)
51 arch_local_irq_save();
54 static inline notrace
void arch_local_irq_enable(void)
56 __arch_local_irq_stosm(0x03);
59 /* This only restores external and I/O interrupt state */
60 static inline notrace
void arch_local_irq_restore(unsigned long flags
)
62 /* only disabled->disabled and disabled->enabled is valid */
63 if (flags
& ARCH_IRQ_ENABLED
)
64 arch_local_irq_enable();
67 static inline notrace
bool arch_irqs_disabled_flags(unsigned long flags
)
69 return !(flags
& ARCH_IRQ_ENABLED
);
72 static inline notrace
bool arch_irqs_disabled(void)
74 return arch_irqs_disabled_flags(arch_local_save_flags());
77 #endif /* __ASM_IRQFLAGS_H */