diff --git a/sdk/xtdk/amd64/ketypes.h b/sdk/xtdk/amd64/ketypes.h index ace7cd8..5d5e8a4 100644 --- a/sdk/xtdk/amd64/ketypes.h +++ b/sdk/xtdk/amd64/ketypes.h @@ -381,88 +381,43 @@ typedef struct _KSWITCH_FRAME /* Trap frame definition */ typedef struct _KTRAP_FRAME { - ULONG64 P1Home; - ULONG64 P2Home; - ULONG64 P3Home; - ULONG64 P4Home; - ULONG64 P5; - KPROCESSOR_MODE PreviousMode; - KRUNLEVEL PreviousRunLevel; - UCHAR FaultIndicator; - UCHAR ExceptionActive; - ULONG MxCsr; - ULONG64 Rax; - ULONG64 Rcx; - ULONG64 Rdx; - ULONG64 R8; - ULONG64 R9; - ULONG64 R10; - ULONG64 R11; - union - { - ULONG64 GsBase; - ULONG64 GsSwap; - }; - M128 Xmm0; - M128 Xmm1; - M128 Xmm2; - M128 Xmm3; - M128 Xmm4; - M128 Xmm5; - union - { - ULONG64 FaultAddress; - ULONG64 ContextRecord; - ULONG64 TimeStampCKCL; - }; - ULONG64 Dr0; - ULONG64 Dr1; - ULONG64 Dr2; - ULONG64 Dr3; - ULONG64 Dr6; - ULONG64 Dr7; - union - { - struct - { - ULONG64 DebugControl; - ULONG64 LastBranchToRip; - ULONG64 LastBranchFromRip; - ULONG64 LastExceptionToRip; - ULONG64 LastExceptionFromRip; - }; - struct - { - ULONG64 LastBranchControl; - ULONG LastBranchMSR; - }; - }; + ULONGLONG Dr0; + ULONGLONG Dr1; + ULONGLONG Dr2; + ULONGLONG Dr3; + ULONGLONG Dr6; + ULONGLONG Dr7; + ULONGLONG Cr2; + ULONGLONG Cr3; USHORT SegDs; USHORT SegEs; USHORT SegFs; USHORT SegGs; - ULONG64 TrapFrame; - ULONG64 Rbx; - ULONG64 Rdi; - ULONG64 Rsi; - ULONG64 Rbp; - union - { - ULONG64 ErrorCode; - ULONG64 ExceptionFrame; - ULONG64 TimeStampKlog; + ULONGLONG Rax; + ULONGLONG Rbx; + ULONGLONG Rcx; + ULONGLONG Rdx; + ULONGLONG Rsi; + ULONGLONG Rdi; + ULONGLONG Rbp; + ULONGLONG R8; + ULONGLONG R9; + ULONGLONG R10; + ULONGLONG R11; + ULONGLONG R12; + ULONGLONG R13; + ULONGLONG R14; + ULONGLONG R15; + ULONGLONG Vector; + union { + ULONGLONG ErrorCode; + ULONGLONG ExceptionFrame; }; - ULONG64 Rip; - USHORT SegCs; - UCHAR Fill0; - UCHAR Logging; - USHORT Fill1[2]; - ULONG EFlags; - ULONG Fill2; - ULONG64 Rsp; - USHORT SegSs; - USHORT Fill3; - ULONG CodePatchCycle; + ULONGLONG Rip; + ULONGLONG Cs; + ULONGLONG RFlags; + ULONGLONG Rsp; + ULONGLONG SegSs; } KTRAP_FRAME, *PKTRAP_FRAME; /* Thread initialization frame definition */ diff --git a/sdk/xtdk/i686/ketypes.h b/sdk/xtdk/i686/ketypes.h index 3d7e5b4..6c16049 100644 --- a/sdk/xtdk/i686/ketypes.h +++ b/sdk/xtdk/i686/ketypes.h @@ -382,41 +382,32 @@ typedef struct _KSWITCH_FRAME /* Trap frame definition */ typedef struct _KTRAP_FRAME { - ULONG DbgEbp; - ULONG DbgEip; - ULONG DbgMark; - ULONG DbgPointer; - ULONG TempSegCs; - ULONG TempEsp; ULONG Dr0; ULONG Dr1; ULONG Dr2; ULONG Dr3; ULONG Dr6; ULONG Dr7; - ULONG SegGs; - ULONG SegEs; - ULONG SegDs; - ULONG Edx; - ULONG Ecx; + ULONG Cr2; + ULONG Cr3; + USHORT SegDs; + USHORT SegEs; + USHORT SegFs; + USHORT SegGs; ULONG Eax; - ULONG PreviousMode; - PEXCEPTION_REGISTRATION_RECORD ExceptionList; - ULONG SegFs; - ULONG Edi; - ULONG Esi; ULONG Ebx; + ULONG Ecx; + ULONG Edx; + ULONG Esi; + ULONG Edi; ULONG Ebp; - ULONG ErrCode; + ULONG Vector; + ULONG ErrorCode; ULONG Eip; - ULONG SegCs; + ULONG Cs; ULONG EFlags; - ULONG HardwareEsp; - ULONG HardwareSegSs; - ULONG V86Es; - ULONG V86Ds; - ULONG V86Fs; - ULONG V86Gs; + ULONG Esp; + ULONG SegSs; } KTRAP_FRAME, *PKTRAP_FRAME; /* Thread initialization frame definition */ diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 0ae045a..3b8fc39 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -8,6 +8,7 @@ include_directories( # Specify list of source code files list(APPEND XTOSKRNL_SOURCE + ${XTOSKRNL_SOURCE_DIR}/ar/${ARCH}/archsup.S ${XTOSKRNL_SOURCE_DIR}/ar/${ARCH}/cpufunc.c ${XTOSKRNL_SOURCE_DIR}/ar/${ARCH}/globals.c ${XTOSKRNL_SOURCE_DIR}/ar/${ARCH}/procsup.c diff --git a/xtoskrnl/ar/amd64/archsup.S b/xtoskrnl/ar/amd64/archsup.S new file mode 100644 index 0000000..0e41bc3 --- /dev/null +++ b/xtoskrnl/ar/amd64/archsup.S @@ -0,0 +1,122 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/ar/amd64/archsup.S + * DESCRIPTION: Provides AMD64 architecture features not implementable in C. + * DEVELOPERS: Rafal Kupiec + */ + +.altmacro +.text + + +/** + * This macro creates a trap handler for the specified vector. + * + * @param Vector + * Supplies a trap vector number. + * + * @return This macro does not return any value. + * + * @since XT 1.0 + */ +.macro ArpCreateTrapHandler Vector +.global ArpTrap\Vector +ArpTrap\Vector: + /* Push fake error code for non-error vectors */ + .if \Vector != 8 && \Vector != 10 && \Vector != 11 && \Vector != 12 && \Vector != 13 && \Vector != 14 && \Vector != 17 && \Vector != 30 + push $0 + .endif + + /* Push vector number */ + push $\Vector + + /* Push General Purpose Registers */ + push %r15 + push %r14 + push %r13 + push %r12 + push %r11 + push %r10 + push %r9 + push %r8 + push %rbp + push %rdi + push %rsi + push %rdx + push %rcx + push %rbx + push %rax + + /* Push Segments */ + mov %gs, %ax + push %ax + mov %fs, %ax + push %ax + mov %es, %ax + push %ax + mov %ds, %ax + push %ax + + /* Push Control Registers */ + mov %cr3, %rax + push %rax + mov %cr2, %rax + push %rax + + /* Push Debug Registers */ + mov %dr7, %rax + push %rax + mov %dr6, %rax + push %rax + mov %dr3, %rax + push %rax + mov %dr2, %rax + push %rax + mov %dr1, %rax + push %rax + mov %dr0, %rax + push %rax + + /* Push Frame Pointer, clear direction flag and pass to trap dispatcher */ + mov %rsp, %rcx + cld + call ArpDispatchTrap + + /* Skip space occupied by Debug Registers */ + add $(6 * 8), %rsp + + /* Skip space occupied by CR2 and CR3 */ + add $(2 * 8), %rsp + + /* Skip space occupied by Segments */ + add $(4 * 2), %rsp + + /* Pop General Purpose Registers */ + pop %rax + pop %rbx + pop %rcx + pop %rdx + pop %rsi + pop %rdi + pop %rbp + pop %r8 + pop %r9 + pop %r10 + pop %r11 + pop %r12 + pop %r13 + pop %r14 + pop %r15 + + /* Skip error code and vector number, then return */ + add $(2 * 8), %rsp + iretq +.endm + +/* Populate common trap handlers */ +.irp i,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F + .irp j,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F + ArpCreateTrapHandler 0x\i\j + .endr +.endr diff --git a/xtoskrnl/ar/amd64/procsup.c b/xtoskrnl/ar/amd64/procsup.c index 02a18cc..e8b6791 100644 --- a/xtoskrnl/ar/amd64/procsup.c +++ b/xtoskrnl/ar/amd64/procsup.c @@ -235,27 +235,30 @@ ArpInitializeIdt(IN PKPROCESSOR_BLOCK ProcessorBlock) } /* Setup IDT handlers for known interrupts and traps */ - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x00, ArpHandleTrap00, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x01, ArpHandleTrap01, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x02, ArpHandleTrap02, KGDT_R0_CODE, KIDT_IST_PANIC, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x03, ArpHandleTrap03, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x04, ArpHandleTrap04, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x05, ArpHandleTrap05, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x06, ArpHandleTrap06, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x07, ArpHandleTrap07, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x08, ArpHandleTrap08, KGDT_R0_CODE, KIDT_IST_PANIC, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x09, ArpHandleTrap09, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0A, ArpHandleTrap0A, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0B, ArpHandleTrap0B, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0C, ArpHandleTrap0C, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0D, ArpHandleTrap0D, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0E, ArpHandleTrap0E, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x10, ArpHandleTrap10, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x11, ArpHandleTrap11, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x12, ArpHandleTrap12, KGDT_R0_CODE, KIDT_IST_MCA, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x13, ArpHandleTrap13, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2C, ArpHandleTrap2C, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2D, ArpHandleTrap2D, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x00, ArpTrap0x00, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x01, ArpTrap0x01, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x02, ArpTrap0x02, KGDT_R0_CODE, KIDT_IST_PANIC, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x03, ArpTrap0x03, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x04, ArpTrap0x04, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x05, ArpTrap0x05, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x06, ArpTrap0x06, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x07, ArpTrap0x07, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x08, ArpTrap0x08, KGDT_R0_CODE, KIDT_IST_PANIC, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x09, ArpTrap0x09, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0A, ArpTrap0x0A, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0B, ArpTrap0x0B, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0C, ArpTrap0x0C, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0D, ArpTrap0x0D, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0E, ArpTrap0x0E, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x10, ArpTrap0x10, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x11, ArpTrap0x11, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x12, ArpTrap0x12, KGDT_R0_CODE, KIDT_IST_MCA, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x13, ArpTrap0x13, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x1F, ArpTrap0x1F, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2C, ArpTrap0x2C, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2D, ArpTrap0x2D, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2F, ArpTrap0x2F, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0xE1, ArpTrap0xE1, KGDT_R0_CODE, KIDT_IST_RESERVED, KIDT_ACCESS_RING0); } /** diff --git a/xtoskrnl/ar/amd64/traps.c b/xtoskrnl/ar/amd64/traps.c index fe0bc88..66540f0 100644 --- a/xtoskrnl/ar/amd64/traps.c +++ b/xtoskrnl/ar/amd64/traps.c @@ -9,6 +9,126 @@ #include +/** + * Dispatches the trap provided by common trap handler. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpDispatchTrap(IN PKTRAP_FRAME TrapFrame) +{ + /* Check vector and call appropriate handler */ + switch(TrapFrame->Vector) + { + case 0x00: + /* Divide By Zero exception */ + ArpHandleTrap00(TrapFrame); + break; + case 0x01: + /* Debug exception */ + ArpHandleTrap01(TrapFrame); + break; + case 0x02: + /* Non-Maskable Interrupt (NMI) */ + ArpHandleTrap02(TrapFrame); + break; + case 0x03: + /* INT3 instruction executed */ + ArpHandleTrap03(TrapFrame); + break; + case 0x04: + /* Overflow exception */ + ArpHandleTrap04(TrapFrame); + break; + case 0x05: + /* Bound Range Exceeded exception */ + ArpHandleTrap05(TrapFrame); + break; + case 0x06: + /* Invalid Opcode exception */ + ArpHandleTrap06(TrapFrame); + break; + case 0x07: + /* Device Not Available exception */ + ArpHandleTrap07(TrapFrame); + break; + case 0x08: + /* Double Fault exception */ + ArpHandleTrap08(TrapFrame); + break; + case 0x09: + /* Segment Overrun exception */ + ArpHandleTrap09(TrapFrame); + break; + case 0x0A: + /* Invalid TSS exception */ + ArpHandleTrap0A(TrapFrame); + break; + case 0x0B: + /* Segment Not Present exception */ + ArpHandleTrap0B(TrapFrame); + break; + case 0x0C: + /* Stack Segment Fault exception */ + ArpHandleTrap0C(TrapFrame); + break; + case 0x0D: + /* General Protection Fault (GPF) exception*/ + ArpHandleTrap0D(TrapFrame); + break; + case 0x0E: + /* Page Fault exception */ + ArpHandleTrap0E(TrapFrame); + break; + case 0x10: + /* X87 Floating-Point exception */ + ArpHandleTrap10(TrapFrame); + break; + case 0x11: + /* Alignment Check exception */ + ArpHandleTrap11(TrapFrame); + break; + case 0x12: + /* Machine Check exception */ + ArpHandleTrap12(TrapFrame); + break; + case 0x13: + /* SIMD Floating-Point exception */ + ArpHandleTrap13(TrapFrame); + break; + case 0x1F: + /* Software Interrupt at APC level */ + ArpHandleTrap1F(TrapFrame); + break; + case 0x2C: + /* Assertion raised */ + ArpHandleTrap2C(TrapFrame); + break; + case 0x2D: + /* Debug-Service-Request raised */ + ArpHandleTrap2D(TrapFrame); + break; + case 0x2F: + /* Software Interrupt at DISPATCH level */ + ArpHandleTrap2F(TrapFrame); + break; + case 0xE1: + /* InterProcessor Interrupt (IPI) */ + ArpHandleTrapE1(TrapFrame); + break; + default: + /* Unknown/Unexpected trap */ + ArpHandleTrapFF(TrapFrame); + break; + } +} + XTCDECL VOID ArpHandleSystemCall32(VOID) @@ -26,13 +146,16 @@ ArpHandleSystemCall64(VOID) /** * Handles the trap 0x00 when a Divide By Zero exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap00(VOID) +ArpHandleTrap00(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Division-By-Zero Error (0x00)!\n"); for(;;); @@ -41,13 +164,16 @@ ArpHandleTrap00(VOID) /** * Handles the trap 0x01 when Debug exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap01(VOID) +ArpHandleTrap01(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Debug exception (0x01)!\n"); for(;;); @@ -56,13 +182,16 @@ ArpHandleTrap01(VOID) /** * Handles the trap 0x02 when Non-Maskable Interrupt (NMI) occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap02(VOID) +ArpHandleTrap02(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Non-Maskable-Interrupt (0x02)!\n"); for(;;); @@ -71,13 +200,16 @@ ArpHandleTrap02(VOID) /** * Handles the trap 0x03 when the INT3 instruction is executed. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap03(VOID) +ArpHandleTrap03(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled INT3 (0x03)!\n"); for(;;); @@ -86,13 +218,16 @@ ArpHandleTrap03(VOID) /** * Handles the trap 0x04 when the INTO instruction is executed and overflow bit is set. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap04(VOID) +ArpHandleTrap04(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Overflow exception (0x04)!\n"); for(;;); @@ -101,13 +236,16 @@ ArpHandleTrap04(VOID) /** * Handles the trap 0x05 when the Bound Range Exceeded exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap05(VOID) +ArpHandleTrap05(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Bound-Range-Exceeded exception (0x05)!\n"); for(;;); @@ -116,13 +254,16 @@ ArpHandleTrap05(VOID) /** * Handles the trap 0x06 when the Invalid Opcode exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap06(VOID) +ArpHandleTrap06(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Invalid Opcode exception (0x06)!\n"); for(;;); @@ -131,13 +272,16 @@ ArpHandleTrap06(VOID) /** * Handles the trap 0x07 when the Device Not Available exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap07(VOID) +ArpHandleTrap07(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Device Not Available exception (0x07)!\n"); for(;;); @@ -146,13 +290,16 @@ ArpHandleTrap07(VOID) /** * Handles the trap 0x08 when Double Fault exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap08(VOID) +ArpHandleTrap08(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Double-Fault exception (0x08)!\n"); for(;;); @@ -161,13 +308,16 @@ ArpHandleTrap08(VOID) /** * Handles the trap 0x09 when the Segment Overrun exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap09(VOID) +ArpHandleTrap09(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Segment-Overrun exception (0x09)!\n"); for(;;); @@ -176,13 +326,16 @@ ArpHandleTrap09(VOID) /** * Handles the trap 0x0A when the Invalid TSS exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0A(VOID) +ArpHandleTrap0A(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Invalid-TSS exception (0x0A)!\n"); for(;;); @@ -191,13 +344,16 @@ ArpHandleTrap0A(VOID) /** * Handles the trap 0x0B when the Segment Not Present exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0B(VOID) +ArpHandleTrap0B(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Segment-Not-Present exception (0x0B)!\n"); for(;;); @@ -206,13 +362,16 @@ ArpHandleTrap0B(VOID) /** * Handles the trap 0x0C when the Stack Segment Fault exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0C(VOID) +ArpHandleTrap0C(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Stack-Segment-Fault exception (0x0C)!\n"); for(;;); @@ -221,13 +380,16 @@ ArpHandleTrap0C(VOID) /** * Handles the trap 0x0D when General Protection Fault (GPF) exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0D(VOID) +ArpHandleTrap0D(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled General-Protection-Fault (0x0D)!\n"); for(;;); @@ -236,13 +398,16 @@ ArpHandleTrap0D(VOID) /** * Handles the trap 0x0E when the Page Fault (PF) exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0E(VOID) +ArpHandleTrap0E(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Page-Fault exception (0x0E)!\n"); for(;;); @@ -251,13 +416,16 @@ ArpHandleTrap0E(VOID) /** * Handles the trap 0x10 when the X87 Floating-Point exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap10(VOID) +ArpHandleTrap10(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled x87 Floating-Point exception (0x10)!\n"); for(;;); @@ -266,13 +434,16 @@ ArpHandleTrap10(VOID) /** * Handles the trap 0x11 when the Alignment Check exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap11(VOID) +ArpHandleTrap11(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Alignment-Check exception (0x11)!\n"); for(;;); @@ -281,13 +452,16 @@ ArpHandleTrap11(VOID) /** * Handles the trap 0x12 when the Machine Check exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap12(VOID) +ArpHandleTrap12(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Machine-Check exception (0x12)!\n"); for(;;); @@ -296,20 +470,26 @@ ArpHandleTrap12(VOID) /** * Handles the trap 0x13 when the SIMD Floating-Point exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap13(VOID) +ArpHandleTrap13(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled SIMD Floating-Point exception (0x13)!\n"); for(;;); } /** - * Handles the trap 0x2C when an assertion is raised. + * Handles the trap 0x1F when software interrupt gets generated at APC_LEVEL. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. * * @return This routine does not return any value. * @@ -317,7 +497,24 @@ ArpHandleTrap13(VOID) */ XTCDECL VOID -ArpHandleTrap2C(VOID) +ArpHandleTrap1F(IN PKTRAP_FRAME TrapFrame) +{ + DebugPrint(L"Unhandled software interrupt at APC level (0x1F)!\n"); +} + +/** + * Handles the trap 0x2C when an assertion is raised. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpHandleTrap2C(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Assertion (0x2C)!\n"); for(;;); @@ -326,20 +523,26 @@ ArpHandleTrap2C(VOID) /** * Handles the trap 0x2D when a debug service is being requested. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap2D(VOID) +ArpHandleTrap2D(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Debug-Service-Request (0x2D)!\n"); for(;;); } /** - * Handles the trap 0xFF then Unexpected Interrupt occurs. + * Handles the trap 0x2F when a software interrupt gets generated at DISPATCH_LEVEL. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. * * @return This routine does not return any value. * @@ -347,7 +550,41 @@ ArpHandleTrap2D(VOID) */ XTCDECL VOID -ArpHandleTrapFF(VOID) +ArpHandleTrap2F(IN PKTRAP_FRAME TrapFrame) +{ + DebugPrint(L"Unhandled software interrupt at DISPATCH level (0x2F)!\n"); +} + +/** + * Handles the trap 0xE1 when InterProcessor Interrupt (IPI) occurs. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpHandleTrapE1(IN PKTRAP_FRAME TrapFrame) +{ + DebugPrint(L"Unhandled IPI interrupt (0xE1)!\n"); +} + +/** + * Handles the trap 0xFF when Unexpected Interrupt occurs. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpHandleTrapFF(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Unexpected-Interrupt (0xFF)!\n"); for(;;); diff --git a/xtoskrnl/ar/i686/archsup.S b/xtoskrnl/ar/i686/archsup.S new file mode 100644 index 0000000..3ef2027 --- /dev/null +++ b/xtoskrnl/ar/i686/archsup.S @@ -0,0 +1,109 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/ar/i686/archsup.S + * DESCRIPTION: Provides i686 architecture features not implementable in C. + * DEVELOPERS: Rafal Kupiec + */ + +.altmacro +.text + + +/** + * This macro creates a trap handler for the specified vector. + * + * @param Vector + * Supplies a trap vector number. + * + * @return This macro does not return any value. + * + * @since XT 1.0 + */ +.macro ArpCreateTrapHandler Vector +.global _ArpTrap\Vector +_ArpTrap\Vector: + /* Push fake error code for non-error vectors */ + .if \Vector != 8 && \Vector != 10 && \Vector != 11 && \Vector != 12 && \Vector != 13 && \Vector != 14 && \Vector != 17 && \Vector != 30 + push $0 + .endif + + /* Push vector number */ + push $\Vector + + /* Push General Purpose Registers */ + push %ebp + push %edi + push %esi + push %edx + push %ecx + push %ebx + push %eax + + /* Push Segments */ + mov %gs, %ax + push %ax + mov %fs, %ax + push %ax + mov %es, %ax + push %ax + mov %ds, %ax + push %ax + + /* Push Control Registers */ + mov %cr3, %eax + push %eax + mov %cr2, %eax + push %eax + + /* Push Debug Registers */ + mov %dr7, %eax + push %eax + mov %dr6, %eax + push %eax + mov %dr3, %eax + push %eax + mov %dr2, %eax + push %eax + mov %dr1, %eax + push %eax + mov %dr0, %eax + push %eax + + /* Push Frame Pointer, clear direction flag and pass to trap dispatcher */ + push %esp + cld + call _ArpDispatchTrap + + /* Clean up the stack */ + add $4, %esp + + /* Skip space occupied by Debug Registers */ + add $(6 * 4), %esp + + /* Skip space occupied by CR2 and CR3 */ + add $(2 * 4), %esp + + /* Skip space occupied by Segments */ + add $(4 * 2), %esp + + /* Pop General Purpose Registers */ + pop %eax + pop %ebx + pop %ecx + pop %edx + pop %esi + pop %edi + pop %ebp + + /* Skip error code and vector number, then return */ + add $(2 * 4), %esp + iretl +.endm + +/* Populate common trap handlers */ +.irp i,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F + .irp j,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F + ArpCreateTrapHandler 0x\i\j + .endr +.endr diff --git a/xtoskrnl/ar/i686/procsup.c b/xtoskrnl/ar/i686/procsup.c index 8b2010c..5631ad1 100644 --- a/xtoskrnl/ar/i686/procsup.c +++ b/xtoskrnl/ar/i686/procsup.c @@ -233,27 +233,30 @@ ArpInitializeIdt(IN PKPROCESSOR_BLOCK ProcessorBlock) } /* Setup IDT handlers for known interrupts and traps */ - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x00, ArpHandleTrap00, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x01, ArpHandleTrap01, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x02, ArpHandleTrap02, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x03, ArpHandleTrap03, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x04, ArpHandleTrap04, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x05, ArpHandleTrap05, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x06, ArpHandleTrap06, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x07, ArpHandleTrap07, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x08, ArpHandleTrap08, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x09, ArpHandleTrap09, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0A, ArpHandleTrap0A, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0B, ArpHandleTrap0B, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0C, ArpHandleTrap0C, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0D, ArpHandleTrap0D, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0E, ArpHandleTrap0E, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x10, ArpHandleTrap10, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x11, ArpHandleTrap11, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x12, ArpHandleTrap12, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x13, ArpHandleTrap13, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2C, ArpHandleTrap2C, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); - ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2D, ArpHandleTrap2D, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x00, ArpTrap0x00, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x01, ArpTrap0x01, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x02, ArpTrap0x02, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x03, ArpTrap0x03, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x04, ArpTrap0x04, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x05, ArpTrap0x05, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x06, ArpTrap0x06, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x07, ArpTrap0x07, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x08, ArpTrap0x08, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x09, ArpTrap0x09, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0A, ArpTrap0x0A, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0B, ArpTrap0x0B, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0C, ArpTrap0x0C, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0D, ArpTrap0x0D, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x0E, ArpTrap0x0E, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x10, ArpTrap0x10, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x11, ArpTrap0x11, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x12, ArpTrap0x12, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x13, ArpTrap0x13, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING0); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2A, ArpTrap0x2A, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2B, ArpTrap0x2B, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2C, ArpTrap0x2C, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2D, ArpTrap0x2D, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); + ArpSetIdtGate(ProcessorBlock->IdtBase, 0x2E, ArpTrap0x2E, KGDT_R0_CODE, 0, KIDT_INTERRUPT | KIDT_ACCESS_RING3); } /** diff --git a/xtoskrnl/ar/i686/traps.c b/xtoskrnl/ar/i686/traps.c index d1c7df1..031d9e2 100644 --- a/xtoskrnl/ar/i686/traps.c +++ b/xtoskrnl/ar/i686/traps.c @@ -10,7 +10,10 @@ /** - * Handles the trap 0x00 when a Divide By Zero exception occurs. + * Dispatches the trap provided by common trap handler. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. * * @return This routine does not return any value. * @@ -18,7 +21,127 @@ */ XTCDECL VOID -ArpHandleTrap00(VOID) +ArpDispatchTrap(IN PKTRAP_FRAME TrapFrame) +{ + /* Check vector and call appropriate handler */ + switch(TrapFrame->Vector) + { + case 0x00: + /* Divide By Zero exception */ + ArpHandleTrap00(TrapFrame); + break; + case 0x01: + /* Debug exception */ + ArpHandleTrap01(TrapFrame); + break; + case 0x02: + /* Non-Maskable Interrupt (NMI) */ + ArpHandleTrap02(TrapFrame); + break; + case 0x03: + /* INT3 instruction executed */ + ArpHandleTrap03(TrapFrame); + break; + case 0x04: + /* Overflow exception */ + ArpHandleTrap04(TrapFrame); + break; + case 0x05: + /* Bound Range Exceeded exception */ + ArpHandleTrap05(TrapFrame); + break; + case 0x06: + /* Invalid Opcode exception */ + ArpHandleTrap06(TrapFrame); + break; + case 0x07: + /* Device Not Available exception */ + ArpHandleTrap07(TrapFrame); + break; + case 0x08: + /* Double Fault exception */ + ArpHandleTrap08(TrapFrame); + break; + case 0x09: + /* Segment Overrun exception */ + ArpHandleTrap09(TrapFrame); + break; + case 0x0A: + /* Invalid TSS exception */ + ArpHandleTrap0A(TrapFrame); + break; + case 0x0B: + /* Segment Not Present exception */ + ArpHandleTrap0B(TrapFrame); + break; + case 0x0C: + /* Stack Segment Fault exception */ + ArpHandleTrap0C(TrapFrame); + break; + case 0x0D: + /* General Protection Fault (GPF) exception*/ + ArpHandleTrap0D(TrapFrame); + break; + case 0x0E: + /* Page Fault exception */ + ArpHandleTrap0E(TrapFrame); + break; + case 0x10: + /* X87 Floating-Point exception */ + ArpHandleTrap10(TrapFrame); + break; + case 0x11: + /* Alignment Check exception */ + ArpHandleTrap11(TrapFrame); + break; + case 0x12: + /* Machine Check exception */ + ArpHandleTrap12(TrapFrame); + break; + case 0x13: + /* SIMD Floating-Point exception */ + ArpHandleTrap13(TrapFrame); + break; + case 0x2A: + /* Tick Count service request */ + ArpHandleTrap2A(TrapFrame); + break; + case 0x2B: + /* User-mode callback return */ + ArpHandleTrap2B(TrapFrame); + break; + case 0x2C: + /* Assertion raised */ + ArpHandleTrap2C(TrapFrame); + break; + case 0x2D: + /* Debug-Service-Request raised */ + ArpHandleTrap2D(TrapFrame); + break; + case 0x2E: + /* System call service request */ + ArpHandleTrap2E(TrapFrame); + break; + default: + /* Unknown/Unexpected trap */ + ArpHandleTrapFF(TrapFrame); + break; + } +} + +/** + * Handles the trap 0x00 when a Divide By Zero exception occurs. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpHandleTrap00(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Division-By-Zero Error (0x00)!\n"); for(;;); @@ -27,13 +150,16 @@ ArpHandleTrap00(VOID) /** * Handles the trap 0x01 when Debug exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap01(VOID) +ArpHandleTrap01(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Debug exception (0x01)!\n"); for(;;); @@ -42,13 +168,16 @@ ArpHandleTrap01(VOID) /** * Handles the trap 0x02 when Non-Maskable Interrupt (NMI) occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap02(VOID) +ArpHandleTrap02(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Non-Maskable-Interrupt (0x02)!\n"); for(;;); @@ -57,13 +186,16 @@ ArpHandleTrap02(VOID) /** * Handles the trap 0x03 when the INT3 instruction is executed. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap03(VOID) +ArpHandleTrap03(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled INT3 (0x03)!\n"); for(;;); @@ -72,13 +204,16 @@ ArpHandleTrap03(VOID) /** * Handles the trap 0x04 when the INTO instruction is executed and overflow bit is set. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap04(VOID) +ArpHandleTrap04(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Overflow exception (0x04)!\n"); for(;;); @@ -87,13 +222,16 @@ ArpHandleTrap04(VOID) /** * Handles the trap 0x05 when the Bound Range Exceeded exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap05(VOID) +ArpHandleTrap05(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Bound-Range-Exceeded exception (0x05)!\n"); for(;;); @@ -102,13 +240,16 @@ ArpHandleTrap05(VOID) /** * Handles the trap 0x06 when the Invalid Opcode exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap06(VOID) +ArpHandleTrap06(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Invalid Opcode exception (0x06)!\n"); for(;;); @@ -117,13 +258,16 @@ ArpHandleTrap06(VOID) /** * Handles the trap 0x07 when the Device Not Available exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap07(VOID) +ArpHandleTrap07(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Device Not Available exception (0x07)!\n"); for(;;); @@ -132,13 +276,16 @@ ArpHandleTrap07(VOID) /** * Handles the trap 0x08 when Double Fault exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap08(VOID) +ArpHandleTrap08(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Double-Fault exception (0x08)!\n"); for(;;); @@ -147,13 +294,16 @@ ArpHandleTrap08(VOID) /** * Handles the trap 0x09 when the Segment Overrun exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap09(VOID) +ArpHandleTrap09(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Segment-Overrun exception (0x09)!\n"); for(;;); @@ -162,13 +312,16 @@ ArpHandleTrap09(VOID) /** * Handles the trap 0x0A when the Invalid TSS exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0A(VOID) +ArpHandleTrap0A(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Invalid-TSS exception (0x0A)!\n"); for(;;); @@ -177,13 +330,16 @@ ArpHandleTrap0A(VOID) /** * Handles the trap 0x0B when the Segment Not Present exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0B(VOID) +ArpHandleTrap0B(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Segment-Not-Present exception (0x0B)!\n"); for(;;); @@ -192,13 +348,16 @@ ArpHandleTrap0B(VOID) /** * Handles the trap 0x0C when the Stack Segment Fault exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0C(VOID) +ArpHandleTrap0C(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Stack-Segment-Fault exception (0x0C)!\n"); for(;;); @@ -207,13 +366,16 @@ ArpHandleTrap0C(VOID) /** * Handles the trap 0x0D when General Protection Fault (GPF) exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0D(VOID) +ArpHandleTrap0D(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled General-Protection-Fault (0x0D)!\n"); for(;;); @@ -222,13 +384,16 @@ ArpHandleTrap0D(VOID) /** * Handles the trap 0x0E when the Page Fault (PF) exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap0E(VOID) +ArpHandleTrap0E(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Page-Fault exception (0x0E)!\n"); for(;;); @@ -237,13 +402,16 @@ ArpHandleTrap0E(VOID) /** * Handles the trap 0x10 when the X87 Floating-Point exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap10(VOID) +ArpHandleTrap10(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled x87 Floating-Point exception (0x10)!\n"); for(;;); @@ -252,13 +420,16 @@ ArpHandleTrap10(VOID) /** * Handles the trap 0x11 when the Alignment Check exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap11(VOID) +ArpHandleTrap11(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Alignment-Check exception (0x11)!\n"); for(;;); @@ -267,13 +438,16 @@ ArpHandleTrap11(VOID) /** * Handles the trap 0x12 when the Machine Check exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap12(VOID) +ArpHandleTrap12(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Machine-Check exception (0x12)!\n"); for(;;); @@ -282,20 +456,26 @@ ArpHandleTrap12(VOID) /** * Handles the trap 0x13 when the SIMD Floating-Point exception occurs. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap13(VOID) +ArpHandleTrap13(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled SIMD Floating-Point exception (0x13)!\n"); for(;;); } /** - * Handles the trap 0x2C when an assertion is raised. + * Handles the trap 0x2A when Tick Count service request occurs. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. * * @return This routine does not return any value. * @@ -303,7 +483,41 @@ ArpHandleTrap13(VOID) */ XTCDECL VOID -ArpHandleTrap2C(VOID) +ArpHandleTrap2A(IN PKTRAP_FRAME TrapFrame) +{ + DebugPrint(L"Unhandled Tick Count service request (0x2A)!\n"); +} + +/** + * Handles the trap 0x2B when Callback return service request occurs. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpHandleTrap2B(IN PKTRAP_FRAME TrapFrame) +{ + DebugPrint(L"Unhandled Callback return service request (0x2B)!\n"); +} + +/** + * Handles the trap 0x2C when an assertion is raised. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpHandleTrap2C(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Assertion (0x2C)!\n"); for(;;); @@ -312,20 +526,26 @@ ArpHandleTrap2C(VOID) /** * Handles the trap 0x2D when a debug service is being requested. * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * * @return This routine does not return any value. * * @since XT 1.0 */ XTCDECL VOID -ArpHandleTrap2D(VOID) +ArpHandleTrap2D(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Debug-Service-Request (0x2D)!\n"); for(;;); } /** - * Handles the trap 0xFF then Unexpected Interrupt occurs. + * Handles the trap 0x2E when a system call is being requested. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. * * @return This routine does not return any value. * @@ -333,7 +553,24 @@ ArpHandleTrap2D(VOID) */ XTCDECL VOID -ArpHandleTrapFF(VOID) +ArpHandleTrap2E(IN PKTRAP_FRAME TrapFrame) +{ + DebugPrint(L"Unhandled system call (0x2E)!\n"); +} + +/** + * Handles the trap 0xFF then Unexpected Interrupt occurs. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common trap handler on the stack. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +ArpHandleTrapFF(IN PKTRAP_FRAME TrapFrame) { DebugPrint(L"Handled Unexpected-Interrupt (0xFF)!\n"); for(;;);