From 752c8aead96c5d248d0a436a2eeaf1768c05828a Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 30 Jan 2010 03:12:26 +0000 Subject: [PATCH] trap.S is now fully MASM/ML compatible svn path=/branches/ros-amd64-bringup/; revision=45336 --- reactos/ntoskrnl/ke/amd64/trap.S | 83 ++++++++++++++++---------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/reactos/ntoskrnl/ke/amd64/trap.S b/reactos/ntoskrnl/ke/amd64/trap.S index c2f82a9fea6..87bef6ff862 100644 --- a/reactos/ntoskrnl/ke/amd64/trap.S +++ b/reactos/ntoskrnl/ke/amd64/trap.S @@ -11,7 +11,7 @@ #include EXTERN _KiDispatchException:PROC -EXTERN _FrLdrDbgPrint:PROC +EXTERN _FrLdrDbgPrint:DWORD EXTERN _KeBugCheckWithTf:PROC EXTERN _MmAccessFault:PROC @@ -45,16 +45,16 @@ _MsgTrapInfo: .ascii "Trap: %s at %p\n\0" MACRO(TRAPINFO, func) +LOCAL label1, label2 #if 0 - jmp 2f - .equ expr, 12 -1: .asciz "\func" -2: + jmp label2 +label1: .asciz "\func" +label2: sub rsp, 32 lea rcx, RIP(_MsgTrapInfo) lea rdx, 1b[rip] mov r8, [rbp + KTRAP_FRAME_Rip] - call _FrLdrDbgPrint[rip] + call qword ptr RIP(_FrLdrDbgPrint) add rsp, 32 #endif ENDM @@ -86,6 +86,7 @@ ENDM * ENTER_TRAP_FRAME - Allocate SIZE_KTRAP_FRAME and save registers to it */ MACRO(ENTER_TRAP_FRAME, Flags) +LOCAL dont_swap SIZE_INITIAL_FRAME = 7 * 8 SIZE_TRAP_FRAME_ALLOC = SIZE_KTRAP_FRAME - SIZE_INITIAL_FRAME TRAPFLAGS = VAL(Flags) @@ -145,9 +146,9 @@ endif mov ax, [rbp + KTRAP_FRAME_SegCs] and al, 1 mov [rbp + KTRAP_FRAME_PreviousMode], al - jz 1f + jz dont_swap swapgs -1: +dont_swap: /* Save previous irql */ mov rax, cr8 @@ -189,7 +190,7 @@ ENDM * LEAVE_TRAP_FRAME - Restore registers and free stack space */ MACRO(LEAVE_TRAP_FRAME) - +LOCAL dont_swap_back if (TRAPFLAGS AND TRAPFLAG_SEGMENTS) /* Restore segment selectors */ mov ax, [rbp + KTRAP_FRAME_SegDs] @@ -201,9 +202,9 @@ if (TRAPFLAGS AND TRAPFLAG_SEGMENTS) endif test byte ptr [rbp + KTRAP_FRAME_PreviousMode], 1 - jz 1f + jz dont_swap_back swapgs -1: +dont_swap_back: if (TRAPFLAGS AND TRAPFLAG_NONVOLATILES) /* Restore non-volatile registers */ @@ -330,7 +331,7 @@ _InternalDispatchException: PUBLIC _KiDivideErrorFault .PROC _KiDivideErrorFault - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -343,7 +344,7 @@ PUBLIC _KiDivideErrorFault PUBLIC _KiDebugTrapOrFault .PROC _KiDebugTrapOrFault - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -377,7 +378,7 @@ KiDebugTrapOrFaultKMode: PUBLIC _KiNmiInterrupt .PROC _KiNmiInterrupt - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -390,7 +391,7 @@ PUBLIC _KiNmiInterrupt PUBLIC _KiBreakpointTrap .PROC _KiBreakpointTrap - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -402,7 +403,7 @@ PUBLIC _KiBreakpointTrap // lea rcx, RIP(_MsgBreakpointTrap) // mov rdx, rsp -// call RIP(_FrLdrDbgPrint) +// call qword ptr RIP(_FrLdrDbgPrint) /* Dispatch the exception */ mov eax, STATUS_BREAKPOINT @@ -419,7 +420,7 @@ PUBLIC _KiBreakpointTrap PUBLIC _KiOverflowTrap .PROC _KiOverflowTrap - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -431,7 +432,7 @@ PUBLIC _KiOverflowTrap PUBLIC _KiBoundFault .PROC _KiBoundFault - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -450,7 +451,7 @@ PUBLIC _KiBoundFault PUBLIC _KiInvalidOpcodeFault .PROC _KiInvalidOpcodeFault - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -464,7 +465,7 @@ PUBLIC _KiInvalidOpcodeFault mov rdx, [rbp + KTRAP_FRAME_Rip] lea rcx, RIP(_MsgInvalidOpcodeFault) - call RIP(_FrLdrDbgPrint) + call qword ptr RIP(_FrLdrDbgPrint) jmp $ /* Return */ @@ -474,7 +475,7 @@ PUBLIC _KiInvalidOpcodeFault PUBLIC _KiNpxNotAvailableFault .PROC _KiNpxNotAvailableFault - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -487,7 +488,7 @@ PUBLIC _KiNpxNotAvailableFault PUBLIC _KiDoubleFaultAbort .PROC _KiDoubleFaultAbort - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -498,7 +499,7 @@ PUBLIC _KiDoubleFaultAbort lea rcx, RIP(_MsgDoubleFault) mov rdx, [rbp + KTRAP_FRAME_FaultAddress] mov r8, rbp - call RIP(_FrLdrDbgPrint) + call qword ptr RIP(_FrLdrDbgPrint) /* Bugcheck code UNEXPECTED_KERNEL_MODE_TRAP */ mov rcx, HEX(0000007F) @@ -516,7 +517,7 @@ PUBLIC _KiDoubleFaultAbort PUBLIC _KiNpxSegmentOverrunAbort .PROC _KiNpxSegmentOverrunAbort - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -529,7 +530,7 @@ PUBLIC _KiNpxSegmentOverrunAbort PUBLIC _KiInvalidTssFault .PROC _KiInvalidTssFault - .pushframe 1 + .pushframe code /* We have an error code */ .endprolog @@ -540,7 +541,7 @@ PUBLIC _KiInvalidTssFault PUBLIC _KiSegmentNotPresentFault .PROC _KiSegmentNotPresentFault - .pushframe 1 + .pushframe /* We have an error code */ .endprolog @@ -551,7 +552,7 @@ PUBLIC _KiSegmentNotPresentFault PUBLIC _KiStackFault .PROC _KiStackFault - .pushframe 1 + .pushframe code /* We have an error code */ .endprolog @@ -562,7 +563,7 @@ PUBLIC _KiStackFault PUBLIC _KiGeneralProtectionFault .PROC _KiGeneralProtectionFault - .pushframe 1 + .pushframe code /* We have an error code */ .endprolog @@ -573,7 +574,7 @@ PUBLIC _KiGeneralProtectionFault mov rdx, [rbp + KTRAP_FRAME_Rip] lea rcx, RIP(_MsgGeneralProtFault) - call RIP(_FrLdrDbgPrint) + call qword ptr RIP(_FrLdrDbgPrint) /* Check if this was from user-mode */ cmp byte ptr [rbp + KTRAP_FRAME_PreviousMode], KernelMode @@ -675,7 +676,7 @@ KiGpfExit: PUBLIC _KiPageFault .PROC _KiPageFault - .pushframe 1 + .pushframe code /* We have an error code */ .endprolog @@ -688,7 +689,7 @@ PUBLIC _KiPageFault mov rdx, [rbp + KTRAP_FRAME_ErrorCode] mov r8, [rbp + KTRAP_FRAME_Rip] mov r9, [rbp + KTRAP_FRAME_FaultAddress] - call RIP(_FrLdrDbgPrint) + call qword ptr RIP(_FrLdrDbgPrint) #endif /* Save page fault address */ @@ -745,7 +746,7 @@ PageFaultReturn: PUBLIC _KiFloatingErrorFault .PROC _KiFloatingErrorFault - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -758,7 +759,7 @@ PUBLIC _KiFloatingErrorFault PUBLIC _KiAlignmentFault .PROC _KiAlignmentFault - .pushframe 1 + .pushframe code /* We have an error code */ .endprolog @@ -769,7 +770,7 @@ PUBLIC _KiAlignmentFault PUBLIC _KiMcheckAbort .PROC _KiMcheckAbort - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -782,7 +783,7 @@ PUBLIC _KiMcheckAbort PUBLIC _KiXmmException .PROC _KiXmmException - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -795,7 +796,7 @@ PUBLIC _KiXmmException PUBLIC _KiApcInterrupt .PROC _KiApcInterrupt - .pushframe 1 + .pushframe code .endprolog UNIMPLEMENTED KiApcInterrupt @@ -805,7 +806,7 @@ PUBLIC _KiApcInterrupt PUBLIC _KiRaiseAssertion .PROC _KiRaiseAssertion - .pushframe 1 + .pushframe code .endprolog UNIMPLEMENTED KiRaiseAssertion @@ -815,7 +816,7 @@ PUBLIC _KiRaiseAssertion PUBLIC _KiDebugServiceTrap .PROC _KiDebugServiceTrap - .pushframe 0 + .pushframe /* Push pseudo error code */ push 0 .allocstack 8 @@ -842,7 +843,7 @@ PUBLIC _KiDebugServiceTrap PUBLIC _KiDpcInterrupt .PROC _KiDpcInterrupt - .pushframe 1 + .pushframe code .endprolog UNIMPLEMENTED KiDpcInterrupt @@ -852,7 +853,7 @@ PUBLIC _KiDpcInterrupt PUBLIC _KiIpiInterrupt .PROC _KiIpiInterrupt - .pushframe 1 + .pushframe code .endprolog UNIMPLEMENTED KiIpiInterrupt @@ -862,7 +863,7 @@ PUBLIC _KiIpiInterrupt PUBLIC _KiUnexpectedInterrupt .PROC _KiUnexpectedInterrupt - .pushframe 0 + .pushframe .endprolog /* The error code is the vector */