From b2e87768af73e397073d8469b4f3976bd225e380 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 15 Jan 2010 00:13:38 +0000 Subject: [PATCH] [NTOS] Implement InterruptDispatchTable, containing 256 dispatch stubs, that push the Vector on the stack and then jump to KiUnexpectedInterrupt. This way we have the vector as ErrorCode on the stack and we can report it with KeBugCheckWithTf. svn path=/branches/ros-amd64-bringup/; revision=45082 --- reactos/ntoskrnl/ke/amd64/except.c | 4 +++- reactos/ntoskrnl/ke/amd64/trap.S | 34 ++++++++++++++++++------------ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/reactos/ntoskrnl/ke/amd64/except.c b/reactos/ntoskrnl/ke/amd64/except.c index ccd9ee59121..ba5a35491aa 100644 --- a/reactos/ntoskrnl/ke/amd64/except.c +++ b/reactos/ntoskrnl/ke/amd64/except.c @@ -13,6 +13,8 @@ #define NDEBUG #include +extern ULONG64 InterruptDispatchTable[256]; + /* GLOBALS *******************************************************************/ KIDT_INIT KiInterruptInitTable[] = @@ -73,7 +75,7 @@ KeInitExceptions(VOID) } else { - Offset = (ULONG64)KiUnexpectedInterrupt; + Offset = (ULONG64)&InterruptDispatchTable[i]; KiIdt[i].Dpl = 0; KiIdt[i].IstIndex = 0; } diff --git a/reactos/ntoskrnl/ke/amd64/trap.S b/reactos/ntoskrnl/ke/amd64/trap.S index 7cbfacf0c6a..868364d3f43 100644 --- a/reactos/ntoskrnl/ke/amd64/trap.S +++ b/reactos/ntoskrnl/ke/amd64/trap.S @@ -28,10 +28,10 @@ _MsgBreakpointTrap: .ascii "BreakpointTrap at %p\n\0" _MsgUnexpectedInterrupt: -.ascii "UnexpectedInterrupt\n\0" +.ascii "UnexpectedInterrupt Vector=0x%02lx\n\0" _MsgInvalidOpcodeFault: -.ascii "General protection fault at %p!\n\0" +.ascii "Invalid opcode fault at %p!\n\0" _MsgDoubleFault: .ascii "Double fault at %p, rbp=%p!\n\0" @@ -242,6 +242,17 @@ _MsgTrapInfo: .text .code64 +.align 8 +.global _InterruptDispatchTable +_InterruptDispatchTable: +.set Vector, 0 +.rept 256 + push Vector + jmp _KiUnexpectedInterrupt + .align 8 + .set Vector, Vector+1 +.endr + // rbp = TrapFrame, eax = ExceptionCode, edx = NumParams, r9,r10,r11 = params _InternalDispatchException: @@ -779,23 +790,20 @@ PageFaultReturn: .proc KiUnexpectedInterrupt .pushframe 0 - /* Push pseudo error code */ - push 0 - .allocstack 0x8 + + /* The error code is the vector */ cli ENTER_TRAP_FRAME TRAPFLAG_ALL - lea rcx, _MsgUnexpectedInterrupt[rip] - call _FrLdrDbgPrint[rip] - + /* Set bugcheck parameters */ mov ecx, TRAP_CAUSE_UNKNOWN -// mov rdx, // The unexpected interrupt -// mov rdx, // The unknown floating-point exception -// mov r8, // The enabled and asserted status bits - xor r9, r9 // Reserved - mov [rbp + KTRAP_FRAME_P5], rbp // trap frame + mov rdx, [rbp + KTRAP_FRAME_ErrorCode] // the vector + mov r8, 0 // The unknown floating-point exception + mov r9, 0 // The enabled and asserted status bits + sub rsp, 8 + mov [rbp + KTRAP_FRAME_P5 + 8], rbp // trap frame call _KeBugCheckWithTf .endproc