Author: sir_richard Date: Mon Jan 25 00:14:08 2010 New Revision: 45234
URL: http://svn.reactos.org/svn/reactos?rev=45234&view=rev Log: [HAL]: Implement KeGetCurrentIrql, KeRaiseIrqlToDpcLevel, KeRaiseIrqlToSynchLevel, HalClearSoftwareInterrupt in C instead of ASM.
Modified: trunk/reactos/hal/halx86/generic/irq.S trunk/reactos/hal/halx86/generic/pic.c
Modified: trunk/reactos/hal/halx86/generic/irq.S URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/irq.S?re... ============================================================================== --- trunk/reactos/hal/halx86/generic/irq.S [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/irq.S [iso-8859-1] Mon Jan 25 00:14:08 2010 @@ -174,20 +174,6 @@ 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 @@ #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
Modified: trunk/reactos/hal/halx86/generic/pic.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/pic.c?re... ============================================================================== --- trunk/reactos/hal/halx86/generic/pic.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/pic.c [iso-8859-1] Mon Jan 25 00:14:08 2010 @@ -116,3 +116,91 @@ __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); +}