1
2
3
4
5
6
7#ifndef __ASM_IRQFLAGS_ARCOMPACT_H
8#define __ASM_IRQFLAGS_ARCOMPACT_H
9
10
11
12
13
14
15
16#include <asm/arcregs.h>
17
18
19#define STATUS_E1_BIT 1
20#define STATUS_E2_BIT 2
21#define STATUS_A1_BIT 3
22#define STATUS_A2_BIT 4
23#define STATUS_AE_BIT 5
24
25#define STATUS_E1_MASK (1<<STATUS_E1_BIT)
26#define STATUS_E2_MASK (1<<STATUS_E2_BIT)
27#define STATUS_A1_MASK (1<<STATUS_A1_BIT)
28#define STATUS_A2_MASK (1<<STATUS_A2_BIT)
29#define STATUS_AE_MASK (1<<STATUS_AE_BIT)
30#define STATUS_IE_MASK (STATUS_E1_MASK | STATUS_E2_MASK)
31
32
33#define AUX_IRQ_LEV 0x200
34#define AUX_IRQ_HINT 0x201
35#define AUX_IRQ_LV12 0x43
36
37#define AUX_IENABLE 0x40c
38#define AUX_ITRIGGER 0x40d
39#define AUX_IPULSE 0x415
40
41#define ISA_INIT_STATUS_BITS STATUS_IE_MASK
42
43#ifndef __ASSEMBLY__
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61static inline long arch_local_irq_save(void)
62{
63 unsigned long temp, flags;
64
65 __asm__ __volatile__(
66 " lr %1, [status32] \n"
67 " bic %0, %1, %2 \n"
68 " and.f 0, %1, %2 \n"
69 " flag.nz %0 \n"
70 : "=r"(temp), "=r"(flags)
71 : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
72 : "memory", "cc");
73
74 return flags;
75}
76
77
78
79
80static inline void arch_local_irq_restore(unsigned long flags)
81{
82
83 __asm__ __volatile__(
84 " flag %0 \n"
85 :
86 : "r"(flags)
87 : "memory");
88}
89
90
91
92
93static inline void arch_local_irq_enable(void)
94{
95 unsigned long temp;
96
97 __asm__ __volatile__(
98 " lr %0, [status32] \n"
99 " or %0, %0, %1 \n"
100 " flag %0 \n"
101 : "=&r"(temp)
102 : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
103 : "cc", "memory");
104}
105
106
107
108
109
110static inline void arch_local_irq_disable(void)
111{
112 unsigned long temp;
113
114 __asm__ __volatile__(
115 " lr %0, [status32] \n"
116 " and %0, %0, %1 \n"
117 " flag %0 \n"
118 : "=&r"(temp)
119 : "n"(~(STATUS_E1_MASK | STATUS_E2_MASK))
120 : "memory");
121}
122
123
124
125
126static inline long arch_local_save_flags(void)
127{
128 unsigned long temp;
129
130 __asm__ __volatile__(
131 " lr %0, [status32] \n"
132 : "=&r"(temp)
133 :
134 : "memory");
135
136 return temp;
137}
138
139
140
141
142static inline int arch_irqs_disabled_flags(unsigned long flags)
143{
144 return !(flags & (STATUS_E1_MASK
145#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
146 | STATUS_E2_MASK
147#endif
148 ));
149}
150
151static inline int arch_irqs_disabled(void)
152{
153 return arch_irqs_disabled_flags(arch_local_save_flags());
154}
155
156#else
157
158#ifdef CONFIG_TRACE_IRQFLAGS
159
160.macro TRACE_ASM_IRQ_DISABLE
161 bl trace_hardirqs_off
162.endm
163
164.macro TRACE_ASM_IRQ_ENABLE
165 bl trace_hardirqs_on
166.endm
167
168#else
169
170.macro TRACE_ASM_IRQ_DISABLE
171.endm
172
173.macro TRACE_ASM_IRQ_ENABLE
174.endm
175
176#endif
177
178.macro IRQ_DISABLE scratch
179 lr \scratch, [status32]
180 bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
181 flag \scratch
182 TRACE_ASM_IRQ_DISABLE
183.endm
184
185.macro IRQ_ENABLE scratch
186 TRACE_ASM_IRQ_ENABLE
187 lr \scratch, [status32]
188 or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
189 flag \scratch
190.endm
191
192#endif
193
194#endif
195