summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2004-01-28 23:55:58 +0000
committerpeter <peter@FreeBSD.org>2004-01-28 23:55:58 +0000
commit57db6c445100947cf58e4b7225c270308162951b (patch)
tree5ab8f0b40713922ef486ad13fa3305d9bed7c8cd /sys/amd64
parent5e45c69f41132d5a819ecab326491bcbd30b567d (diff)
downloadFreeBSD-src-57db6c445100947cf58e4b7225c270308162951b.zip
FreeBSD-src-57db6c445100947cf58e4b7225c270308162951b.tar.gz
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.
Diffstat (limited to 'sys/amd64')
-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 c5197b6..3e5d3ea 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 7c79912..8b6e1f9 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
OpenPOWER on IntegriCloud