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