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 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 11 | /* store then OR system mask. */ |
| 12 | #define __arch_local_irq_stosm(__or) \ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 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 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 21 | /* store then AND system mask. */ |
| 22 | #define __arch_local_irq_stnsm(__and) \ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 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. */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 32 | static inline void __arch_local_irq_ssm(unsigned long flags) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 33 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 34 | asm volatile("ssm %0" : : "Q" (flags) : "memory"); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 35 | } |
| 36 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 37 | static inline unsigned long arch_local_save_flags(void) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 38 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 39 | return __arch_local_irq_stosm(0x00); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 40 | } |
| 41 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 42 | static inline unsigned long arch_local_irq_save(void) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 43 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 44 | return __arch_local_irq_stnsm(0xfc); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 45 | } |
| 46 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 47 | static inline void arch_local_irq_disable(void) |
| 48 | { |
| 49 | arch_local_irq_save(); |
| 50 | } |
| 51 | |
| 52 | static inline void arch_local_irq_enable(void) |
| 53 | { |
| 54 | __arch_local_irq_stosm(0x03); |
| 55 | } |
| 56 | |
| 57 | static inline void arch_local_irq_restore(unsigned long flags) |
| 58 | { |
| 59 | __arch_local_irq_ssm(flags); |
| 60 | } |
| 61 | |
| 62 | static inline bool arch_irqs_disabled_flags(unsigned long flags) |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 63 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 64 | return !(flags & (3UL << (BITS_PER_LONG - 8))); |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 65 | } |
| 66 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 67 | static inline bool arch_irqs_disabled(void) |
| 68 | { |
| 69 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
| 70 | } |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 71 | |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 72 | #endif /* __ASM_IRQFLAGS_H */ |