Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 2 | /* |
| 3 | * include/asm/irqflags.h |
| 4 | * |
| 5 | * IRQ flags handling |
| 6 | * |
| 7 | * This file gets included from lowlevel asm headers too, to provide |
| 8 | * wrapped versions of the local_irq_*() APIs, based on the |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 9 | * arch_local_irq_*() functions from the lowlevel headers. |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 10 | */ |
| 11 | #ifndef _ASM_IRQFLAGS_H |
| 12 | #define _ASM_IRQFLAGS_H |
| 13 | |
| 14 | #ifndef __ASSEMBLY__ |
| 15 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 16 | #include <linux/types.h> |
David Howells | d550bbd | 2012-03-28 18:30:03 +0100 | [diff] [blame] | 17 | #include <asm/psr.h> |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 18 | |
Sam Ravnborg | f05a686 | 2014-05-16 23:25:50 +0200 | [diff] [blame] | 19 | void arch_local_irq_restore(unsigned long); |
| 20 | unsigned long arch_local_irq_save(void); |
| 21 | void arch_local_irq_enable(void); |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 22 | |
Steven Rostedt | 18d85bc | 2011-07-06 08:00:29 -0700 | [diff] [blame] | 23 | static inline notrace unsigned long arch_local_save_flags(void) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 24 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 25 | unsigned long flags; |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 26 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 27 | asm volatile("rd %%psr, %0" : "=r" (flags)); |
| 28 | return flags; |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 29 | } |
| 30 | |
Steven Rostedt | 18d85bc | 2011-07-06 08:00:29 -0700 | [diff] [blame] | 31 | static inline notrace void arch_local_irq_disable(void) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 32 | { |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 33 | arch_local_irq_save(); |
| 34 | } |
| 35 | |
Steven Rostedt | 18d85bc | 2011-07-06 08:00:29 -0700 | [diff] [blame] | 36 | static inline notrace bool arch_irqs_disabled_flags(unsigned long flags) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 37 | { |
| 38 | return (flags & PSR_PIL) != 0; |
| 39 | } |
| 40 | |
Steven Rostedt | 18d85bc | 2011-07-06 08:00:29 -0700 | [diff] [blame] | 41 | static inline notrace bool arch_irqs_disabled(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 42 | { |
| 43 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | #endif /* (__ASSEMBLY__) */ |
| 47 | |
| 48 | #endif /* !(_ASM_IRQFLAGS_H) */ |