We can simplify a lot of things now that we don't have to worry about

hardware bugs on external 386 cpus and now that we can depend on SSE.
This commit is contained in:
Peter Wemm 2004-01-28 23:55:58 +00:00
parent d957532a87
commit 1c89210c83
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125177
2 changed files with 9 additions and 43 deletions

View File

@ -112,26 +112,17 @@ static bool_t fpu_cleanstate_ready;
* Initialize floating point unit.
*/
void
fpuinit()
fpuinit(void)
{
register_t savecrit;
u_short control;
/*
* fpusave() initializes the fpu and sets fpcurthread = NULL
*/
savecrit = intr_disable();
fpusave(&fpu_cleanstate); /* XXX borrow for now */
PCPU_SET(fpcurthread, 0);
stop_emulating();
/* XXX fpusave() doesn't actually initialize the fpu in the SSE case. */
fninit();
control = __INITIAL_FPUCW__;
fldcw(&control);
start_emulating();
intr_restore(savecrit);
savecrit = intr_disable();
stop_emulating();
fxsave(&fpu_cleanstate);
start_emulating();
fpu_cleanstate_ready = 1;
@ -147,8 +138,12 @@ fpuexit(struct thread *td)
register_t savecrit;
savecrit = intr_disable();
if (curthread == PCPU_GET(fpcurthread))
fpusave(&PCPU_GET(curpcb)->pcb_save);
if (curthread == PCPU_GET(fpcurthread)) {
stop_emulating();
fxsave(&PCPU_GET(curpcb)->pcb_save);
start_emulating();
PCPU_SET(fpcurthread, 0);
}
intr_restore(savecrit);
}
@ -422,41 +417,13 @@ fpudna()
control = __INITIAL_FPUCW__;
fldcw(&control);
pcb->pcb_flags |= PCB_FPUINITDONE;
} else {
/*
* The following frstor may cause a trap when the state
* being restored has a pending error. The error will
* appear to have been triggered by the current (fpu) user
* instruction even when that instruction is a no-wait
* instruction that should not trigger an error (e.g.,
* instructions are broken the same as frstor, so our
* treatment does not amplify the breakage.
*/
} else
fxrstor(&pcb->pcb_save);
}
intr_restore(s);
return (1);
}
/*
* Wrapper for fnsave instruction.
*
* fpusave() must be called with interrupts disabled, so that it clears
* fpcurthread atomically with saving the state. We require callers to do the
* disabling, since most callers need to disable interrupts anyway to call
* fpusave() atomically with checking fpcurthread.
*/
void
fpusave(struct savefpu *addr)
{
stop_emulating();
fxsave(addr);
start_emulating();
PCPU_SET(fpcurthread, NULL);
}
/*
* This should be called with interrupts disabled and only when the owning
* FPU thread is non-null.

View File

@ -106,7 +106,6 @@ void fpuexit(struct thread *td);
int fpuformat(void);
int fpugetregs(struct thread *td, struct savefpu *addr);
void fpuinit(void);
void fpusave(struct savefpu *addr);
void fpusetregs(struct thread *td, struct savefpu *addr);
int fputrap(void);
#endif