Initialize the MXCSR to the appropriate default value at startup.

Tested on:	tjr
This commit is contained in:
David Schultz 2004-06-05 03:13:39 +00:00
parent 7d7cd407cb
commit ad070467cd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130105

View File

@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#define fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
#define fxrstor(addr) __asm("fxrstor %0" : : "m" (*(addr)))
#define fxsave(addr) __asm __volatile("fxsave %0" : "=m" (*(addr)))
#define ldmxcsr(r) __asm __volatile("ldmxcsr %0" : : "m" (r))
#define start_emulating() __asm("smsw %%ax; orb %0,%%al; lmsw %%ax" \
: : "n" (CR0_TS) : "ax")
#define stop_emulating() __asm("clts")
@ -111,6 +112,7 @@ void
fpuinit(void)
{
register_t savecrit;
u_int mxcsr;
u_short control;
savecrit = intr_disable();
@ -119,6 +121,8 @@ fpuinit(void)
fninit();
control = __INITIAL_FPUCW__;
fldcw(&control);
mxcsr = __INITIAL_MXCSR__;
ldmxcsr(mxcsr);
fxsave(&fpu_cleanstate);
start_emulating();
fpu_cleanstate_ready = 1;