aboutsummaryrefslogtreecommitdiffstats
path: root/arch/nios2/include/asm/irqflags.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/nios2/include/asm/irqflags.h')
-rw-r--r--arch/nios2/include/asm/irqflags.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/nios2/include/asm/irqflags.h b/arch/nios2/include/asm/irqflags.h
new file mode 100644
index 000000000000..75ab92e639f8
--- /dev/null
+++ b/arch/nios2/include/asm/irqflags.h
@@ -0,0 +1,72 @@
1/*
2 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18#ifndef _ASM_IRQFLAGS_H
19#define _ASM_IRQFLAGS_H
20
21#include <asm/registers.h>
22
23static inline unsigned long arch_local_save_flags(void)
24{
25 return RDCTL(CTL_STATUS);
26}
27
28/*
29 * This will restore ALL status register flags, not only the interrupt
30 * mask flag.
31 */
32static inline void arch_local_irq_restore(unsigned long flags)
33{
34 WRCTL(CTL_STATUS, flags);
35}
36
37static inline void arch_local_irq_disable(void)
38{
39 unsigned long flags;
40
41 flags = arch_local_save_flags();
42 arch_local_irq_restore(flags & ~STATUS_PIE);
43}
44
45static inline void arch_local_irq_enable(void)
46{
47 unsigned long flags;
48
49 flags = arch_local_save_flags();
50 arch_local_irq_restore(flags | STATUS_PIE);
51}
52
53static inline int arch_irqs_disabled_flags(unsigned long flags)
54{
55 return (flags & STATUS_PIE) == 0;
56}
57
58static inline int arch_irqs_disabled(void)
59{
60 return arch_irqs_disabled_flags(arch_local_save_flags());
61}
62
63static inline unsigned long arch_local_irq_save(void)
64{
65 unsigned long flags;
66
67 flags = arch_local_save_flags();
68 arch_local_irq_restore(flags & ~STATUS_PIE);
69 return flags;
70}
71
72#endif /* _ASM_IRQFLAGS_H */