From 575fd458f27114cc36242d577bdb402c000acf0f Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sun, 24 Jan 2010 23:14:08 +0000 Subject: [PATCH] [HAL]: Implement KeGetCurrentIrql, KeRaiseIrqlToDpcLevel, KeRaiseIrqlToSynchLevel, HalClearSoftwareInterrupt in C instead of ASM. svn path=/trunk/; revision=45234 --- reactos/hal/halx86/generic/irq.S | 81 ----------------------------- reactos/hal/halx86/generic/pic.c | 88 ++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 81 deletions(-) diff --git a/reactos/hal/halx86/generic/irq.S b/reactos/hal/halx86/generic/irq.S index 84ab80f62b0..8366555fb2e 100644 --- a/reactos/hal/halx86/generic/irq.S +++ b/reactos/hal/halx86/generic/irq.S @@ -174,20 +174,6 @@ NothingHardware: ret .endfunc -.globl @HalClearSoftwareInterrupt@4 -.func @HalClearSoftwareInterrupt@4, @HalClearSoftwareInterrupt@4 -@HalClearSoftwareInterrupt@4: - - /* Get IRR mask */ - mov eax, 1 - shl eax, cl - not eax - - /* Set IRR */ - and PCR[KPCR_IRR], eax - ret -.endfunc - .globl @HalRequestSoftwareInterrupt@4 .func @HalRequestSoftwareInterrupt@4, @HalRequestSoftwareInterrupt@4 @HalRequestSoftwareInterrupt@4: @@ -699,73 +685,6 @@ InvalidKfRaise: #endif .endfunc -.globl _KeGetCurrentIrql@0 -.func KeGetCurrentIrql@0 -_KeGetCurrentIrql@0: - - /* Return the IRQL */ - mov eax, PCR[KPCR_IRQL] - ret -.endfunc - -.globl _KeRaiseIrqlToDpcLevel@0 -.func KeRaiseIrqlToDpcLevel@0 -_KeRaiseIrqlToDpcLevel@0: - - /* Get the current IRQL */ - mov eax, PCR[KPCR_IRQL] - - /* Set DISPATCH_LEVEL */ - mov dword ptr PCR[KPCR_IRQL], DISPATCH_LEVEL - -#if DBG - /* Make sure we were not higher then synch */ - cmp eax, DISPATCH_LEVEL - ja InvalidRaise -#endif - ret - -#if DBG -InvalidRaise: - /* Bugcheck the system */ - push 1 - push 0 - push DISPATCH_LEVEL - push eax - push IRQL_NOT_GREATER_OR_EQUAL - call _KeBugCheckEx@20 -#endif -.endfunc - -.globl _KeRaiseIrqlToSynchLevel@0 -.func KeRaiseIrqlToSynchLevel@0 -_KeRaiseIrqlToSynchLevel@0: - - /* Get the current IRQL */ - mov eax, PCR[KPCR_IRQL] - - /* Set SYNCH_LEVEL */ - mov dword ptr PCR[KPCR_IRQL], SYNCH_LEVEL - -#if DBG - /* Make sure we were not higher then dispatch */ - cmp eax, SYNCH_LEVEL - ja InvalidSyRaise -#endif - ret - -#if DBG -InvalidSyRaise: - /* Bugcheck the system */ - push 2 - push 0 - push SYNCH_LEVEL - push eax - push IRQL_NOT_GREATER_OR_EQUAL - call _KeBugCheckEx@20 -#endif -.endfunc - .globl _HalpApcInterrupt .func HalpApcInterrupt TRAP_FIXUPS hapc_a, hapc_t, DoFixupV86, DoFixupAbios diff --git a/reactos/hal/halx86/generic/pic.c b/reactos/hal/halx86/generic/pic.c index d54e89f3a76..ea1b68b9b7d 100644 --- a/reactos/hal/halx86/generic/pic.c +++ b/reactos/hal/halx86/generic/pic.c @@ -116,3 +116,91 @@ HalpInitializePICs(IN BOOLEAN EnableInterrupts) __writeeflags(EFlags); } +/* IRQL MANAGEMENT ************************************************************/ + +/* + * @implemented + */ +KIRQL +NTAPI +KeGetCurrentIrql(VOID) +{ + /* Return the IRQL */ + return KeGetPcr()->Irql; +} + +/* + * @implemented + */ +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID) +{ + PKPCR Pcr = KeGetPcr(); + KIRQL CurrentIrql; + + /* Save and update IRQL */ + CurrentIrql = Pcr->Irql; + Pcr->Irql = DISPATCH_LEVEL; + +#ifdef IRQL_DEBUG + /* Validate correct raise */ + if (CurrentIrql > DISPATCH_LEVEL) + { + /* Crash system */ + KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL, + CurrentIrql, + DISPATCH_LEVEL, + 0, + 1); + } +#endif + + /* Return the previous value */ + return CurrentIrql; +} + +/* + * @implemented + */ +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID) +{ + PKPCR Pcr = KeGetPcr(); + KIRQL CurrentIrql; + + /* Save and update IRQL */ + CurrentIrql = Pcr->Irql; + Pcr->Irql = SYNCH_LEVEL; + +#ifdef IRQL_DEBUG + /* Validate correct raise */ + if (CurrentIrql > SYNCH_LEVEL) + { + /* Crash system */ + KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL, + CurrentIrql, + SYNCH_LEVEL, + 0, + 1); + } +#endif + + /* Return the previous value */ + return CurrentIrql; +} + + +/* SOFTWARE INTERRUPTS ********************************************************/ + +/* + * @implemented + */ +VOID +FASTCALL +HalClearSoftwareInterrupt(IN KIRQL Irql) +{ + /* Mask out the requested bit */ + KeGetPcr()->IRR &= ~(1 << Irql); +}