Author: ion
Date: Wed Aug 23 05:23:11 2006
New Revision: 23660
URL:
http://svn.reactos.org/svn/reactos?rev=23660&view=rev
Log:
- 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.
Modified:
trunk/reactos/hal/halx86/generic/irq.S
trunk/reactos/hal/halx86/generic/irql.c
Modified: trunk/reactos/hal/halx86/generic/irq.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/irq.S?r…
==============================================================================
--- trunk/reactos/hal/halx86/generic/irq.S (original)
+++ trunk/reactos/hal/halx86/generic/irq.S Wed Aug 23 05:23:11 2006
@@ -83,7 +83,8 @@
.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 @@
/* 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 @@
/* 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:
@@ -400,6 +403,7 @@
add esp, 8
jmp SoftIntHandlerTable2[eax*4]
.endfunc
+
.globl @KfLowerIrql@4
.func @KfLowerIrql@4
@@ -427,14 +431,20 @@
/* 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 @@
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
Modified: trunk/reactos/hal/halx86/generic/irql.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/irql.c?…
==============================================================================
--- trunk/reactos/hal/halx86/generic/irql.c (original)
+++ trunk/reactos/hal/halx86/generic/irql.c Wed Aug 23 05:23:11 2006
@@ -12,29 +12,22 @@
#include <hal.h>
#define NDEBUG
#include <debug.h>
-#include <ndk/asm.h>
/* 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 @@
WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)Mask);
}
- if (NewIrql >= PROFILE_LEVEL)
+
+ KeGetPcr()->Irql = NewIrql;
+ Pending = SoftIntByteTable[KeGetPcr()->IRR];
+ if (Pending > NewIrql)
{
- KeGetPcr()->Irql = NewIrql;
- Ki386RestoreFlags(Flags);
- return;
- }
- if (NewIrql >= DISPATCH_LEVEL)
- {
- KeGetPcr()->Irql = NewIrql;
- Ki386RestoreFlags(Flags);
- return;
- }
- KeGetPcr()->Irql = NewIrql;
- if (Table[KeGetPcr()->IRR] > 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)
+VOID STDCALL HalEndSystemInterrupt (KIRQL Irql, ULONG Unknown2)
{
- DPRINT("KfLowerIrql(NewIrql %d)\n", NewIrql);
-
- if (NewIrql > KeGetPcr()->Irql)
+ ULONG Mask;
+ ULONG Flags;
+ UCHAR Pending;
+
+ Ki386SaveFlags(Flags);
+ Ki386DisableInterrupts();
+
+ if (KeGetPcr()->Irql > DISPATCH_LEVEL)
{
- DbgPrint ("(%s:%d) NewIrql %x CurrentIrql %x\n",
- __FILE__, __LINE__, NewIrql, KeGetPcr()->Irql);
- KEBUGCHECK(0);
- for(;;);
+ Mask = KeGetPcr()->IDR | KiI8259MaskTable[Irql];
+ WRITE_PORT_UCHAR((PUCHAR)0x21, (UCHAR)Mask);
+ Mask >>= 8;
+ WRITE_PORT_UCHAR((PUCHAR)0xa1, (UCHAR)Mask);
}
-
- HalpLowerIrql(NewIrql);
+
+
+ KeGetPcr()->Irql = Irql;
+ Pending = SoftIntByteTable[KeGetPcr()->IRR];
+ if (Pending > Irql)
+ {
+ SoftIntHandlerTable[Pending]();
+ }
+ Ki386RestoreFlags(Flags);
}
-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);
-}
-
/* EOF */