xref: /openbmc/linux/arch/xtensa/include/asm/irqflags.h (revision 95188aaf)
1 /*
2  * Xtensa IRQ flags handling functions
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 2001 - 2005 Tensilica Inc.
9  */
10 
11 #ifndef _XTENSA_IRQFLAGS_H
12 #define _XTENSA_IRQFLAGS_H
13 
14 #include <linux/types.h>
15 
16 static inline unsigned long arch_local_save_flags(void)
17 {
18 	unsigned long flags;
19 	asm volatile("rsr %0, ps" : "=a" (flags));
20 	return flags;
21 }
22 
23 static inline unsigned long arch_local_irq_save(void)
24 {
25 	unsigned long flags;
26 	asm volatile("rsil %0, "__stringify(LOCKLEVEL)
27 		     : "=a" (flags) :: "memory");
28 	return flags;
29 }
30 
31 static inline void arch_local_irq_disable(void)
32 {
33 	arch_local_irq_save();
34 }
35 
36 static inline void arch_local_irq_enable(void)
37 {
38 	unsigned long flags;
39 	asm volatile("rsil %0, 0" : "=a" (flags) :: "memory");
40 }
41 
42 static inline void arch_local_irq_restore(unsigned long flags)
43 {
44 	asm volatile("wsr %0, ps; rsync"
45 		     :: "a" (flags) : "memory");
46 }
47 
48 static inline bool arch_irqs_disabled_flags(unsigned long flags)
49 {
50 	return (flags & 0xf) != 0;
51 }
52 
53 static inline bool arch_irqs_disabled(void)
54 {
55 	return arch_irqs_disabled_flags(arch_local_save_flags());
56 }
57 
58 #endif /* _XTENSA_IRQFLAGS_H */
59