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
)
61 * Unconditionally Enable IRQs
63 extern void arch_local_irq_enable(void);
66 * Unconditionally Disable IRQs
68 static inline void arch_local_irq_disable(void)
73 " lr %0, [status32] \n"
77 : "n"(~(STATUS_E1_MASK
| STATUS_E2_MASK
))
84 static inline long arch_local_save_flags(void)
89 " lr %0, [status32] \n"
100 static inline int arch_irqs_disabled_flags(unsigned long flags
)
102 return !(flags
& (STATUS_E1_MASK
103 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
109 static inline int arch_irqs_disabled(void)
111 return arch_irqs_disabled_flags(arch_local_save_flags());
114 static inline void arch_mask_irq(unsigned int irq
)
118 ienb
= read_aux_reg(AUX_IENABLE
);
120 write_aux_reg(AUX_IENABLE
, ienb
);
123 static inline void arch_unmask_irq(unsigned int irq
)
127 ienb
= read_aux_reg(AUX_IENABLE
);
129 write_aux_reg(AUX_IENABLE
, ienb
);
134 .macro IRQ_DISABLE scratch
135 lr \scratch
, [status32
]
136 bic \scratch
, \scratch
, (STATUS_E1_MASK
| STATUS_E2_MASK
)
140 .macro IRQ_DISABLE_SAVE scratch
, save
141 lr \scratch
, [status32
]
142 mov \save
, \scratch
/* Make a copy */
143 bic \scratch
, \scratch
, (STATUS_E1_MASK
| STATUS_E2_MASK
)
147 .macro IRQ_ENABLE scratch
148 lr \scratch
, [status32
]
149 or \scratch
, \scratch
, (STATUS_E1_MASK
| STATUS_E2_MASK
)
153 #endif /* __ASSEMBLY__ */