2 * Copyright (C) 2012 ARM Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #ifndef __ASM_IRQFLAGS_H
17 #define __ASM_IRQFLAGS_H
21 #include <asm/ptrace.h>
24 * CPU interrupt mask handling.
26 static inline unsigned long arch_local_irq_save(void)
30 "mrs %0, daif // arch_local_irq_save\n"
38 static inline void arch_local_irq_enable(void)
41 "msr daifclr, #2 // arch_local_irq_enable"
47 static inline void arch_local_irq_disable(void)
50 "msr daifset, #2 // arch_local_irq_disable"
56 #define local_fiq_enable() asm("msr daifclr, #1" : : : "memory")
57 #define local_fiq_disable() asm("msr daifset, #1" : : : "memory")
59 #define local_async_enable() asm("msr daifclr, #4" : : : "memory")
60 #define local_async_disable() asm("msr daifset, #4" : : : "memory")
63 * Save the current interrupt enable state.
65 static inline unsigned long arch_local_save_flags(void)
69 "mrs %0, daif // arch_local_save_flags"
77 * restore saved IRQ state
79 static inline void arch_local_irq_restore(unsigned long flags
)
82 "msr daif, %0 // arch_local_irq_restore"
88 static inline int arch_irqs_disabled_flags(unsigned long flags
)
90 return flags
& PSR_I_BIT
;
94 * save and restore debug state
96 #define local_dbg_save(flags) \
98 typecheck(unsigned long, flags); \
100 "mrs %0, daif // local_dbg_save\n" \
102 : "=r" (flags) : : "memory"); \
105 #define local_dbg_restore(flags) \
107 typecheck(unsigned long, flags); \
109 "msr daif, %0 // local_dbg_restore\n" \
110 : : "r" (flags) : "memory"); \
113 #define local_dbg_enable() asm("msr daifclr, #8" : : : "memory")
114 #define local_dbg_disable() asm("msr daifset, #8" : : : "memory")