2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
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.
9 #ifndef __ASM_ARC_IRQFLAGS_H
10 #define __ASM_ARC_IRQFLAGS_H
12 /* vineetg: March 2010 : local_irq_save( ) optimisation
13 * -Remove explicit mov of current status32 into reg, that is not needed
14 * -Use BIC insn instead of INVERTED + AND
15 * -Conditionally disable interrupts (if they are not enabled, don't disable)
18 #include <asm/arcregs.h>
20 /* status32 Reg bits related to Interrupt Handling */
21 #define STATUS_E1_BIT 1 /* Int 1 enable */
22 #define STATUS_E2_BIT 2 /* Int 2 enable */
23 #define STATUS_A1_BIT 3 /* Int 1 active */
24 #define STATUS_A2_BIT 4 /* Int 2 active */
26 #define STATUS_E1_MASK (1<<STATUS_E1_BIT)
27 #define STATUS_E2_MASK (1<<STATUS_E2_BIT)
28 #define STATUS_A1_MASK (1<<STATUS_A1_BIT)
29 #define STATUS_A2_MASK (1<<STATUS_A2_BIT)
31 /* Other Interrupt Handling related Aux regs */
32 #define AUX_IRQ_LEV 0x200 /* IRQ Priority: L1 or L2 */
33 #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
34 #define AUX_IRQ_LV12 0x43 /* interrupt level register */
36 #define AUX_IENABLE 0x40c
37 #define AUX_ITRIGGER 0x40d
38 #define AUX_IPULSE 0x415
42 /******************************************************************
44 ******************************************************************/
47 * Save IRQ state and disable IRQs
49 static inline long arch_local_irq_save(void)
51 unsigned long temp, flags;
54 " lr %1, [status32] \n"
58 : "=r"(temp), "=r"(flags)
59 : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
66 * restore saved IRQ state
68 static inline void arch_local_irq_restore(unsigned long flags)
79 * Unconditionally Enable IRQs
81 extern void arch_local_irq_enable(void);
84 * Unconditionally Disable IRQs
86 static inline void arch_local_irq_disable(void)
91 " lr %0, [status32] \n"
95 : "n"(~(STATUS_E1_MASK | STATUS_E2_MASK))
102 static inline long arch_local_save_flags(void)
106 __asm__ __volatile__(
107 " lr %0, [status32] \n"
118 static inline int arch_irqs_disabled_flags(unsigned long flags)
120 return !(flags & (STATUS_E1_MASK
121 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
127 static inline int arch_irqs_disabled(void)
129 return arch_irqs_disabled_flags(arch_local_save_flags());
134 #ifdef CONFIG_TRACE_IRQFLAGS
136 .macro TRACE_ASM_IRQ_DISABLE
137 bl trace_hardirqs_off
140 .macro TRACE_ASM_IRQ_ENABLE
146 .macro TRACE_ASM_IRQ_DISABLE
149 .macro TRACE_ASM_IRQ_ENABLE
154 .macro IRQ_DISABLE scratch
155 lr \scratch, [status32]
156 bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
158 TRACE_ASM_IRQ_DISABLE
161 .macro IRQ_ENABLE scratch
162 lr \scratch, [status32]
163 or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
168 #endif /* __ASSEMBLY__ */