Author: sir_richard
Date: Sun Jan 10 15:32:19 2010
New Revision: 45027
URL:
http://svn.reactos.org/svn/reactos?rev=45027&view=rev
Log:
[NTOS]: Implement KiAdjustEsp0 in C.
[NTOS]: Temporarily remove FPU save/restore instructions since they seem to be smashing
the stack and breaking boot.
Modified:
trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
trunk/reactos/ntoskrnl/ke/i386/exp.c
trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
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] Sun Jan 10 15:32:19 2010
@@ -807,41 +807,6 @@
#endif
.endfunc
-.globl _Ki386AdjustEsp0@4
-.func Ki386AdjustEsp0@4
-_Ki386AdjustEsp0@4:
-
- /* Get the current thread */
- mov eax, [fs:KPCR_CURRENT_THREAD]
-
- /* Get trap frame and stack */
- mov edx, [esp+4]
- mov eax, [eax+KTHREAD_INITIAL_STACK]
-
- /* Check if V86 */
- test dword ptr [edx+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
- jnz 1f
-
- /* Bias the stack */
- sub eax, KTRAP_FRAME_V86_GS - KTRAP_FRAME_SS
-
-1:
- /* Skip FX Save Area */
- sub eax, SIZEOF_FX_SAVE_AREA
-
- /* Disable interrupts */
- pushf
- cli
-
- /* Adjust ESP0 */
- mov edx, [fs:KPCR_TSS]
- mov ss:[edx+KTSS_ESP0], eax
-
- /* Enable interrupts and return */
- popf
- ret 4
-.endfunc
-
.globl _KiSwapProcess@8
.func KiSwapProcess@8
_KiSwapProcess@8:
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/exp.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/exp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/exp.c [iso-8859-1] Sun Jan 10 15:32:19 2010
@@ -303,6 +303,40 @@
FxTagWord = (FxTagWord | (FxTagWord >> 2)) & 0x0f0f; /* 0000VVVV0000VVVV
*/
FxTagWord = (FxTagWord | (FxTagWord >> 4)) & 0x00ff; /* 00000000VVVVVVVV
*/
return FxTagWord;
+}
+
+VOID
+NTAPI
+Ki386AdjustEsp0(IN PKTRAP_FRAME TrapFrame)
+{
+ PKTHREAD Thread;
+ ULONG_PTR Stack;
+ ULONG EFlags;
+
+ /* Get the current thread's stack */
+ Thread = KeGetCurrentThread();
+ Stack = (ULONG_PTR)Thread->InitialStack;
+
+ /* Check if we are in V8086 mode */
+ if (!(TrapFrame->EFlags & EFLAGS_V86_MASK))
+ {
+ /* Bias the stack for the V86 segments */
+ Stack -= (FIELD_OFFSET(KTRAP_FRAME, V86Gs) -
+ FIELD_OFFSET(KTRAP_FRAME, HardwareSegSs));
+ }
+
+ /* Bias the stack for the FPU area */
+ Stack -= sizeof(FX_SAVE_AREA);
+
+ /* Disable interrupts */
+ EFlags = __readeflags();
+ _disable();
+
+ /* Set new ESP0 value in the TSS */
+ KeGetPcr()->TSS->Esp0 = Stack;
+
+ /* Restore old interrupt state */
+ __writeeflags(EFlags);
}
VOID
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] Sun Jan 10 15:32:19 2010
@@ -270,11 +270,11 @@
SaveArea->Cr0NpxState |= CR0_TS;
/* Only valid if it happened during a restore */
- if ((PVOID)TrapFrame->Eip == FrRestore)
+ //if ((PVOID)TrapFrame->Eip == FrRestore)
{
/* It did, so just skip the instruction */
- TrapFrame->Eip += 3; /* sizeof(FRSTOR) */
- KiEoiHelper(TrapFrame);
+ //TrapFrame->Eip += 3; /* sizeof(FRSTOR) */
+ //KiEoiHelper(TrapFrame);
}
}
@@ -287,7 +287,7 @@
__writecr0(Cr0);
/* Save FPU state */
- Ke386SaveFpuState(SaveArea);
+ //Ke386SaveFpuState(SaveArea);
/* Mark CR0 state dirty */
Cr0 |= NPX_STATE_NOT_LOADED;
@@ -588,14 +588,14 @@
NpxSaveArea = KiGetThreadNpxArea(NpxThread);
/* Save FPU state */
- Ke386SaveFpuState(NpxSaveArea);
+ //Ke386SaveFpuState(NpxSaveArea);
/* Update NPX state */
Thread->NpxState = NPX_STATE_NOT_LOADED;
}
/* Load FPU state */
- Ke386LoadFpuState(SaveArea);
+ //Ke386LoadFpuState(SaveArea);
/* Update NPX state */
Thread->NpxState = NPX_STATE_LOADED;
@@ -925,7 +925,7 @@
__writecr0(Cr0);
/* Save FPU state */
- Ke386SaveFpuState(SaveArea);
+ //Ke386SaveFpuState(SaveArea);
/* Mark CR0 state dirty */
Cr0 |= NPX_STATE_NOT_LOADED;