1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_ARM_IRQFLAGS_H
3 #define __ASM_ARM_IRQFLAGS_H
7 #include <asm/ptrace.h>
10 * CPU interrupt mask handling.
13 #define IRQMASK_REG_NAME_R "primask"
14 #define IRQMASK_REG_NAME_W "primask"
15 #define IRQMASK_I_BIT 1
17 #define IRQMASK_REG_NAME_R "cpsr"
18 #define IRQMASK_REG_NAME_W "cpsr_c"
19 #define IRQMASK_I_BIT PSR_I_BIT
22 #if __LINUX_ARM_ARCH__ >= 6
24 #define arch_local_irq_save arch_local_irq_save
25 static inline unsigned long arch_local_irq_save(void)
30 " mrs %0, " IRQMASK_REG_NAME_R " @ arch_local_irq_save\n"
32 : "=r" (flags) : : "memory", "cc");
36 #define arch_local_irq_enable arch_local_irq_enable
37 static inline void arch_local_irq_enable(void)
40 " cpsie i @ arch_local_irq_enable"
46 #define arch_local_irq_disable arch_local_irq_disable
47 static inline void arch_local_irq_disable(void)
50 " cpsid i @ arch_local_irq_disable"
56 #define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc")
57 #define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc")
59 #ifndef CONFIG_CPU_V7M
60 #define local_abt_enable() __asm__("cpsie a @ __sta" : : : "memory", "cc")
61 #define local_abt_disable() __asm__("cpsid a @ __cla" : : : "memory", "cc")
63 #define local_abt_enable() do { } while (0)
64 #define local_abt_disable() do { } while (0)
69 * Save the current interrupt enable state & disable IRQs
71 #define arch_local_irq_save arch_local_irq_save
72 static inline unsigned long arch_local_irq_save(void)
74 unsigned long flags, temp;
77 " mrs %0, cpsr @ arch_local_irq_save\n"
80 : "=r" (flags), "=r" (temp)
89 #define arch_local_irq_enable arch_local_irq_enable
90 static inline void arch_local_irq_enable(void)
94 " mrs %0, cpsr @ arch_local_irq_enable\n"
105 #define arch_local_irq_disable arch_local_irq_disable
106 static inline void arch_local_irq_disable(void)
110 " mrs %0, cpsr @ arch_local_irq_disable\n"
111 " orr %0, %0, #128\n"
121 #define local_fiq_enable() \
123 unsigned long temp; \
124 __asm__ __volatile__( \
125 "mrs %0, cpsr @ stf\n" \
126 " bic %0, %0, #64\n" \
136 #define local_fiq_disable() \
138 unsigned long temp; \
139 __asm__ __volatile__( \
140 "mrs %0, cpsr @ clf\n" \
141 " orr %0, %0, #64\n" \
148 #define local_abt_enable() do { } while (0)
149 #define local_abt_disable() do { } while (0)
153 * Save the current interrupt enable state.
155 #define arch_local_save_flags arch_local_save_flags
156 static inline unsigned long arch_local_save_flags(void)
160 " mrs %0, " IRQMASK_REG_NAME_R " @ local_save_flags"
161 : "=r" (flags) : : "memory", "cc");
166 * restore saved IRQ & FIQ state
168 #define arch_local_irq_restore arch_local_irq_restore
169 static inline void arch_local_irq_restore(unsigned long flags)
172 " msr " IRQMASK_REG_NAME_W ", %0 @ local_irq_restore"
178 #define arch_irqs_disabled_flags arch_irqs_disabled_flags
179 static inline int arch_irqs_disabled_flags(unsigned long flags)
181 return flags & IRQMASK_I_BIT;
184 #include <asm-generic/irqflags.h>
186 #endif /* ifdef __KERNEL__ */
187 #endif /* ifndef __ASM_ARM_IRQFLAGS_H */