1/* 2 * Copyright IBM Corp. 2006, 2010 3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 4 */ 5 6#ifndef __ASM_IRQFLAGS_H 7#define __ASM_IRQFLAGS_H 8 9#include <linux/types.h> 10 11#define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8)) 12 13/* store then OR system mask. */ 14#define __arch_local_irq_stosm(__or) \ 15({ \ 16 unsigned long __mask; \ 17 asm volatile( \ 18 " stosm %0,%1" \ 19 : "=Q" (__mask) : "i" (__or) : "memory"); \ 20 __mask; \ 21}) 22 23/* store then AND system mask. */ 24#define __arch_local_irq_stnsm(__and) \ 25({ \ 26 unsigned long __mask; \ 27 asm volatile( \ 28 " stnsm %0,%1" \ 29 : "=Q" (__mask) : "i" (__and) : "memory"); \ 30 __mask; \ 31}) 32 33/* set system mask. */ 34static inline notrace void __arch_local_irq_ssm(unsigned long flags) 35{ 36 asm volatile("ssm %0" : : "Q" (flags) : "memory"); 37} 38 39static inline notrace unsigned long arch_local_save_flags(void) 40{ 41 return __arch_local_irq_stnsm(0xff); 42} 43 44static inline notrace unsigned long arch_local_irq_save(void) 45{ 46 return __arch_local_irq_stnsm(0xfc); 47} 48 49static inline notrace void arch_local_irq_disable(void) 50{ 51 arch_local_irq_save(); 52} 53 54static inline notrace void arch_local_irq_enable(void) 55{ 56 __arch_local_irq_stosm(0x03); 57} 58 59/* This only restores external and I/O interrupt state */ 60static inline notrace void arch_local_irq_restore(unsigned long flags) 61{ 62 /* only disabled->disabled and disabled->enabled is valid */ 63 if (flags & ARCH_IRQ_ENABLED) 64 arch_local_irq_enable(); 65} 66 67static inline notrace bool arch_irqs_disabled_flags(unsigned long flags) 68{ 69 return !(flags & ARCH_IRQ_ENABLED); 70} 71 72static inline notrace bool arch_irqs_disabled(void) 73{ 74 return arch_irqs_disabled_flags(arch_local_save_flags()); 75} 76 77#endif /* __ASM_IRQFLAGS_H */ 78