summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa/npx.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-11-26 14:50:42 +0000
committerkib <kib@FreeBSD.org>2010-11-26 14:50:42 +0000
commit60c89c994a97c0fb5628378c9b8b98b4b6f96d32 (patch)
treeb2b70b68cc97d1e8a719368ec7e8475bd9afc7c0 /sys/i386/isa/npx.c
parentb2984c404f1844039344b6aa018d21ed4ee9d388 (diff)
downloadFreeBSD-src-60c89c994a97c0fb5628378c9b8b98b4b6f96d32.zip
FreeBSD-src-60c89c994a97c0fb5628378c9b8b98b4b6f96d32.tar.gz
Remove npxgetregs(), npxsetregs(), fpugetregs() and fpusetregs()
functions, they are unused. Remove 'user' from npxgetuserregs() etc. names. For {npx,fpu}{get,set}regs(), always use pcb->pcb_user_save for FPU context storage. This eliminates the need for ugly copying with overwrite of the newly added and reserved fields in ucontext on i386 to satisfy alignment requirements for fpusave() and fpurstor(). pc98 version was copied from i386. Suggested and reviewed by: bde Tested by: pho (i386 and amd64) MFC after: 1 week
Diffstat (limited to 'sys/i386/isa/npx.c')
-rw-r--r--sys/i386/isa/npx.c94
1 files changed, 22 insertions, 72 deletions
diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c
index 8d37562..9ec5d25 100644
--- a/sys/i386/isa/npx.c
+++ b/sys/i386/isa/npx.c
@@ -684,9 +684,7 @@ npxdna(void)
fpurstor(&npx_initialstate);
if (pcb->pcb_initial_npxcw != __INITIAL_NPXCW__)
fldcw(pcb->pcb_initial_npxcw);
- pcb->pcb_flags |= PCB_NPXINITDONE;
- if (PCB_USER_FPU(pcb))
- pcb->pcb_flags |= PCB_NPXUSERINITDONE;
+ npxuserinited(curthread);
} else {
/*
* The following fpurstor() may cause an IRQ13 when the
@@ -767,11 +765,12 @@ npxdrop()
}
/*
- * Get the state of the FPU without dropping ownership (if possible).
- * It returns the FPU ownership status.
+ * Get the user state of the FPU into pcb->pcb_user_save without
+ * dropping ownership (if possible). It returns the FPU ownership
+ * status.
*/
int
-npxgetregs(struct thread *td, union savefpu *addr)
+npxgetregs(struct thread *td)
{
struct pcb *pcb;
@@ -780,48 +779,15 @@ npxgetregs(struct thread *td, union savefpu *addr)
pcb = td->td_pcb;
if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) {
- bcopy(&npx_initialstate, addr, sizeof(npx_initialstate));
- SET_FPU_CW(addr, pcb->pcb_initial_npxcw);
- return (_MC_FPOWNED_NONE);
- }
- critical_enter();
- if (td == PCPU_GET(fpcurthread)) {
- fpusave(addr);
-#ifdef CPU_ENABLE_SSE
- if (!cpu_fxsr)
-#endif
- /*
- * fnsave initializes the FPU and destroys whatever
- * context it contains. Make sure the FPU owner
- * starts with a clean state next time.
- */
- npxdrop();
- critical_exit();
- return (_MC_FPOWNED_FPU);
- } else {
- critical_exit();
- bcopy(pcb->pcb_save, addr, sizeof(*addr));
+ bcopy(&npx_initialstate, &pcb->pcb_user_save,
+ sizeof(npx_initialstate));
+ SET_FPU_CW(&pcb->pcb_user_save, pcb->pcb_initial_npxcw);
+ npxuserinited(td);
return (_MC_FPOWNED_PCB);
}
-}
-
-int
-npxgetuserregs(struct thread *td, union savefpu *addr)
-{
- struct pcb *pcb;
-
- if (!hw_float)
- return (_MC_FPOWNED_NONE);
-
- pcb = td->td_pcb;
- if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) == 0) {
- bcopy(&npx_initialstate, addr, sizeof(npx_initialstate));
- SET_FPU_CW(addr, pcb->pcb_initial_npxcw);
- return (_MC_FPOWNED_NONE);
- }
critical_enter();
- if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) {
- fpusave(addr);
+ if (td == PCPU_GET(fpcurthread)) {
+ fpusave(&pcb->pcb_user_save);
#ifdef CPU_ENABLE_SSE
if (!cpu_fxsr)
#endif
@@ -835,42 +801,24 @@ npxgetuserregs(struct thread *td, union savefpu *addr)
return (_MC_FPOWNED_FPU);
} else {
critical_exit();
- bcopy(&pcb->pcb_user_save, addr, sizeof(*addr));
return (_MC_FPOWNED_PCB);
}
}
-/*
- * Set the state of the FPU.
- */
void
-npxsetregs(struct thread *td, union savefpu *addr)
+npxuserinited(struct thread *td)
{
struct pcb *pcb;
- if (!hw_float)
- return;
-
pcb = td->td_pcb;
- critical_enter();
- if (td == PCPU_GET(fpcurthread)) {
-#ifdef CPU_ENABLE_SSE
- if (!cpu_fxsr)
-#endif
- fnclex(); /* As in npxdrop(). */
- fpurstor(addr);
- critical_exit();
- } else {
- critical_exit();
- bcopy(addr, pcb->pcb_save, sizeof(*addr));
- }
if (PCB_USER_FPU(pcb))
- pcb->pcb_flags |= PCB_NPXUSERINITDONE;
- pcb->pcb_flags |= PCB_NPXINITDONE;
+ pcb->pcb_flags |= PCB_NPXINITDONE;
+ pcb->pcb_flags |= PCB_NPXUSERINITDONE;
}
+
void
-npxsetuserregs(struct thread *td, union savefpu *addr)
+npxsetregs(struct thread *td, union savefpu *addr)
{
struct pcb *pcb;
@@ -884,15 +832,17 @@ npxsetuserregs(struct thread *td, union savefpu *addr)
if (!cpu_fxsr)
#endif
fnclex(); /* As in npxdrop(). */
- fpurstor(addr);
+ if (((uintptr_t)addr & 0xf) != 0) {
+ bcopy(addr, &pcb->pcb_user_save, sizeof(*addr));
+ fpurstor(&pcb->pcb_user_save);
+ } else
+ fpurstor(addr);
critical_exit();
pcb->pcb_flags |= PCB_NPXUSERINITDONE | PCB_NPXINITDONE;
} else {
critical_exit();
bcopy(addr, &pcb->pcb_user_save, sizeof(*addr));
- if (PCB_USER_FPU(pcb))
- pcb->pcb_flags |= PCB_NPXINITDONE;
- pcb->pcb_flags |= PCB_NPXUSERINITDONE;
+ npxuserinited(td);
}
}
OpenPOWER on IntegriCloud