1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2a439fe51SSam Ravnborg /* 3a439fe51SSam Ravnborg * include/asm/irqflags.h 4a439fe51SSam Ravnborg * 5a439fe51SSam Ravnborg * IRQ flags handling 6a439fe51SSam Ravnborg * 7a439fe51SSam Ravnborg * This file gets included from lowlevel asm headers too, to provide 8a439fe51SSam Ravnborg * wrapped versions of the local_irq_*() APIs, based on the 9df9ee292SDavid Howells * arch_local_irq_*() functions from the lowlevel headers. 10a439fe51SSam Ravnborg */ 11a439fe51SSam Ravnborg #ifndef _ASM_IRQFLAGS_H 12a439fe51SSam Ravnborg #define _ASM_IRQFLAGS_H 13a439fe51SSam Ravnborg 14a439fe51SSam Ravnborg #ifndef __ASSEMBLY__ 15a439fe51SSam Ravnborg 16df9ee292SDavid Howells #include <linux/types.h> 17d550bbd4SDavid Howells #include <asm/psr.h> 18a439fe51SSam Ravnborg 19f05a6865SSam Ravnborg void arch_local_irq_restore(unsigned long); 20f05a6865SSam Ravnborg unsigned long arch_local_irq_save(void); 21f05a6865SSam Ravnborg void arch_local_irq_enable(void); 22df9ee292SDavid Howells arch_local_save_flags(void)2318d85bc5SSteven Rostedtstatic inline notrace unsigned long arch_local_save_flags(void) 24a439fe51SSam Ravnborg { 25df9ee292SDavid Howells unsigned long flags; 26a439fe51SSam Ravnborg 27df9ee292SDavid Howells asm volatile("rd %%psr, %0" : "=r" (flags)); 28df9ee292SDavid Howells return flags; 29a439fe51SSam Ravnborg } 30a439fe51SSam Ravnborg arch_local_irq_disable(void)3118d85bc5SSteven Rostedtstatic inline notrace void arch_local_irq_disable(void) 32a439fe51SSam Ravnborg { 33df9ee292SDavid Howells arch_local_irq_save(); 34df9ee292SDavid Howells } 35df9ee292SDavid Howells arch_irqs_disabled_flags(unsigned long flags)3618d85bc5SSteven Rostedtstatic inline notrace bool arch_irqs_disabled_flags(unsigned long flags) 37df9ee292SDavid Howells { 38df9ee292SDavid Howells return (flags & PSR_PIL) != 0; 39df9ee292SDavid Howells } 40df9ee292SDavid Howells arch_irqs_disabled(void)4118d85bc5SSteven Rostedtstatic inline notrace bool arch_irqs_disabled(void) 42df9ee292SDavid Howells { 43df9ee292SDavid Howells return arch_irqs_disabled_flags(arch_local_save_flags()); 44a439fe51SSam Ravnborg } 45a439fe51SSam Ravnborg 46a439fe51SSam Ravnborg #endif /* (__ASSEMBLY__) */ 47a439fe51SSam Ravnborg 48a439fe51SSam Ravnborg #endif /* !(_ASM_IRQFLAGS_H) */ 49