mirror of
https://github.com/reactos/reactos.git
synced 2025-04-04 20:50:41 +00:00
[NTOS]: Implement KiAdjustEsp0 in C.
[NTOS]: Temporarily remove FPU save/restore instructions since they seem to be smashing the stack and breaking boot. svn path=/trunk/; revision=45027
This commit is contained in:
parent
1ab6f5ad16
commit
f61b9c9113
3 changed files with 41 additions and 42 deletions
|
@ -807,41 +807,6 @@ NoNextThread:
|
|||
#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:
|
||||
|
|
|
@ -305,6 +305,40 @@ KiTagWordFnsaveToFxsave(USHORT TagWord)
|
|||
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
|
||||
NTAPI
|
||||
KeContextToTrapFrame(IN PCONTEXT Context,
|
||||
|
|
|
@ -270,11 +270,11 @@ KiNpxHandler(IN PKTRAP_FRAME TrapFrame,
|
|||
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 @@ KiNpxHandler(IN PKTRAP_FRAME TrapFrame,
|
|||
__writecr0(Cr0);
|
||||
|
||||
/* Save FPU state */
|
||||
Ke386SaveFpuState(SaveArea);
|
||||
//Ke386SaveFpuState(SaveArea);
|
||||
|
||||
/* Mark CR0 state dirty */
|
||||
Cr0 |= NPX_STATE_NOT_LOADED;
|
||||
|
@ -588,14 +588,14 @@ KiTrap7Handler(IN PKTRAP_FRAME TrapFrame)
|
|||
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 @@ KiTrap19Handler(IN PKTRAP_FRAME TrapFrame)
|
|||
__writecr0(Cr0);
|
||||
|
||||
/* Save FPU state */
|
||||
Ke386SaveFpuState(SaveArea);
|
||||
//Ke386SaveFpuState(SaveArea);
|
||||
|
||||
/* Mark CR0 state dirty */
|
||||
Cr0 |= NPX_STATE_NOT_LOADED;
|
||||
|
|
Loading…
Reference in a new issue