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)
20 #include <asm/arcregs.h>
24 /******************************************************************
26 ******************************************************************/
29 * Save IRQ state and disable IRQs
31 static inline long arch_local_irq_save(void)
33 unsigned long temp, flags;
36 " lr %1, [status32] \n"
40 : "=r"(temp), "=r"(flags)
41 : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
48 * restore saved IRQ state
50 static inline void arch_local_irq_restore(unsigned long flags)
60 * Unconditionally Enable IRQs
62 extern void arch_local_irq_enable(void);
65 * Unconditionally Disable IRQs
67 static inline void arch_local_irq_disable(void)
72 " lr %0, [status32] \n"
76 : "n"(~(STATUS_E1_MASK | STATUS_E2_MASK)));
82 static inline long arch_local_save_flags(void)
87 " lr %0, [status32] \n"
96 static inline int arch_irqs_disabled_flags(unsigned long flags)
98 return !(flags & (STATUS_E1_MASK
99 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
105 static inline int arch_irqs_disabled(void)
107 return arch_irqs_disabled_flags(arch_local_save_flags());
110 static inline void arch_mask_irq(unsigned int irq)
114 ienb = read_aux_reg(AUX_IENABLE);
116 write_aux_reg(AUX_IENABLE, ienb);
119 static inline void arch_unmask_irq(unsigned int irq)
123 ienb = read_aux_reg(AUX_IENABLE);
125 write_aux_reg(AUX_IENABLE, ienb);
130 .macro IRQ_DISABLE scratch
131 lr \scratch, [status32]
132 bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
136 .macro IRQ_DISABLE_SAVE scratch, save
137 lr \scratch, [status32]
138 mov \save, \scratch /* Make a copy */
139 bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
143 .macro IRQ_ENABLE scratch
144 lr \scratch, [status32]
145 or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
149 #endif /* __ASSEMBLY__ */