Initialisation of debugging and floating point registers in

PsBeginThread*.

svn path=/trunk/; revision=3504
This commit is contained in:
guido 2002-09-15 13:49:57 +00:00
parent 2b22998369
commit c9aa7a8462
4 changed files with 62 additions and 35 deletions

View file

@ -20,7 +20,9 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_FPU_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_FPU_H
#define __NTOSKRNL_INCLUDE_INTERNAL_I386_FPU_H #define __NTOSKRNL_INCLUDE_INTERNAL_I386_FPU_H
VOID extern ULONG HardwareMathSupport;
VOID
KiCheckFPU(VOID); KiCheckFPU(VOID);
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_FPU_H */ #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_FPU_H */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: bthread.S,v 1.5 2002/09/08 10:23:29 chorns Exp $ /* $Id: bthread.S,v 1.6 2002/09/15 13:49:57 guido Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -38,10 +38,10 @@
* *
*/ */
.globl _PsBeginThreadWithContextInternal .globl _PsBeginThreadWithContextInternal
.globl _PsBeginThread .globl _PsBeginThread
_PsBeginThread: _PsBeginThread:
/* /*
* This isn't really a function, we are called as the return address * This isn't really a function, we are called as the return address
* of the context switch function * of the context switch function
@ -52,6 +52,25 @@ _PsBeginThread:
*/ */
call _PiBeforeBeginThread call _PiBeforeBeginThread
/*
* Initialize debugging registers
*/
movl $0, %eax /* set to 0 */
movl %eax, %dr0
movl %eax, %dr1
movl %eax, %dr2
movl %eax, %dr3
movl %eax, %dr6
movl %eax, %dr7
/*
* Initialize floating point registers
*/
movl (_HardwareMathSupport), %eax
jz nofpu
fninit
nofpu:
/* /*
* Call the actual start of the thread * Call the actual start of the thread
*/ */
@ -74,41 +93,51 @@ _PsBeginThread:
pushl $0 pushl $0
call _KeBugCheck@4 call _KeBugCheck@4
addl $4, %esp addl $4, %esp
/* /*
* And if that fails then loop * And if that fails then loop
*/ */
.1: .1:
jmp .1 jmp .1
_PsBeginThreadWithContextInternal: _PsBeginThreadWithContextInternal:
/* /*
* This isn't really a function, we are called as the return * This isn't really a function, we are called as the return
* address of a context switch * address of a context switch
*/ */
/* /*
* Do the necessary prolog before the context switch * Do the necessary prolog before the context switch
*/ */
call _PiBeforeBeginThread call _PiBeforeBeginThread
/* FIXME: Don't ignore the debugging registers. */
popl %eax /* Dr0 */
popl %eax /* Dr1 */
popl %eax /* Dr2 */
popl %eax /* Dr3 */
popl %eax /* Dr6 */
popl %eax /* Dr7 */
/* FIXME: Don't ignore the floating point registers. */ /*
addl $112,%esp /* FloatSave */ * Load the debugging registers
*/
popl %eax /* Dr0 */
movl %eax, %dr0
popl %eax /* Dr1 */
movl %eax, %dr1
popl %eax /* Dr2 */
movl %eax, %dr2
popl %eax /* Dr3 */
movl %eax, %dr3
popl %eax /* Dr6 */
movl %eax, %dr6
popl %eax /* Dr7 */
movl %eax, %dr7
/*
* Load the floating point registers
*/
movl (_HardwareMathSupport), %eax
jz nofpu2
frstor 0(%esp)
nofpu2:
addl $4, %esp
/* Load the rest of the thread's user mode context. */ /* Load the rest of the thread's user mode context. */
movl $0,%eax movl $0, %eax
jmp KeReturnFromSystemCallWithHook jmp KeReturnFromSystemCallWithHook

View file

@ -37,7 +37,7 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static ULONG HardwareMathSupport; ULONG HardwareMathSupport;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/

View file

@ -103,8 +103,8 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
/* /*
* Setup a stack frame for exit from the task switching routine * Setup a stack frame for exit from the task switching routine
*/ */
InitSize = 5 * sizeof(DWORD) + 6 * sizeof(DWORD) + InitSize = 5 * sizeof(DWORD) + 6 * sizeof(DWORD) +
sizeof(FLOATING_SAVE_AREA) + sizeof(KTRAP_FRAME); sizeof(FLOATING_SAVE_AREA) + sizeof(KTRAP_FRAME);
KernelStack = (PULONG)(Thread->KernelStack - InitSize); KernelStack = (PULONG)(Thread->KernelStack - InitSize);
@ -124,12 +124,10 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
KernelStack[10] = Context->Dr7; KernelStack[10] = Context->Dr7;
/* Set up the initial floating point state. */ /* Set up the initial floating point state. */
memcpy((PVOID)&KernelStack[11], (PVOID)&Context->FloatSave, KernelStack[11] = (ULONG)&Context->FloatSave;
sizeof(FLOATING_SAVE_AREA));
/* Set up a trap frame from the context. */ /* Set up a trap frame from the context. */
TrapFrame = (PKTRAP_FRAME) TrapFrame = (PKTRAP_FRAME)((PBYTE)KernelStack + 12 * sizeof(DWORD));
((PBYTE)KernelStack + 11 * sizeof(DWORD) + sizeof(FLOATING_SAVE_AREA));
TrapFrame->DebugEbp = (PVOID)Context->Ebp; TrapFrame->DebugEbp = (PVOID)Context->Ebp;
TrapFrame->DebugEip = (PVOID)Context->Eip; TrapFrame->DebugEip = (PVOID)Context->Eip;
TrapFrame->DebugArgMark = 0; TrapFrame->DebugArgMark = 0;
@ -163,8 +161,8 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context)
} }
NTSTATUS NTSTATUS
Ke386InitThread(PKTHREAD Thread, Ke386InitThread(PKTHREAD Thread,
PKSTART_ROUTINE StartRoutine, PKSTART_ROUTINE StartRoutine,
PVOID StartContext) PVOID StartContext)
/* /*
* Initialize a thread * Initialize a thread
@ -177,8 +175,6 @@ Ke386InitThread(PKTHREAD Thread,
*/ */
KernelStack = (PULONG)(Thread->KernelStack - (8*4)); KernelStack = (PULONG)(Thread->KernelStack - (8*4));
/* FIXME: Add initial floating point information */
/* FIXME: Add initial debugging information */
KernelStack[0] = 0; /* EDI */ KernelStack[0] = 0; /* EDI */
KernelStack[1] = 0; /* ESI */ KernelStack[1] = 0; /* ESI */
KernelStack[2] = 0; /* EBX */ KernelStack[2] = 0; /* EBX */