reactos/ntoskrnl/ke/i386
diff -u -r1.18 -r1.19
--- fpu.c 27 Nov 2004 16:12:26 -0000 1.18
+++ fpu.c 27 Nov 2004 23:50:26 -0000 1.19
@@ -1,4 +1,4 @@
-/* $Id: fpu.c,v 1.18 2004/11/27 16:12:26 hbirr Exp $
+/* $Id: fpu.c,v 1.19 2004/11/27 23:50:26 hbirr Exp $
*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
@@ -403,44 +403,6 @@
return STATUS_SUCCESS;
}
-VOID
-KiClearFloatingPointState(BOOLEAN Save)
-{
- PKTHREAD CurrentThread;
- PFX_SAVE_AREA FxSaveArea;
-
- ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
-
- CurrentThread = KeGetCurrentThread();
-
- if (CurrentThread->NpxState & NPX_STATE_DIRTY)
- {
- if (Save)
- {
- FxSaveArea = (PFX_SAVE_AREA)((char *)CurrentThread->InitialStack - sizeof (FX_SAVE_AREA));
- if (FxsrSupport)
- {
- asm volatile("fxsave %0" : : "m"(FxSaveArea->U.FxArea));
- }
- else
- {
- asm volatile("fnsave %0" : : "m"(FxSaveArea->U.FnArea));
- }
- CurrentThread->NpxState = NPX_STATE_VALID;
- }
- else
- {
- CurrentThread->NpxState = NPX_STATE_INVALID;
- }
- Ke386SetCr0(Ke386GetCr0() | X86_CR0_TS);
- }
- if (KeGetCurrentKPCR()->PrcbData.NpxThread == CurrentThread)
- {
- KeGetCurrentKPCR()->PrcbData.NpxThread = NULL;
- }
-}
-
-
NTSTATUS
KiHandleFpuFault(PKTRAP_FRAME Tf, ULONG ExceptionNr)
{
reactos/ntoskrnl/ps
diff -u -r1.19 -r1.20
--- w32call.c 27 Nov 2004 16:12:26 -0000 1.19
+++ w32call.c 27 Nov 2004 23:50:27 -0000 1.20
@@ -1,4 +1,4 @@
-/* $Id: w32call.c,v 1.19 2004/11/27 16:12:26 hbirr Exp $
+/* $Id: w32call.c,v 1.20 2004/11/27 23:50:27 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -45,7 +45,6 @@
PKTRAP_FRAME SavedTrapFrame;
PVOID SavedCallbackStack;
PVOID SavedExceptionStack;
- BYTE SavedNpxState;
} NTW32CALL_SAVED_STATE, *PNTW32CALL_SAVED_STATE;
typedef struct
@@ -84,7 +83,6 @@
PKTRAP_FRAME SavedTrapFrame;
PVOID SavedCallbackStack;
PVOID SavedExceptionStack;
- BYTE SavedNpxState;
Thread = PsGetCurrentThread();
if (Thread->Tcb.CallbackStack == NULL)
@@ -107,7 +105,7 @@
SavedTrapFrame = State->SavedTrapFrame;
SavedCallbackStack = State->SavedCallbackStack;
SavedExceptionStack = State->SavedExceptionStack;
- SavedNpxState = State->SavedNpxState;
+
/*
* Copy the callback status and the callback result to NtW32Call
*/
@@ -129,14 +127,20 @@
* Restore the old stack.
*/
KeRaiseIrql(HIGH_LEVEL, &oldIrql);
- KiClearFloatingPointState(FALSE);
- Thread->Tcb.NpxState = SavedNpxState;
+ if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
+ ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentKPCR()->PrcbData.NpxThread)
+ {
+ memcpy((char*)InitialStack - sizeof(FX_SAVE_AREA),
+ (char*)Thread->Tcb.InitialStack - sizeof(FX_SAVE_AREA),
+ sizeof(FX_SAVE_AREA));
+ }
Thread->Tcb.InitialStack = InitialStack;
Thread->Tcb.StackBase = StackBase;
Thread->Tcb.StackLimit = StackLimit;
Thread->Tcb.TrapFrame = SavedTrapFrame;
Thread->Tcb.CallbackStack = SavedCallbackStack;
KeGetCurrentKPCR()->TSS->Esp0 = (ULONG)SavedExceptionStack;
+ Ke386SetCr0(Ke386GetCr0() | X86_CR0_TS); /* set TS */
KeStackSwitchAndRet((PVOID)(OldStack + 1));
/* Should never return. */
@@ -239,7 +243,6 @@
}
return(NULL);
}
- DPRINT1("KernelStack %x\n", KernelStack);
return(KernelStack);
}
@@ -311,15 +314,17 @@
SavedState.SavedTrapFrame = Thread->Tcb.TrapFrame;
SavedState.SavedCallbackStack = Thread->Tcb.CallbackStack;
SavedState.SavedExceptionStack = (PVOID)KeGetCurrentKPCR()->TSS->Esp0;
-
- KiClearFloatingPointState(TRUE);
-
- SavedState.SavedNpxState = Thread->Tcb.NpxState;
+ if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
+ ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentKPCR()->PrcbData.NpxThread)
+ {
+ memcpy((char*)NewStack + StackSize - sizeof(FX_SAVE_AREA),
+ (char*)SavedState.SavedInitialStack - sizeof(FX_SAVE_AREA),
+ sizeof(FX_SAVE_AREA));
+ }
Thread->Tcb.InitialStack = Thread->Tcb.StackBase = (char*)NewStack + StackSize;
Thread->Tcb.StackLimit = (ULONG)NewStack;
Thread->Tcb.KernelStack = (char*)NewStack + StackSize - sizeof(KTRAP_FRAME) - sizeof(FX_SAVE_AREA);
KeGetCurrentKPCR()->TSS->Esp0 = (ULONG)Thread->Tcb.InitialStack - sizeof(FX_SAVE_AREA);
- Thread->Tcb.NpxState = NPX_STATE_INVALID;
KePushAndStackSwitchAndSysRet((ULONG)&SavedState, Thread->Tcb.KernelStack);
/*