1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2df9ee292SDavid Howells #ifndef __PARISC_IRQFLAGS_H 3df9ee292SDavid Howells #define __PARISC_IRQFLAGS_H 4df9ee292SDavid Howells 5df9ee292SDavid Howells #include <linux/types.h> 6df9ee292SDavid Howells #include <asm/psw.h> 7df9ee292SDavid Howells arch_local_save_flags(void)8df9ee292SDavid Howellsstatic inline unsigned long arch_local_save_flags(void) 9df9ee292SDavid Howells { 10df9ee292SDavid Howells unsigned long flags; 11df9ee292SDavid Howells asm volatile("ssm 0, %0" : "=r" (flags) : : "memory"); 12df9ee292SDavid Howells return flags; 13df9ee292SDavid Howells } 14df9ee292SDavid Howells arch_local_irq_disable(void)15df9ee292SDavid Howellsstatic inline void arch_local_irq_disable(void) 16df9ee292SDavid Howells { 17df9ee292SDavid Howells asm volatile("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory"); 18df9ee292SDavid Howells } 19df9ee292SDavid Howells arch_local_irq_enable(void)20df9ee292SDavid Howellsstatic inline void arch_local_irq_enable(void) 21df9ee292SDavid Howells { 22df9ee292SDavid Howells asm volatile("ssm %0,%%r0\n" : : "i" (PSW_I) : "memory"); 23df9ee292SDavid Howells } 24df9ee292SDavid Howells arch_local_irq_save(void)25df9ee292SDavid Howellsstatic inline unsigned long arch_local_irq_save(void) 26df9ee292SDavid Howells { 27df9ee292SDavid Howells unsigned long flags; 28df9ee292SDavid Howells asm volatile("rsm %1,%0" : "=r" (flags) : "i" (PSW_I) : "memory"); 29df9ee292SDavid Howells return flags; 30df9ee292SDavid Howells } 31df9ee292SDavid Howells arch_local_irq_restore(unsigned long flags)32df9ee292SDavid Howellsstatic inline void arch_local_irq_restore(unsigned long flags) 33df9ee292SDavid Howells { 34*40c9c62cSHelge Deller /* warn if IRQs are on although they should be off */ 35*40c9c62cSHelge Deller if (IS_ENABLED(CONFIG_LIGHTWEIGHT_SPINLOCK_CHECK)) 36*40c9c62cSHelge Deller if (arch_local_save_flags() & PSW_I) 37*40c9c62cSHelge Deller asm volatile("break 6,6\n"); /* SPINLOCK_BREAK_INSN */ 38*40c9c62cSHelge Deller 39df9ee292SDavid Howells asm volatile("mtsm %0" : : "r" (flags) : "memory"); 40df9ee292SDavid Howells } 41df9ee292SDavid Howells arch_irqs_disabled_flags(unsigned long flags)42df9ee292SDavid Howellsstatic inline bool arch_irqs_disabled_flags(unsigned long flags) 43df9ee292SDavid Howells { 44df9ee292SDavid Howells return (flags & PSW_I) == 0; 45df9ee292SDavid Howells } 46df9ee292SDavid Howells arch_irqs_disabled(void)47df9ee292SDavid Howellsstatic inline bool arch_irqs_disabled(void) 48df9ee292SDavid Howells { 49df9ee292SDavid Howells return arch_irqs_disabled_flags(arch_local_save_flags()); 50df9ee292SDavid Howells } 51df9ee292SDavid Howells 52df9ee292SDavid Howells #endif /* __PARISC_IRQFLAGS_H */ 53