reactos/ntoskrnl/ke/i386
diff -u -r1.17 -r1.18
--- fpu.c 25 Nov 2004 13:22:54 -0000 1.17
+++ fpu.c 27 Nov 2004 16:12:26 -0000 1.18
@@ -1,4 +1,4 @@
-/* $Id: fpu.c,v 1.17 2004/11/25 13:22:54 blight Exp $
+/* $Id: fpu.c,v 1.18 2004/11/27 16:12:26 hbirr Exp $
*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
@@ -403,6 +403,44 @@
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.18 -r1.19
--- w32call.c 20 Nov 2004 23:46:37 -0000 1.18
+++ w32call.c 27 Nov 2004 16:12:26 -0000 1.19
@@ -1,4 +1,4 @@
-/* $Id: w32call.c,v 1.18 2004/11/20 23:46:37 blight Exp $
+/* $Id: w32call.c,v 1.19 2004/11/27 16:12:26 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -45,6 +45,7 @@
PKTRAP_FRAME SavedTrapFrame;
PVOID SavedCallbackStack;
PVOID SavedExceptionStack;
+ BYTE SavedNpxState;
} NTW32CALL_SAVED_STATE, *PNTW32CALL_SAVED_STATE;
typedef struct
@@ -83,6 +84,7 @@
PKTRAP_FRAME SavedTrapFrame;
PVOID SavedCallbackStack;
PVOID SavedExceptionStack;
+ BYTE SavedNpxState;
Thread = PsGetCurrentThread();
if (Thread->Tcb.CallbackStack == NULL)
@@ -105,7 +107,7 @@
SavedTrapFrame = State->SavedTrapFrame;
SavedCallbackStack = State->SavedCallbackStack;
SavedExceptionStack = State->SavedExceptionStack;
-
+ SavedNpxState = State->SavedNpxState;
/*
* Copy the callback status and the callback result to NtW32Call
*/
@@ -127,20 +129,14 @@
* Restore the old stack.
*/
KeRaiseIrql(HIGH_LEVEL, &oldIrql);
- 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));
- }
+ KiClearFloatingPointState(FALSE);
+ Thread->Tcb.NpxState = SavedNpxState;
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. */
@@ -243,6 +239,7 @@
}
return(NULL);
}
+ DPRINT1("KernelStack %x\n", KernelStack);
return(KernelStack);
}
@@ -288,9 +285,7 @@
AssignedStack = CONTAINING_RECORD(StackEntry, NTW32CALL_CALLBACK_STACK,
ListEntry);
NewStack = AssignedStack->BaseAddress;
-
- MmUpdatePageDir(PsGetCurrentProcess(), NewStack, StackSize);
-
+ memset(NewStack, 0, StackSize);
}
/* FIXME: Need to check whether we were interrupted from v86 mode. */
memcpy((char*)NewStack + StackSize - sizeof(KTRAP_FRAME) - sizeof(FX_SAVE_AREA),
@@ -316,17 +311,15 @@
SavedState.SavedTrapFrame = Thread->Tcb.TrapFrame;
SavedState.SavedCallbackStack = Thread->Tcb.CallbackStack;
SavedState.SavedExceptionStack = (PVOID)KeGetCurrentKPCR()->TSS->Esp0;
- 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));
- }
+
+ KiClearFloatingPointState(TRUE);
+
+ SavedState.SavedNpxState = Thread->Tcb.NpxState;
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);
/*