From da725d9d300fec2bc59817a9a9cd0cfebe28e1b5 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Wed, 23 Aug 2006 18:02:52 +0000 Subject: [PATCH] - Fix some bugs in INT_PROLOG so that it can be used in cases like Unexepcted interrupts, where we don't want to push a fake error code, and want to use our own parameter. svn path=/trunk/; revision=23672 --- reactos/hal/halx86/generic/halinit.c | 11 ---------- reactos/hal/halx86/generic/irq.S | 4 ++-- reactos/hal/halx86/generic/systimer.S | 1 + reactos/hal/halx86/up/halinit_up.c | 11 ++++++++++ .../ntoskrnl/include/internal/i386/asmmacro.S | 20 ++++++++++++++++++- reactos/ntoskrnl/ke/i386/irq.c | 1 + reactos/ntoskrnl/ke/i386/trap.s | 2 +- 7 files changed, 35 insertions(+), 15 deletions(-) diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 3762691c6d1..8abdda47fd9 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -20,8 +20,6 @@ PVOID HalpZeroPageMapping = NULL; HALP_HOOKS HalpHooks; -VOID NTAPI HalpClockInterrupt(VOID); - /* FUNCTIONS ***************************************************************/ NTSTATUS @@ -44,15 +42,6 @@ HalInitSystem (ULONG BootPhase, } else if (BootPhase == 1) { -#if 0 - /* Enable the clock interrupt */ - ((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].ExtendedOffset = - (USHORT)(((ULONG_PTR)HalpClockInterrupt >> 16) & 0xFFFF); - ((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].Offset = - (USHORT)HalpClockInterrupt; - HalEnableSystemInterrupt(IRQ2VECTOR(0), CLOCK2_LEVEL, Latched); -#endif - /* Initialize display and make the screen black */ HalInitializeDisplay ((PROS_LOADER_PARAMETER_BLOCK)LoaderBlock); HalpInitBusHandlers(); diff --git a/reactos/hal/halx86/generic/irq.S b/reactos/hal/halx86/generic/irq.S index e38b0fc1719..1944b56060b 100644 --- a/reactos/hal/halx86/generic/irq.S +++ b/reactos/hal/halx86/generic/irq.S @@ -537,7 +537,7 @@ _HalpApcInterrupt: push eax /* Enter interrupt */ - INT_PROLOG(hapc) + INT_PROLOG hapc, DoPushFakeErrorCode .endfunc .globl _HalpApcInterrupt2ndEntry @@ -584,7 +584,7 @@ _HalpDispatchInterrupt: push eax /* Enter interrupt */ - INT_PROLOG(hapc) + INT_PROLOG hapc, DoPushFakeErrorCode .endfunc .globl _HalpDispatchInterrupt2ndEntry diff --git a/reactos/hal/halx86/generic/systimer.S b/reactos/hal/halx86/generic/systimer.S index 8d160fbefc0..e7c14bc352e 100644 --- a/reactos/hal/halx86/generic/systimer.S +++ b/reactos/hal/halx86/generic/systimer.S @@ -21,4 +21,5 @@ .func HalpClockInterrupt@0 _HalpClockInterrupt@0: + jmp $ .endfunc diff --git a/reactos/hal/halx86/up/halinit_up.c b/reactos/hal/halx86/up/halinit_up.c index 8b4824abf32..1709cf00d2e 100644 --- a/reactos/hal/halx86/up/halinit_up.c +++ b/reactos/hal/halx86/up/halinit_up.c @@ -15,6 +15,8 @@ #define NDEBUG #include +VOID NTAPI HalpClockInterrupt(VOID); + /* FUNCTIONS ***************************************************************/ VOID @@ -22,6 +24,15 @@ HalpInitPhase0(PROS_LOADER_PARAMETER_BLOCK LoaderBlock) { HalpInitPICs(); + /* Enable the clock interrupt */ +#if 0 + ((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].ExtendedOffset = + (USHORT)(((ULONG_PTR)HalpClockInterrupt >> 16) & 0xFFFF); + ((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].Offset = + (USHORT)HalpClockInterrupt; +#endif + HalEnableSystemInterrupt(IRQ2VECTOR(0), CLOCK2_LEVEL, Latched); + /* Setup busy waiting */ HalpCalibrateStallExecution(); } diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index d97baa2d934..e755477546e 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -16,11 +16,13 @@ #define DoRestoreEverything 1 #define DoRestoreSegments 1 #define DoRestoreVolatiles 1 +#define DoPushFakeErrorCode 1 #define NotFromSystemCall 0 #define DoNotRestorePreviousMode 0 #define DoNotRestoreEverything 0 #define DoNotRestoreSegments 0 #define DoNotRestoreVolatiles 0 +#define DoNotPushFakeErrorCode 0 // Arguments for idt #define INT_32_DPL0 0x8E00 @@ -332,9 +334,12 @@ _KiUnexpectedInterrupt&Number: // // @remark For software interrupts, make sure that a fake INT stack is created. // -.macro INT_PROLOG Label +.macro INT_PROLOG Label FakeErrorCode + +.if \FakeErrorCode /* Save fake error code */ push esp +.endif /* Save the non-volatiles */ push ebp @@ -388,6 +393,14 @@ _KiUnexpectedInterrupt&Number: /* Save the previous exception list */ mov [esp+KTRAP_FRAME_EXCEPTION_LIST], ebx +.ifeq \FakeErrorCode + /* Setup the 16-bit stack */ + lea eax, [esp+KTRAP_FRAME_ERROR_CODE] + lea ecx, [esp+KTRAP_FRAME_EIP] + mov ebx, ss:[eax] + mov ss:[eax], ecx +.endif + /* Check if this is the ABIOS stack */ /* cmp esp, 0x10000*/ /* jb Abios_Label*/ @@ -405,6 +418,11 @@ _KiUnexpectedInterrupt&Number: /* Check if the thread was being debugged */ test byte ptr [ecx+KTHREAD_DEBUG_ACTIVE], 0xFF +.ifeq \FakeErrorCode + /* Push parameter */ + push ebx +.endif + /* Save DR registers if needed */ //jnz Dr_&Label diff --git a/reactos/ntoskrnl/ke/i386/irq.c b/reactos/ntoskrnl/ke/i386/irq.c index eb13fb7bc82..aa82328509c 100644 --- a/reactos/ntoskrnl/ke/i386/irq.c +++ b/reactos/ntoskrnl/ke/i386/irq.c @@ -292,6 +292,7 @@ KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe) #ifndef CONFIG_SMP if (VECTOR2IRQ(vector) == 0) { + DPRINT1("Tick\n"); KeIRQTrapFrameToTrapFrame(Trapframe, &KernelTrapFrame); KeUpdateSystemTime(&KernelTrapFrame, old_level); } diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index ef30f8ef247..f6e073adf30 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -1309,7 +1309,7 @@ _KiEndUnexpected: _KiUnexpectedInterruptTail: /* Enter interrupt trap */ - INT_PROLOG(kui) + INT_PROLOG kui, DoNotPushFakeErrorCode /* Increase interrupt count */ inc dword ptr [fs:KPCR_PRCB_INTERRUPT_COUNT]