1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
5 #ifndef _ASM_IRQFLAGS_H
6 #define _ASM_IRQFLAGS_H
8 #include <asm/registers.h>
10 static inline unsigned long arch_local_save_flags(void)
12 return RDCTL(CTL_FSTATUS);
16 * This will restore ALL status register flags, not only the interrupt
19 static inline void arch_local_irq_restore(unsigned long flags)
21 WRCTL(CTL_FSTATUS, flags);
24 static inline void arch_local_irq_disable(void)
28 flags = arch_local_save_flags();
29 arch_local_irq_restore(flags & ~STATUS_PIE);
32 static inline void arch_local_irq_enable(void)
36 flags = arch_local_save_flags();
37 arch_local_irq_restore(flags | STATUS_PIE);
40 static inline int arch_irqs_disabled_flags(unsigned long flags)
42 return (flags & STATUS_PIE) == 0;
45 static inline int arch_irqs_disabled(void)
47 return arch_irqs_disabled_flags(arch_local_save_flags());
50 static inline unsigned long arch_local_irq_save(void)
54 flags = arch_local_save_flags();
55 arch_local_irq_restore(flags & ~STATUS_PIE);
59 #endif /* _ASM_IRQFLAGS_H */