Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 2 | #ifndef __ASM_GENERIC_IRQFLAGS_H |
| 3 | #define __ASM_GENERIC_IRQFLAGS_H |
| 4 | |
| 5 | /* |
| 6 | * All architectures should implement at least the first two functions, |
| 7 | * usually inline assembly will be the best way. |
| 8 | */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 9 | #ifndef ARCH_IRQ_DISABLED |
| 10 | #define ARCH_IRQ_DISABLED 0 |
| 11 | #define ARCH_IRQ_ENABLED 1 |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 12 | #endif |
| 13 | |
| 14 | /* read interrupt enabled status */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 15 | #ifndef arch_local_save_flags |
| 16 | unsigned long arch_local_save_flags(void); |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 17 | #endif |
| 18 | |
| 19 | /* set interrupt enabled status */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 20 | #ifndef arch_local_irq_restore |
| 21 | void arch_local_irq_restore(unsigned long flags); |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 22 | #endif |
| 23 | |
| 24 | /* get status and disable interrupts */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 25 | #ifndef arch_local_irq_save |
| 26 | static inline unsigned long arch_local_irq_save(void) |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 27 | { |
| 28 | unsigned long flags; |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 29 | flags = arch_local_save_flags(); |
| 30 | arch_local_irq_restore(ARCH_IRQ_DISABLED); |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 31 | return flags; |
| 32 | } |
| 33 | #endif |
| 34 | |
| 35 | /* test flags */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 36 | #ifndef arch_irqs_disabled_flags |
| 37 | static inline int arch_irqs_disabled_flags(unsigned long flags) |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 38 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 39 | return flags == ARCH_IRQ_DISABLED; |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 40 | } |
| 41 | #endif |
| 42 | |
| 43 | /* unconditionally enable interrupts */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 44 | #ifndef arch_local_irq_enable |
| 45 | static inline void arch_local_irq_enable(void) |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 46 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 47 | arch_local_irq_restore(ARCH_IRQ_ENABLED); |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 48 | } |
| 49 | #endif |
| 50 | |
| 51 | /* unconditionally disable interrupts */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 52 | #ifndef arch_local_irq_disable |
| 53 | static inline void arch_local_irq_disable(void) |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 54 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 55 | arch_local_irq_restore(ARCH_IRQ_DISABLED); |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 56 | } |
| 57 | #endif |
| 58 | |
| 59 | /* test hardware interrupt enable bit */ |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 60 | #ifndef arch_irqs_disabled |
| 61 | static inline int arch_irqs_disabled(void) |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 62 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 63 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 64 | } |
| 65 | #endif |
| 66 | |
Arnd Bergmann | aafe4db | 2009-05-13 22:56:33 +0000 | [diff] [blame] | 67 | #endif /* __ASM_GENERIC_IRQFLAGS_H */ |