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/* store then or system mask. */ 12#define __raw_local_irq_stosm(__or) \ 13({ \ 14 unsigned long __mask; \ 15 asm volatile( \ 16 " stosm %0,%1" \ 17 : "=Q" (__mask) : "i" (__or) : "memory"); \ 18 __mask; \ 19}) 20 21/* store then and system mask. */ 22#define __raw_local_irq_stnsm(__and) \ 23({ \ 24 unsigned long __mask; \ 25 asm volatile( \ 26 " stnsm %0,%1" \ 27 : "=Q" (__mask) : "i" (__and) : "memory"); \ 28 __mask; \ 29}) 30 31/* set system mask. */ 32#define __raw_local_irq_ssm(__mask) \ 33({ \ 34 asm volatile("ssm %0" : : "Q" (__mask) : "memory"); \ 35}) 36 37/* interrupt control.. */ 38static inline unsigned long raw_local_irq_enable(void) 39{ 40 return __raw_local_irq_stosm(0x03); 41} 42 43static inline unsigned long raw_local_irq_disable(void) 44{ 45 return __raw_local_irq_stnsm(0xfc); 46} 47 48#define raw_local_save_flags(x) \ 49do { \ 50 typecheck(unsigned long, x); \ 51 (x) = __raw_local_irq_stosm(0x00); \ 52} while (0) 53 54static inline void raw_local_irq_restore(unsigned long flags) 55{ 56 __raw_local_irq_ssm(flags); 57} 58 59static inline int raw_irqs_disabled_flags(unsigned long flags) 60{ 61 return !(flags & (3UL << (BITS_PER_LONG - 8))); 62} 63 64/* For spinlocks etc */ 65#define raw_local_irq_save(x) ((x) = raw_local_irq_disable()) 66 67#endif /* __ASM_IRQFLAGS_H */ 68