aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2004-01-28 23:55:58 +0000
committerPeter Wemm <peter@FreeBSD.org>2004-01-28 23:55:58 +0000
commit1c89210c83723136ed7d044da8802765fa85d7ff (patch)
tree5ab8f0b40713922ef486ad13fa3305d9bed7c8cd /sys
parentd957532a87a1d41aed4f52836faf6539d3133840 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/fpu.c51
-rw-r--r--sys/amd64/include/fpu.h1
2 files changed, 9 insertions, 43 deletions
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index c5197b63c23a..3e5d3ea91f87 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -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,42 +417,14 @@ 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.
*/
diff --git a/sys/amd64/include/fpu.h b/sys/amd64/include/fpu.h
index 7c79912102d0..8b6e1f9ca9a6 100644
--- a/sys/amd64/include/fpu.h
+++ b/sys/amd64/include/fpu.h
@@ -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