blob: ea36674c6ec5d9828e757112e9caa13b785bf72e [file] [log] [blame]
David Howellsdf9ee292010-10-07 14:08:55 +01001/*
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
16static inline unsigned long arch_local_save_flags(void)
17{
18 unsigned long flags;
Max Filippovbc5378f2012-10-15 03:55:38 +040019 asm volatile("rsr %0, ps" : "=a" (flags));
David Howellsdf9ee292010-10-07 14:08:55 +010020 return flags;
21}
22
23static 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
31static inline void arch_local_irq_disable(void)
32{
33 arch_local_irq_save();
34}
35
36static inline void arch_local_irq_enable(void)
37{
38 unsigned long flags;
39 asm volatile("rsil %0, 0" : "=a" (flags) :: "memory");
40}
41
42static inline void arch_local_irq_restore(unsigned long flags)
43{
Max Filippovbc5378f2012-10-15 03:55:38 +040044 asm volatile("wsr %0, ps; rsync"
David Howellsdf9ee292010-10-07 14:08:55 +010045 :: "a" (flags) : "memory");
46}
47
48static inline bool arch_irqs_disabled_flags(unsigned long flags)
49{
Max Filippov031d0112013-03-31 06:34:10 +040050#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;
David Howellsdf9ee292010-10-07 14:08:55 +010054}
55
56static inline bool arch_irqs_disabled(void)
57{
58 return arch_irqs_disabled_flags(arch_local_save_flags());
59}
60
61#endif /* _XTENSA_IRQFLAGS_H */