Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 1 | /* |
Heiko Carstens | 428aecf | 2010-01-27 10:12:36 +0100 | [diff] [blame] | 2 | * Copyright IBM Corp. 2006,2010 |
| 3 | * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __ASM_IRQFLAGS_H |
| 7 | #define __ASM_IRQFLAGS_H |
| 8 | |
Heiko Carstens | 428aecf | 2010-01-27 10:12:36 +0100 | [diff] [blame] | 9 | #include <linux/types.h> |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 10 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 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; \ |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 19 | }) |
| 20 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 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 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 37 | /* interrupt control.. */ |
| 38 | static inline unsigned long raw_local_irq_enable(void) |
| 39 | { |
| 40 | return __raw_local_irq_stosm(0x03); |
| 41 | } |
| 42 | |
| 43 | static 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) \ |
| 49 | do { \ |
| 50 | typecheck(unsigned long, x); \ |
| 51 | (x) = __raw_local_irq_stosm(0x00); \ |
| 52 | } while (0) |
| 53 | |
| 54 | static inline void raw_local_irq_restore(unsigned long flags) |
| 55 | { |
| 56 | __raw_local_irq_ssm(flags); |
| 57 | } |
| 58 | |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 59 | static inline int raw_irqs_disabled_flags(unsigned long flags) |
| 60 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 61 | return !(flags & (3UL << (BITS_PER_LONG - 8))); |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /* For spinlocks etc */ |
| 65 | #define raw_local_irq_save(x) ((x) = raw_local_irq_disable()) |
| 66 | |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 67 | #endif /* __ASM_IRQFLAGS_H */ |