Author: sir_richard
Date: Mon Jan 11 19:26:46 2010
New Revision: 45046
URL:
http://svn.reactos.org/svn/reactos?rev=45046&view=rev
Log:
[NTOS]: Switch to a slightly (perhaps, hopefully?) safer version of V86 entry/exit to see
if this fixes the buildbot boot (suffice it to say, the original code works fine on my
test machine, but since half the developers seem to be using GCC 4.4 and the others GCC
4.1, I wouldn't be surprised if there's compiler subtleties involved).
Modified:
trunk/reactos/ntoskrnl/include/internal/i386/ke.h
trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
trunk/reactos/ntoskrnl/ke/i386/v86vdm.c
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Mon Jan 11 19:26:46
2010
@@ -410,6 +410,12 @@
);
VOID
+FASTCALL
+Ki386BiosCallReturnAddress(
+ IN PKTRAP_FRAME TrapFrame
+);
+
+ULONG_PTR
FASTCALL
KiExitV86Mode(
IN PKTRAP_FRAME TrapFrame
@@ -442,7 +448,6 @@
extern VOID __cdecl CopyParams(VOID);
extern VOID __cdecl ReadBatch(VOID);
extern VOID __cdecl FrRestore(VOID);
-extern VOID Ki386BiosCallReturnAddress(VOID);
PFX_SAVE_AREA
FORCEINLINE
Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/ctxswitch…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S [iso-8859-1] Mon Jan 11 19:26:46 2010
@@ -871,6 +871,19 @@
/* Enter V8086 mode */
pushad
- call @KiEnterV86Mode@0
+ sub esp, (12 + KTRAP_FRAME_LENGTH + NPX_FRAME_LENGTH)
+ mov ecx, esp
+ call @KiEnterV86Mode@4
+ jmp $
.endfunc
+.globl @Ki386BiosCallReturnAddress@4
+@Ki386BiosCallReturnAddress@4:
+
+ /* Exit V8086 mode */
+ call @KiExitV86Mode@4
+ mov esp, eax
+ add esp, (12 + KTRAP_FRAME_LENGTH + NPX_FRAME_LENGTH)
+ popad
+ ret
+
Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Mon Jan 11 19:26:46 2010
@@ -1255,11 +1255,11 @@
* Why? Because part of the trap frame actually corresponds to the IRET
* stack during the trap exit!
*/
- if ((TrapFrame->HardwareEsp == (ULONG)KiExitV86Mode) &&
+ if ((TrapFrame->HardwareEsp == (ULONG)Ki386BiosCallReturnAddress)
&&
(TrapFrame->HardwareSegSs == (KGDT_R0_CODE | RPL_MASK)))
{
/* Exit the V86 trap! */
- KiExitV86Mode(TrapFrame);
+ Ki386BiosCallReturnAddress(TrapFrame);
}
else
{
Modified: trunk/reactos/ntoskrnl/ke/i386/v86vdm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/v86vdm.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/v86vdm.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/v86vdm.c [iso-8859-1] Mon Jan 11 19:26:46 2010
@@ -429,7 +429,7 @@
return KiVdmHandleOpcode(TrapFrame, 1);
}
-VOID
+ULONG_PTR
FASTCALL
KiExitV86Mode(IN PKTRAP_FRAME TrapFrame)
{
@@ -468,17 +468,15 @@
/* Enable interrupts and get back to protected mode */
_enable();
- KiV86TrapReturn(TrapFrame->Edi);
+ return TrapFrame->Edi;
}
VOID
FASTCALL
-KiEnterV86Mode(VOID)
+KiEnterV86Mode(IN PKV8086_STACK_FRAME StackFrame)
{
PKTHREAD Thread;
PKGDTENTRY GdtEntry;
- KV8086_STACK_FRAME StackFrameBuffer;
- PKV8086_STACK_FRAME StackFrame = &StackFrameBuffer;
PKTRAP_FRAME TrapFrame = &StackFrame->TrapFrame;
PKV86_FRAME V86Frame = &StackFrame->V86Frame;
PFX_SAVE_AREA NpxFrame = &StackFrame->NpxArea;
@@ -497,7 +495,7 @@
V86Frame->PcrTeb = KeGetPcr()->Tib.Self;
/* Save return EIP */
- TrapFrame->Eip = (ULONG_PTR)KiExitV86Mode;
+ TrapFrame->Eip = (ULONG_PTR)Ki386BiosCallReturnAddress;
/* Save our stack (after the frames) */
TrapFrame->Esi = (ULONG_PTR)V86Frame;