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 * Aarch64 has flags for masking: Debug, Asynchronous (serror), Interrupts and
25 * FIQ exceptions, in the 'daif' register. We mask and unmask them in 'dai'
27 * Masking debug exceptions causes all other exceptions to be masked too/
28 * Masking SError masks irq, but not debug exceptions. Masking irqs has no
29 * side effects for other flags. Keeping to this order makes it easier for
30 * entry.S to know which exceptions should be unmasked.
32 * FIQ is never expected, but we mask it when we disable debug exceptions, and
33 * unmask it at all other times.
37 * CPU interrupt mask handling.
39 static inline unsigned long arch_local_irq_save(void)
43 "mrs %0, daif // arch_local_irq_save\n"
51 static inline void arch_local_irq_enable(void)
54 "msr daifclr, #2 // arch_local_irq_enable"
60 static inline void arch_local_irq_disable(void)
63 "msr daifset, #2 // arch_local_irq_disable"
70 * Save the current interrupt enable state.
72 static inline unsigned long arch_local_save_flags(void)
76 "mrs %0, daif // arch_local_save_flags"
84 * restore saved IRQ state
86 static inline void arch_local_irq_restore(unsigned long flags)
89 "msr daif, %0 // arch_local_irq_restore"
95 static inline int arch_irqs_disabled_flags(unsigned long flags)
97 return flags & PSR_I_BIT;