Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 1 | /* |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 2 | * Copyright IBM Corp. 2006, 2010 |
Heiko Carstens | 428aecf | 2010-01-27 10:12:36 +0100 | [diff] [blame] | 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 | |
Christian Borntraeger | 204ee2c | 2016-01-11 09:17:18 +0100 | [diff] [blame] | 11 | #define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8)) |
| 12 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 13 | /* store then OR system mask. */ |
| 14 | #define __arch_local_irq_stosm(__or) \ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 15 | ({ \ |
| 16 | unsigned long __mask; \ |
| 17 | asm volatile( \ |
| 18 | " stosm %0,%1" \ |
| 19 | : "=Q" (__mask) : "i" (__or) : "memory"); \ |
| 20 | __mask; \ |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 21 | }) |
| 22 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 23 | /* store then AND system mask. */ |
| 24 | #define __arch_local_irq_stnsm(__and) \ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 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. */ |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 34 | static inline notrace void __arch_local_irq_ssm(unsigned long flags) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 35 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 36 | asm volatile("ssm %0" : : "Q" (flags) : "memory"); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 37 | } |
| 38 | |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 39 | static inline notrace unsigned long arch_local_save_flags(void) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 40 | { |
Christian Borntraeger | 81fc77f | 2014-12-16 10:25:37 +0100 | [diff] [blame] | 41 | return __arch_local_irq_stnsm(0xff); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 42 | } |
| 43 | |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 44 | static inline notrace unsigned long arch_local_irq_save(void) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 45 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 46 | return __arch_local_irq_stnsm(0xfc); |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 47 | } |
| 48 | |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 49 | static inline notrace void arch_local_irq_disable(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 50 | { |
| 51 | arch_local_irq_save(); |
| 52 | } |
| 53 | |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 54 | static inline notrace void arch_local_irq_enable(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 55 | { |
| 56 | __arch_local_irq_stosm(0x03); |
| 57 | } |
| 58 | |
Christian Borntraeger | 204ee2c | 2016-01-11 09:17:18 +0100 | [diff] [blame] | 59 | /* This only restores external and I/O interrupt state */ |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 60 | static inline notrace void arch_local_irq_restore(unsigned long flags) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 61 | { |
Christian Borntraeger | 204ee2c | 2016-01-11 09:17:18 +0100 | [diff] [blame] | 62 | /* only disabled->disabled and disabled->enabled is valid */ |
| 63 | if (flags & ARCH_IRQ_ENABLED) |
| 64 | arch_local_irq_enable(); |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 65 | } |
| 66 | |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 67 | static inline notrace bool arch_irqs_disabled_flags(unsigned long flags) |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 68 | { |
Christian Borntraeger | 204ee2c | 2016-01-11 09:17:18 +0100 | [diff] [blame] | 69 | return !(flags & ARCH_IRQ_ENABLED); |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Steven Rostedt | f433c4a | 2011-07-24 10:47:58 +0200 | [diff] [blame] | 72 | static inline notrace bool arch_irqs_disabled(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 73 | { |
| 74 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
| 75 | } |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 76 | |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 77 | #endif /* __ASM_IRQFLAGS_H */ |