From c30a8d1cd466b1f1ba39a90ff30d4e171c46b176 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Wed, 23 Aug 2006 01:23:11 +0000 Subject: [PATCH] - Duplicate code between the remaining functions (KfLowerIRql and HalEndSystemInterrupt) so testing the switch to their ASM versions will be easier. - Use same table as in ASM code. svn path=/trunk/; revision=23660 --- reactos/hal/halx86/generic/irq.S | 28 ++++++--- reactos/hal/halx86/generic/irql.c | 97 +++++++++++-------------------- 2 files changed, 52 insertions(+), 73 deletions(-) diff --git a/reactos/hal/halx86/generic/irq.S b/reactos/hal/halx86/generic/irq.S index 88f1e851221..e2ec92ed983 100644 --- a/reactos/hal/halx86/generic/irq.S +++ b/reactos/hal/halx86/generic/irq.S @@ -83,7 +83,8 @@ HalpSysIntHandler: .long GenericIRQ /* IRQ 16-35 */ .endr -SoftIntByteTable: +.globl _SoftIntByteTable +_SoftIntByteTable: .byte PASSIVE_LEVEL /* IRR 0 */ .byte PASSIVE_LEVEL /* IRR 1 */ .byte APC_LEVEL /* IRR 2 */ @@ -174,7 +175,7 @@ _@HalRequestSoftwareInterrupt@4: /* Get highest pending software interrupt and check if it's higher */ xor edx, edx - mov dl, SoftIntByteTable[eax] + mov dl, _SoftIntByteTable[eax] cmp dl, cl jbe AfterCall @@ -388,10 +389,12 @@ SkipMask2: /* Set IRQL and check if there are pending software interrupts */ mov [fs:KPCR_IRQL], cl +#if 0 mov eax, [fs:KPCR_IDR] - mov al, SoftIntByteTable[eax] + mov al, _SoftIntByteTable[eax] cmp al, cl ja DoCall +#endif ret 8 DoCall: @@ -401,6 +404,7 @@ DoCall: jmp SoftIntHandlerTable2[eax*4] .endfunc + .globl @KfLowerIrql@4 .func @KfLowerIrql@4 _@KfLowerIrql@4: @@ -427,14 +431,20 @@ SkipMask: /* Set the new IRQL and check if there's a pending software interrupt */ mov [fs:KPCR_IRQL], cl mov eax, [fs:KPCR_IDR] - mov al, SoftIntByteTable[eax] + mov al, _SoftIntByteTable[eax] cmp al, cl - jbe AfterCall2 + ja DoCall3 + + /* Restore interrupts and return */ + popf + ret + .align 4 + +DoCall3: /* There is, call it */ - call SoftIntHandlerTable[eax*4] - -AfterCall2: + call _SoftIntHandlerTable[eax*4] + jmp $ /* Restore interrupts and return */ popf @@ -629,7 +639,7 @@ SoftwareInt: mov [fs:KPCR_IRQL], cl #if 0 mov eax, [fs:KPCR_IDR] - mov al, SoftIntByteTable[eax] + mov al, _SoftIntByteTable[eax] cmp al, cl ja DoCall2 #endif diff --git a/reactos/hal/halx86/generic/irql.c b/reactos/hal/halx86/generic/irql.c index a1b458f0421..6c8c90fca5e 100644 --- a/reactos/hal/halx86/generic/irql.c +++ b/reactos/hal/halx86/generic/irql.c @@ -12,29 +12,22 @@ #include #define NDEBUG #include -#include /* GLOBALS ******************************************************************/ -UCHAR Table[8] = -{ - 0, 0, - 1, 1, - 2, 2, 2, 2 -}; - typedef VOID (*PSW_HANDLER)(VOID); extern PSW_HANDLER SoftIntHandlerTable[]; +extern ULONG KiI8259MaskTable[]; +extern UCHAR SoftIntByteTable[]; /* FUNCTIONS ****************************************************************/ -extern ULONG KiI8259MaskTable[]; - -VOID STATIC -HalpLowerIrql(KIRQL NewIrql) +VOID FASTCALL +KfLowerIrql (KIRQL NewIrql) { ULONG Mask; ULONG Flags; + UCHAR Pending; Ki386SaveFlags(Flags); Ki386DisableInterrupts(); @@ -47,66 +40,42 @@ HalpLowerIrql(KIRQL NewIrql) WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)Mask); } - if (NewIrql >= PROFILE_LEVEL) - { - KeGetPcr()->Irql = NewIrql; - Ki386RestoreFlags(Flags); - return; - } - if (NewIrql >= DISPATCH_LEVEL) - { - KeGetPcr()->Irql = NewIrql; - Ki386RestoreFlags(Flags); - return; - } + KeGetPcr()->Irql = NewIrql; - if (Table[KeGetPcr()->IRR] > NewIrql) + Pending = SoftIntByteTable[KeGetPcr()->IRR]; + if (Pending > NewIrql) { - SoftIntHandlerTable[Table[KeGetPcr()->IRR]](); + SoftIntHandlerTable[Pending](); } Ki386RestoreFlags(Flags); } -/********************************************************************** - * NAME EXPORTED - * KfLowerIrql - * - * DESCRIPTION - * Restores the irq level on the current processor - * - * ARGUMENTS - * NewIrql = Irql to lower to - * - * RETURN VALUE - * None - * - * NOTES - * Uses fastcall convention - */ -VOID FASTCALL -KfLowerIrql (KIRQL NewIrql) -{ - DPRINT("KfLowerIrql(NewIrql %d)\n", NewIrql); - - if (NewIrql > KeGetPcr()->Irql) - { - DbgPrint ("(%s:%d) NewIrql %x CurrentIrql %x\n", - __FILE__, __LINE__, NewIrql, KeGetPcr()->Irql); - KEBUGCHECK(0); - for(;;); - } - - HalpLowerIrql(NewIrql); -} - - VOID STDCALL HalEndSystemInterrupt (KIRQL Irql, ULONG Unknown2) -/* - * FUNCTION: Finish a system interrupt and restore the specified irq level. - */ { - //DPRINT1("ENDING: %lx %lx\n", Irql, Unknown2); - HalpLowerIrql(Irql); + ULONG Mask; + ULONG Flags; + UCHAR Pending; + + Ki386SaveFlags(Flags); + Ki386DisableInterrupts(); + + if (KeGetPcr()->Irql > DISPATCH_LEVEL) + { + Mask = KeGetPcr()->IDR | KiI8259MaskTable[Irql]; + WRITE_PORT_UCHAR((PUCHAR)0x21, (UCHAR)Mask); + Mask >>= 8; + WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)Mask); + } + + + KeGetPcr()->Irql = Irql; + Pending = SoftIntByteTable[KeGetPcr()->IRR]; + if (Pending > Irql) + { + SoftIntHandlerTable[Pending](); + } + Ki386RestoreFlags(Flags); } + /* EOF */