ReactOS 0.4.15-dev-7928-g68a8619
pic.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS HAL
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: hal/halarm/generic/pic.c
5 * PURPOSE: HAL PIC Management and Control Code
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <hal.h>
12#define NDEBUG
13#include <debug.h>
14
15#undef KeGetCurrentIrql
16
17/* GLOBALS ********************************************************************/
18
20{
21 0xFFFFFFFF, // IRQL 0 PASSIVE_LEVEL
22 0xFFFFFFFD, // IRQL 1 APC_LEVEL
23 0xFFFFFFF9, // IRQL 2 DISPATCH_LEVEL
24 0xFFFFFFD9, // IRQL 3
25 0xFFFFFF99, // IRQL 4
26 0xFFFFFF19, // IRQL 5
27 0xFFFFFE19, // IRQL 6
28 0xFFFFFC19, // IRQL 7
29 0xFFFFF819, // IRQL 8
30 0xFFFFF019, // IRQL 9
31 0xFFFFE019, // IRQL 10
32 0xFFFFC019, // IRQL 11
33 0xFFFF8019, // IRQL 12
34 0xFFFF0019, // IRQL 13
35 0xFFFE0019, // IRQL 14
36 0xFFFC0019, // IRQL 15
37 0xFFF80019, // IRQL 16
38 0xFFF00019, // IRQL 17
39 0xFFE00019, // IRQL 18
40 0xFFC00019, // IRQL 19
41 0xFF800019, // IRQL 20
42 0xFF000019, // IRQL 21
43 0xFE000019, // IRQL 22
44 0xFC000019, // IRQL 23
45 0xF0000019, // IRQL 24
46 0x80000019, // IRQL 25
47 0x19, // IRQL 26
48 0x18, // IRQL 27 PROFILE_LEVEL
49 0x10, // IRQL 28 CLOCK2_LEVEL
50 0x00, // IRQL 29 IPI_LEVEL
51 0x00, // IRQL 30 POWER_LEVEL
52 0x00, // IRQL 31 HIGH_LEVEL
53};
54
56{
57 PROFILE_LEVEL, // INT 0 WATCHDOG
58 APC_LEVEL, // INT 1 SOFTWARE INTERRUPT
59 DISPATCH_LEVEL,// INT 2 COMM RX
60 IPI_LEVEL, // INT 3 COMM TX
61 CLOCK2_LEVEL, // INT 4 TIMER 0
62 3,
63 4,
64 5,
65 6,
66 7,
67 8,
68 9,
69 10,
70 11,
71 12,
72 13,
73 14,
74 15,
75 16,
76 17,
77 18,
78 19,
79 20,
80 21,
81 22,
82 23,
83 24,
84 25,
85 26,
86 26,
87 26
88};
89
90/* FUNCTIONS ******************************************************************/
91
92VOID
94{
95 PKPCR Pcr = KeGetPcr();
96
97 /* Fill out the IRQL mappings */
98 RtlCopyMemory(Pcr->IrqlTable, HalpIrqlTable, sizeof(Pcr->IrqlTable));
99 RtlCopyMemory(Pcr->IrqlMask, HalpMaskTable, sizeof(Pcr->IrqlMask));
100}
101
102/* IRQL MANAGEMENT ************************************************************/
103
104/*
105 * @implemented
106 */
107ULONG
109{
110 ULONG InterruptStatus;
111
112 /* Get the interrupt status, and return the highest bit set */
113 InterruptStatus = READ_REGISTER_ULONG(VIC_INT_STATUS);
114 return 31 - _clz(InterruptStatus);
115}
116
117/*
118 * @implemented
119 */
120KIRQL
121NTAPI
123{
124 /* Return the IRQL */
125 return KeGetPcr()->Irql;
126}
127
128/*
129 * @implemented
130 */
131KIRQL
132NTAPI
134{
135 PKPCR Pcr = KeGetPcr();
136 KIRQL CurrentIrql;
137
138 /* Save and update IRQL */
139 CurrentIrql = Pcr->Irql;
140 Pcr->Irql = DISPATCH_LEVEL;
141
142#ifdef IRQL_DEBUG
143 /* Validate correct raise */
144 if (CurrentIrql > DISPATCH_LEVEL) KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL);
145#endif
146
147 /* Return the previous value */
148 return CurrentIrql;
149}
150
151/*
152 * @implemented
153 */
154KIRQL
155NTAPI
157{
158 PKPCR Pcr = KeGetPcr();
159 KIRQL CurrentIrql;
160
161 /* Save and update IRQL */
162 CurrentIrql = Pcr->Irql;
163 Pcr->Irql = SYNCH_LEVEL;
164
165#ifdef IRQL_DEBUG
166 /* Validate correct raise */
167 if (CurrentIrql > SYNCH_LEVEL)
168 {
169 /* Crash system */
170 KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
171 CurrentIrql,
173 0,
174 1);
175 }
176#endif
177
178 /* Return the previous value */
179 return CurrentIrql;
180}
181
182/*
183 * @implemented
184 */
185KIRQL
188{
190 PKPCR Pcr = KeGetPcr();
191 KIRQL CurrentIrql;
192 ULONG InterruptMask;
193
194 /* Disable interrupts */
196 _disable();
197
198 /* Read current IRQL */
199 CurrentIrql = Pcr->Irql;
200
201#ifdef IRQL_DEBUG
202 /* Validate correct raise */
203 if (CurrentIrql > NewIrql)
204 {
205 /* Crash system */
206 Pcr->Irql = PASSIVE_LEVEL;
207 KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL);
208 }
209#endif
210 /* Clear interrupts associated to the old IRQL */
212
213 /* Set the new interrupt mask */
214 InterruptMask = Pcr->IrqlTable[NewIrql];
215 WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
216
217 /* Set new IRQL */
218 Pcr->Irql = NewIrql;
219
220 /* Restore interrupt state */
221 if (!Flags.IrqDisable) _enable();
222
223 /* Return old IRQL */
224 return CurrentIrql;
225}
226
227/*
228 * @implemented
229 */
230VOID
233{
235 PKPCR Pcr = KeGetPcr();
236 ULONG InterruptMask;
237
238 /* Disableinterrupts */
240 _disable();
241
242#ifdef IRQL_DEBUG
243 /* Validate correct lower */
244 if (OldIrql > Pcr->Irql)
245 {
246 /* Crash system */
247 Pcr->Irql = HIGH_LEVEL;
248 KeBugCheck(IRQL_NOT_LESS_OR_EQUAL);
249 }
250#endif
251
252 /* Clear interrupts associated to the old IRQL */
254
255 /* Set the new interrupt mask */
256 InterruptMask = Pcr->IrqlTable[NewIrql];
257 WRITE_REGISTER_ULONG(VIC_INT_ENABLE, InterruptMask);
258
259 /* Save the new IRQL and restore interrupt state */
260 Pcr->Irql = NewIrql;
261 if (!Flags.IrqDisable) _enable();
262}
263
264/* SOFTWARE INTERRUPTS ********************************************************/
265
266/*
267 * @implemented
268 */
269VOID
272{
273 /* Force a software interrupt */
275}
276
277/*
278 * @implemented
279 */
280VOID
283{
284 /* Clear software interrupt */
286}
287
288/* SYSTEM INTERRUPTS **********************************************************/
289
290/*
291 * @implemented
292 */
294NTAPI
296 IN KIRQL Irql,
298{
300 while (TRUE);
301 return FALSE;
302}
303
304/*
305 * @implemented
306 */
307VOID
308NTAPI
310 IN KIRQL Irql)
311{
313 while (TRUE);
314}
315
316/*
317 * @implemented
318 */
320NTAPI
324{
326 while (TRUE);
327 return FALSE;
328}
329
330/*
331 * @implemented
332 */
333VOID
334NTAPI
336 IN PKTRAP_FRAME TrapFrame)
337{
339 while (TRUE);
340}
341
342/* EOF */
unsigned char BOOLEAN
FORCEINLINE ARM_STATUS_REGISTER KeArmStatusRegisterGet(VOID)
Definition: intrin_i.h:122
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:27
#define READ_REGISTER_ULONG(r)
Definition: arm.h:26
#define UNIMPLEMENTED
Definition: debug.h:115
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1431
_Out_ PKIRQL Irql
Definition: csq.h:179
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CLOCK2_LEVEL
Definition: env_spec_w32.h:700
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define IPI_LEVEL
Definition: env_spec_w32.h:701
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PROFILE_LEVEL
Definition: env_spec_w32.h:698
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment KeRaiseIrqlToDpcLevel
Definition: CrNtStubs.h:68
VOID NTAPI HalEndSystemInterrupt(IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame)
Definition: pic.c:335
ULONG HalpIrqlTable[HIGH_LEVEL+1]
Definition: pic.c:19
VOID HalpInitializeInterrupts(VOID)
Definition: pic.c:93
UCHAR HalpMaskTable[HIGH_LEVEL+1]
Definition: pic.c:55
BOOLEAN NTAPI HalBeginSystemInterrupt(IN KIRQL Irql, IN ULONG Vector, OUT PKIRQL OldIrql)
Definition: pic.c:321
BOOLEAN NTAPI HalEnableSystemInterrupt(IN ULONG Vector, IN KIRQL Irql, IN KINTERRUPT_MODE InterruptMode)
Definition: pic.c:295
VOID NTAPI HalDisableSystemInterrupt(IN ULONG Vector, IN KIRQL Irql)
Definition: pic.c:309
VOID FASTCALL HalRequestSoftwareInterrupt(IN KIRQL Irql)
Definition: pic.c:271
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
ULONG HalGetInterruptSource(VOID)
Definition: pic.c:108
VOID FASTCALL HalClearSoftwareInterrupt(IN KIRQL Irql)
Definition: pic.c:282
KIRQL NTAPI KeRaiseIrqlToSynchLevel(VOID)
Definition: pic.c:156
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
#define _clz(a)
Definition: intrin_arm.h:398
#define KeGetPcr()
Definition: ketypes.h:81
#define FASTCALL
Definition: nt_native.h:50
#define VIC_INT_STATUS
Definition: pl190.h:16
#define VIC_SOFT_INT
Definition: pl190.h:19
#define VIC_INT_ENABLE
Definition: pl190.h:17
#define VIC_INT_CLEAR
Definition: pl190.h:18
#define VIC_SOFT_INT_CLEAR
Definition: pl190.h:20
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
enum _KINTERRUPT_MODE KINTERRUPT_MODE
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
Definition: ke.h:294
KIRQL Irql
Definition: ke.h:311
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE InterruptMode
Definition: iofuncs.h:806
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
unsigned char UCHAR
Definition: xmlstorage.h:181