Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / xtensa / include / asm / irqflags.h
blobea36674c6ec5d9828e757112e9caa13b785bf72e
1 /*
2 * Xtensa IRQ flags handling functions
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.
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
11 #ifndef _XTENSA_IRQFLAGS_H
12 #define _XTENSA_IRQFLAGS_H
14 #include <linux/types.h>
16 static inline unsigned long arch_local_save_flags(void)
18 unsigned long flags;
19 asm volatile("rsr %0, ps" : "=a" (flags));
20 return flags;
23 static inline unsigned long arch_local_irq_save(void)
25 unsigned long flags;
26 asm volatile("rsil %0, "__stringify(LOCKLEVEL)
27 : "=a" (flags) :: "memory");
28 return flags;
31 static inline void arch_local_irq_disable(void)
33 arch_local_irq_save();
36 static inline void arch_local_irq_enable(void)
38 unsigned long flags;
39 asm volatile("rsil %0, 0" : "=a" (flags) :: "memory");
42 static inline void arch_local_irq_restore(unsigned long flags)
44 asm volatile("wsr %0, ps; rsync"
45 :: "a" (flags) : "memory");
48 static inline bool arch_irqs_disabled_flags(unsigned long flags)
50 #if XCHAL_EXCM_LEVEL < LOCKLEVEL || (1 << PS_EXCM_BIT) < LOCKLEVEL
51 #error "XCHAL_EXCM_LEVEL and 1<<PS_EXCM_BIT must be no less than LOCKLEVEL"
52 #endif
53 return (flags & (PS_INTLEVEL_MASK | (1 << PS_EXCM_BIT))) >= LOCKLEVEL;
56 static inline bool arch_irqs_disabled(void)
58 return arch_irqs_disabled_flags(arch_local_save_flags());
61 #endif /* _XTENSA_IRQFLAGS_H */