Author: ros-arm-bringup
Date: Fri Jan 1 22:03:22 2010
New Revision: 44861
URL:
http://svn.reactos.org/svn/reactos?rev=44861&view=rev
Log:
NMI Support Patch 7:
[NTOS]: Improve UNHANDLED_PATH macro with a new "Reason" parameter which
displays why the path is unhandled (ie: what the unexpected/unlikely/untested scenario
is). This is better than just displaying the current PC which is typically useless.
[NTOS]: Separate UNHANDLED_PATH from UNHANDLED_V86_PATH which is specifically for
paths that are unimplemented due to lack of VDM support.
[HAL]: Update to new macros in V8086 support, and handle invalid opcode errors with a
debug print (I encountered these when the NMI TSS was being used, since the IOPM was
invalid).
[HAL]: If the V8086 GPF handler is called outside of V8086 mode, assume an NMI
happened around the BIOS Call and just spin forever. We'll piggyback on the V8086 GPF
handler during an NMI, in order to avoid the kernel's GPF handler which would attempt
to panic/reset the display again (and cause endless NMI recursion/corruption).
Modified:
trunk/reactos/hal/halx86/generic/v86.s
trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
trunk/reactos/ntoskrnl/ke/i386/trap.s
Modified: trunk/reactos/hal/halx86/generic/v86.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/v86.s?r…
==============================================================================
--- trunk/reactos/hal/halx86/generic/v86.s [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/v86.s [iso-8859-1] Fri Jan 1 22:03:22 2010
@@ -34,8 +34,14 @@
_HalpSavedEsp:
.long 0
+_InvalidMsg:
+ .asciz "HAL: An invalid V86 opcode was encountered at address %x:%x\n"
+
+_InvalidGpfMsg:
+ .asciz "HAL: Trap0D while not in V86 mode\n"
+
_UnhandledMsg:
- .asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx!!!\n"
+ .asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx [%s]!!!\n"
/* FUNCTIONS *****************************************************************/
@@ -143,8 +149,15 @@
.func HalpOpcodeInvalid@0
_HalpOpcodeInvalid@0:
- /* Unhandled */
- UNHANDLED_PATH
+ /* This should never happen -- is the IOPM damaged? */
+ push [esi+HALP_BIOS_FRAME_EIP]
+ push [esi+HALP_BIOS_FRAME_CS]
+ push offset _InvalidMsg
+ call _DbgPrint
+ add esp, 12
+
+ /* Break */
+ int 3
/* Nothing to return */
xor eax, eax
@@ -376,7 +389,7 @@
add esp, [eax+KTHREAD_INITIAL_STACK]
/* Switch to good stack segment */
- UNHANDLED_PATH
+ UNHANDLED_PATH "16-Bit Stack"
.endfunc
.globl _HalpTrap0D@0
@@ -391,8 +404,13 @@
test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
jnz DoDispatch
- /* Unhandled */
- UNHANDLED_PATH
+ /* This is weird -- but might happen during an NMI */
+ push offset _InvalidGpfMsg
+ call _DbgPrint
+ add esp, 4
+
+ /* Loop forever */
+ jmp $
DoDispatch:
/* Handle the opcode */
Modified: trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S [iso-8859-1] Fri Jan 1
22:03:22 2010
@@ -87,18 +87,47 @@
//
// @name UNHANDLED_PATH
//
-// This macro TODO
+// This macro prints out that the current code path is not expected yet
//
// @param None
//
// @remark None.
//
-.macro UNHANDLED_PATH
+.macro UNHANDLED_PATH Reason
+
+ /* Push reason */
+ push offset 1f
+
/* Get EIP */
call $+5
/* Print debug message */
push offset _UnhandledMsg
+ call _DbgPrint
+ add esp, 12
+
+ /* Loop indefinitely */
+ jmp $
+
+1:
+ .asciz \Reason
+.endm
+
+//
+// @name UNHANDLED_V86_PATH
+//
+// This macro prints out that the current code path is for unhandled VDM support
+//
+// @param None
+//
+// @remark None.
+//
+.macro UNHANDLED_V86_PATH
+ /* Get EIP */
+ call $+5
+
+ /* Print debug message */
+ push offset _V86UnhandledMsg
call _DbgPrint
add esp, 8
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] Fri Jan 1 22:03:22 2010
@@ -91,8 +91,11 @@
_UnexpectedMsg:
.asciz "\n\x7\x7!!! Unexpected Interrupt %02lx !!!\n"
+_V86UnhandledMsg:
+ .asciz "\n\x7\x7!!! Unhandled V8086 (VDM) support at line: %lx!!!\n"
+
_UnhandledMsg:
- .asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx!!!\n"
+ .asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx [%s]!!!\n"
_IsrTimeoutMsg:
.asciz "\n*** ISR at %lx took over .5 second\n"
@@ -133,7 +136,7 @@
_KiGetTickCount:
_KiCallbackReturn:
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_PATH "TickCount/Callback Interrupts\n"
.func KiSystemService
TRAP_FIXUPS kss_a, kss_t, DoNotFixupV86, DoNotFixupAbios
@@ -458,7 +461,7 @@
AbiosExit:
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_PATH "ABIOS Exit"
.func KiRaiseAssertion
TRAP_FIXUPS kira_a, kira_t, DoFixupV86, DoFixupAbios
@@ -697,7 +700,7 @@
_KiFixupFrame:
/* TODO: Routine to fixup a KTRAP_FRAME when faulting from a syscall. */
- UNHANDLED_PATH
+ UNHANDLED_PATH "Trap Frame Fixup"
.endfunc
.func KiTrap0
@@ -738,7 +741,7 @@
/* We don't support this yet! */
V86Int0:
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
.endfunc
.func KiTrap1
@@ -781,7 +784,7 @@
jz EnableInterrupts
/* We don't support VDM! */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
.endfunc
.globl _KiTrap2
@@ -847,7 +850,7 @@
jz EnableInterrupts3
/* We don't support VDM! */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
.endfunc
.func KiTrap4
@@ -888,7 +891,7 @@
/* We don't support this yet! */
V86Int4:
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
.endfunc
.func KiTrap5
@@ -933,7 +936,7 @@
/* We don't support this yet! */
V86Int5:
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
.endfunc
.func KiTrap6
@@ -949,7 +952,7 @@
VdmOpCodeFault:
/* Not yet supported (Invalid OPCODE from V86) */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
NotV86UD:
/* Push error code */
@@ -1025,7 +1028,7 @@
IsVdmOpcode:
/* Unhandled yet */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
/* Return to caller */
jmp _Kei386EoiHelper@0
@@ -1332,7 +1335,7 @@
jz HandleUserNpx
/* V86 NPX not handled */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
EmulationEnabled:
/* Did this come from kernel-mode? */
@@ -1499,7 +1502,7 @@
jnz NoReflect
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
NoReflect:
@@ -1540,7 +1543,7 @@
jae KmodeGpf
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_PATH "Double GPF"
/* Get the opcode and trap frame */
KmodeGpf:
@@ -1629,7 +1632,7 @@
MsrCheck:
/* FIXME: Handle RDMSR/WRMSR */
- UNHANDLED_PATH
+ UNHANDLED_PATH "RDMSR/WRMSR"
NotIretGpf:
@@ -1913,7 +1916,7 @@
DispatchV86Gpf:
/* FIXME */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
.endfunc
.func KiTrap14
@@ -2003,12 +2006,12 @@
jnz CheckVdmPf
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_PATH "SYSENTER Fault"
jmp _Kei386EoiHelper@0
SysCallCopyFault:
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_PATH "SYSENTER Fault"
jmp _Kei386EoiHelper@0
/* Check if the fault occured in a V86 mode */
@@ -2033,7 +2036,7 @@
VdmPF:
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
/* Save EIP and check what kind of status failure we got */
CheckStatus:
@@ -2067,7 +2070,7 @@
SlistFault:
/* FIXME: TODO */
- UNHANDLED_PATH
+ UNHANDLED_PATH "SLIST Fault"
IllegalState:
@@ -2083,7 +2086,7 @@
VdmAlertGpf:
/* FIXME: NOT SUPPORTED */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
HandleLockErrata:
@@ -2328,7 +2331,7 @@
V86Xmmi:
/* V86 XMMI not handled */
- UNHANDLED_PATH
+ UNHANDLED_V86_PATH
KernelXmmi:
/* Another weird situation */
@@ -2394,7 +2397,7 @@
add esp, [eax+KTHREAD_INITIAL_STACK]
/* Switch to good stack segment */
- UNHANDLED_PATH
+ UNHANDLED_PATH "16-Bit Stack"
.endfunc
/* UNEXPECTED INTERRUPT HANDLERS **********************************************/