ReactOS 0.4.15-dev-8100-g1887773
mpsirql.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for mpsirql.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

KIRQL NTAPI KeGetCurrentIrql (VOID)
 
VOID KeSetCurrentIrql (KIRQL NewIrql)
 
VOID HalpLowerIrql (KIRQL NewIrql, BOOLEAN FromHalEndSystemInterrupt)
 
VOID FASTCALL KfLowerIrql (KIRQL NewIrql)
 
KIRQL FASTCALL KfRaiseIrql (KIRQL NewIrql)
 
KIRQL NTAPI KeRaiseIrqlToDpcLevel (VOID)
 
KIRQL NTAPI KeRaiseIrqlToSynchLevel (VOID)
 
BOOLEAN NTAPI HalBeginSystemInterrupt (KIRQL Irql, ULONG Vector, PKIRQL OldIrql)
 
VOID NTAPI HalEndSystemInterrupt (KIRQL Irql, IN PKTRAP_FRAME TrapFrame)
 
VOID NTAPI HalDisableSystemInterrupt (ULONG Vector, KIRQL Irql)
 
BOOLEAN NTAPI HalEnableSystemInterrupt (ULONG Vector, KIRQL Irql, KINTERRUPT_MODE InterruptMode)
 
VOID FASTCALL HalRequestSoftwareInterrupt (IN KIRQL Request)
 
VOID FASTCALL HalClearSoftwareInterrupt (IN KIRQL Request)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file mpsirql.c.

Function Documentation

◆ HalBeginSystemInterrupt()

BOOLEAN NTAPI HalBeginSystemInterrupt ( KIRQL  Irql,
ULONG  Vector,
PKIRQL  OldIrql 
)

Definition at line 244 of file mpsirql.c.

247{
248 ULONG Flags;
249 DPRINT("Vector (0x%X) Irql (0x%X)\n", Vector, Irql);
250
251 if (KeGetCurrentIrql () >= Irql)
252 {
253 DPRINT1("current irql %d, new irql %d\n", KeGetCurrentIrql(), Irql);
254 ASSERT(FALSE);
255 }
256
259 {
260 DPRINT1("HalBeginSystemInterrupt was called with interrupt's enabled\n");
261 ASSERT(FALSE);
262 }
263 APICWrite (APIC_TPR, IRQL2TPR (Irql) & APIC_TPR_PRI);
266 return(TRUE);
267}
#define EFLAGS_INTERRUPT_MASK
Definition: SystemCall.c:11
@ APIC_TPR
Definition: apicp.h:82
#define DPRINT1
Definition: precomp.h:8
_Out_ PKIRQL Irql
Definition: csq.h:179
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1674
#define ASSERT(a)
Definition: mode.c:44
#define IRQL2TPR(irql)
Definition: mps.h:9
VOID KeSetCurrentIrql(KIRQL NewIrql)
Definition: mpsirql.c:51
#define DPRINT
Definition: sndvol32.h:73
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

◆ HalClearSoftwareInterrupt()

VOID FASTCALL HalClearSoftwareInterrupt ( IN KIRQL  Request)

Definition at line 354 of file mpsirql.c.

356{
358}
#define UNIMPLEMENTED
Definition: debug.h:118

◆ HalDisableSystemInterrupt()

VOID NTAPI HalDisableSystemInterrupt ( ULONG  Vector,
KIRQL  Irql 
)

Definition at line 291 of file mpsirql.c.

293{
294 ULONG irq;
295
296 DPRINT ("Vector (0x%X)\n", Vector);
297
298 if (Vector < FIRST_DEVICE_VECTOR ||
299 Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
300 {
301 DPRINT1("Not a device interrupt, vector=%x\n", Vector);
302 ASSERT(FALSE);
303 return;
304 }
305
308
309 return;
310}
unsigned char irq
Definition: dsp.h:13
#define VECTOR2IRQ(vector)
Definition: halirq.h:25
VOID IOAPICMaskIrq(ULONG Irq)
Definition: ioapic.c:494
#define NUMBER_DEVICE_VECTORS
Definition: mps.h:37

◆ HalEnableSystemInterrupt()

BOOLEAN NTAPI HalEnableSystemInterrupt ( ULONG  Vector,
KIRQL  Irql,
KINTERRUPT_MODE  InterruptMode 
)

Definition at line 314 of file mpsirql.c.

317{
318 ULONG irq;
319
320 if (Vector < FIRST_DEVICE_VECTOR ||
321 Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
322 {
323 DPRINT("Not a device interrupt\n");
324 return FALSE;
325 }
326
327 /* FIXME: We must check if the requested and the assigned interrupt mode is the same */
328
331
332 return TRUE;
333}
VOID IOAPICUnmaskIrq(ULONG Irq)
Definition: ioapic.c:511

◆ HalEndSystemInterrupt()

VOID NTAPI HalEndSystemInterrupt ( KIRQL  Irql,
IN PKTRAP_FRAME  TrapFrame 
)

Definition at line 271 of file mpsirql.c.

276{
277 ULONG Flags;
279
281 {
282 DPRINT1("HalEndSystemInterrupt was called with interrupt's enabled\n");
283 ASSERT(FALSE);
284 }
285 APICSendEOI();
287}
VOID HalpLowerIrql(KIRQL NewIrql, BOOLEAN FromHalEndSystemInterrupt)
Definition: mpsirql.c:72

◆ HalpLowerIrql()

VOID HalpLowerIrql ( KIRQL  NewIrql,
BOOLEAN  FromHalEndSystemInterrupt 
)

Definition at line 72 of file mpsirql.c.

73{
75 UCHAR DpcRequested;
77 {
79 APICWrite(APIC_TPR, IRQL2TPR (NewIrql) & APIC_TPR_PRI);
80 return;
81 }
84 {
86 APICWrite(APIC_TPR, IRQL2TPR (DISPATCH_LEVEL) & APIC_TPR_PRI);
87 DpcRequested = __readfsbyte(FIELD_OFFSET(KPCR, HalReserved[HAL_DPC_REQUEST]));
88 if (FromHalEndSystemInterrupt || DpcRequested)
89 {
91 _enable();
94 {
95 _disable();
96 }
97 }
99 }
100 if (NewIrql == APC_LEVEL)
101 {
102 return;
103 }
104 if (KeGetCurrentThread () != NULL &&
105 KeGetCurrentThread ()->ApcState.KernelApcPending)
106 {
107 _enable();
110 {
111 _disable();
112 }
113 }
115}
VOID NTAPI KiDispatchInterrupt(VOID)
Definition: thrdini.c:305
#define NULL
Definition: types.h:112
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeGetCurrentThread
Definition: hal.h:55
#define HAL_DPC_REQUEST
Definition: halp.h:51
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
PPC_QUAL unsigned char __readfsbyte(const unsigned long Offset)
Definition: intrin_ppc.h:360
PPC_QUAL void __writefsbyte(const unsigned long Offset, const unsigned char Data)
Definition: intrin_ppc.h:342
#define KernelMode
Definition: asm.h:34
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1765
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
Definition: apc.c:302
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
Definition: ke.h:294
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by HalEndSystemInterrupt(), and KfLowerIrql().

◆ HalRequestSoftwareInterrupt()

VOID FASTCALL HalRequestSoftwareInterrupt ( IN KIRQL  Request)

Definition at line 336 of file mpsirql.c.

337{
338 switch (Request)
339 {
340 case APC_LEVEL:
342 break;
343
344 case DISPATCH_LEVEL:
346 break;
347
348 default:
349 ASSERT(FALSE);
350 }
351}
#define HAL_APC_REQUEST
Definition: halp.h:50
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547

◆ KeGetCurrentIrql()

KIRQL NTAPI KeGetCurrentIrql ( VOID  )

Definition at line 24 of file mpsirql.c.

29{
30 KIRQL irql;
32
34 _disable();
35
37 if (irql > HIGH_LEVEL)
38 {
39 DPRINT1 ("CurrentIrql %x\n", irql);
41 }
43 {
44 _enable();
45 }
46 return irql;
47}
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define HIGH_LEVEL
Definition: env_spec_w32.h:703

◆ KeRaiseIrqlToDpcLevel()

KIRQL NTAPI KeRaiseIrqlToDpcLevel ( VOID  )

Definition at line 213 of file mpsirql.c.

214{
216}
KIRQL FASTCALL KfRaiseIrql(KIRQL NewIrql)
Definition: mpsirql.c:165

◆ KeRaiseIrqlToSynchLevel()

KIRQL NTAPI KeRaiseIrqlToSynchLevel ( VOID  )

Definition at line 237 of file mpsirql.c.

238{
239 return KfRaiseIrql (CLOCK2_LEVEL);
240}
#define CLOCK2_LEVEL
Definition: env_spec_w32.h:700

◆ KeSetCurrentIrql()

VOID KeSetCurrentIrql ( KIRQL  NewIrql)

Definition at line 51 of file mpsirql.c.

55{
57 if (NewIrql > HIGH_LEVEL)
58 {
59 DPRINT1 ("NewIrql %x\n", NewIrql);
61 }
63 _disable();
66 {
67 _enable();
68 }
69}

Referenced by HalBeginSystemInterrupt(), HalpLowerIrql(), KfRaiseIrql(), and KiInitializeCpu().

◆ KfLowerIrql()

VOID FASTCALL KfLowerIrql ( KIRQL  NewIrql)

Definition at line 135 of file mpsirql.c.

136{
137 KIRQL oldIrql = KeGetCurrentIrql();
138 if (NewIrql > oldIrql)
139 {
140 DPRINT1 ("NewIrql %x CurrentIrql %x\n", NewIrql, oldIrql);
141 ASSERT(FALSE);
142 }
144}

◆ KfRaiseIrql()

KIRQL FASTCALL KfRaiseIrql ( KIRQL  NewIrql)

Definition at line 165 of file mpsirql.c.

166{
168 ULONG Flags;
169
171 _disable();
172
174
175 if (NewIrql < OldIrql)
176 {
177 DPRINT1 ("CurrentIrql %x NewIrql %x\n", KeGetCurrentIrql (), NewIrql);
178 ASSERT(FALSE);
179 }
180
181
183 {
184 APICWrite (APIC_TPR, IRQL2TPR(NewIrql) & APIC_TPR_PRI);
185 }
188 {
189 _enable();
190 }
191
192 return OldIrql;
193}

Referenced by KeRaiseIrqlToDpcLevel(), and KeRaiseIrqlToSynchLevel().