summaryrefslogtreecommitdiffstats
path: root/sys/pc98/pc98
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/pc98/pc98
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/pc98/pc98')
-rw-r--r--sys/pc98/pc98/machdep.c103
1 files changed, 26 insertions, 77 deletions
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index 942aa45..03933a6 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -568,13 +568,6 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
sf.sf_uc.uc_mcontext.mc_gs = rgs();
bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs));
sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); /* magic */
-
- /*
- * The get_fpcontext() call must be placed before assignments
- * to mc_fsbase and mc_gsbase due to the alignment-override
- * code in get_fpcontext() that possibly clobbers 12 bytes of
- * mcontext after mc_fpstate.
- */
get_fpcontext(td, &sf.sf_uc.uc_mcontext);
fpstate_drop(td);
/*
@@ -2553,28 +2546,33 @@ set_fpregs_xmm(sv_87, sv_xmm)
int
fill_fpregs(struct thread *td, struct fpreg *fpregs)
{
+
+ KASSERT(TD_IS_SUSPENDED(td), ("not suspended thread %p", td));
+ npxgetregs(td);
#ifdef CPU_ENABLE_SSE
- if (cpu_fxsr) {
- fill_fpregs_xmm(&td->td_pcb->pcb_save->sv_xmm,
- (struct save87 *)fpregs);
- return (0);
- }
+ if (cpu_fxsr)
+ fill_fpregs_xmm(&td->td_pcb->pcb_user_save.sv_xmm,
+ (struct save87 *)fpregs);
+ else
#endif /* CPU_ENABLE_SSE */
- bcopy(&td->td_pcb->pcb_save->sv_87, fpregs, sizeof *fpregs);
+ bcopy(&td->td_pcb->pcb_user_save.sv_87, fpregs,
+ sizeof(*fpregs));
return (0);
}
int
set_fpregs(struct thread *td, struct fpreg *fpregs)
{
+
#ifdef CPU_ENABLE_SSE
- if (cpu_fxsr) {
+ if (cpu_fxsr)
set_fpregs_xmm((struct save87 *)fpregs,
- &td->td_pcb->pcb_save->sv_xmm);
- return (0);
- }
+ &td->td_pcb->pcb_user_save.sv_xmm);
+ else
#endif /* CPU_ENABLE_SSE */
- bcopy(fpregs, &td->td_pcb->pcb_save->sv_87, sizeof *fpregs);
+ bcopy(fpregs, &td->td_pcb->pcb_user_save.sv_87,
+ sizeof(*fpregs));
+ npxuserinited(td);
return (0);
}
@@ -2616,13 +2614,6 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
mcp->mc_esp = tp->tf_esp;
mcp->mc_ss = tp->tf_ss;
mcp->mc_len = sizeof(*mcp);
-
- /*
- * The get_fpcontext() call must be placed before assignments
- * to mc_fsbase and mc_gsbase due to the alignment-override
- * code in get_fpcontext() that possibly clobbers 12 bytes of
- * mcontext after mc_fpstate.
- */
get_fpcontext(td, mcp);
sdp = &td->td_pcb->pcb_fsd;
mcp->mc_fsbase = sdp->sd_hibase << 24 | sdp->sd_lobase;
@@ -2673,39 +2664,14 @@ set_mcontext(struct thread *td, const mcontext_t *mcp)
static void
get_fpcontext(struct thread *td, mcontext_t *mcp)
{
+
#ifndef DEV_NPX
mcp->mc_fpformat = _MC_FPFMT_NODEV;
mcp->mc_ownedfp = _MC_FPOWNED_NONE;
#else
- union savefpu *addr;
-
- /*
- * XXX mc_fpstate might be misaligned, since its declaration is not
- * unportabilized using __attribute__((aligned(16))) like the
- * declaration of struct savemm, and anyway, alignment doesn't work
- * for auto variables since we don't use gcc's pessimal stack
- * alignment. Work around this by abusing the spare fields after
- * mcp->mc_fpstate.
- *
- * XXX unpessimize most cases by only aligning when fxsave might be
- * called, although this requires knowing too much about
- * npxgetuserregs()'s internals.
- */
- addr = (union savefpu *)&mcp->mc_fpstate;
- if (td == PCPU_GET(fpcurthread) &&
-#ifdef CPU_ENABLE_SSE
- cpu_fxsr &&
-#endif
- ((uintptr_t)(void *)addr & 0xF)) {
- do
- addr = (void *)((char *)addr + 4);
- while ((uintptr_t)(void *)addr & 0xF);
- }
- mcp->mc_ownedfp = npxgetuserregs(td, addr);
- if (addr != (union savefpu *)&mcp->mc_fpstate) {
- bcopy(addr, &mcp->mc_fpstate, sizeof(mcp->mc_fpstate));
- bzero(&mcp->mc_spare2, sizeof(mcp->mc_spare2));
- }
+ mcp->mc_ownedfp = npxgetregs(td);
+ bcopy(&td->td_pcb->pcb_user_save, &mcp->mc_fpstate,
+ sizeof(mcp->mc_fpstate));
mcp->mc_fpformat = npxformat();
#endif
}
@@ -2713,7 +2679,6 @@ get_fpcontext(struct thread *td, mcontext_t *mcp)
static int
set_fpcontext(struct thread *td, const mcontext_t *mcp)
{
- union savefpu *addr;
if (mcp->mc_fpformat == _MC_FPFMT_NODEV)
return (0);
@@ -2725,30 +2690,14 @@ set_fpcontext(struct thread *td, const mcontext_t *mcp)
fpstate_drop(td);
else if (mcp->mc_ownedfp == _MC_FPOWNED_FPU ||
mcp->mc_ownedfp == _MC_FPOWNED_PCB) {
- /* XXX align as above. */
- addr = (union savefpu *)&mcp->mc_fpstate;
- if (td == PCPU_GET(fpcurthread) &&
-#ifdef CPU_ENABLE_SSE
- cpu_fxsr &&
-#endif
- ((uintptr_t)(void *)addr & 0xF)) {
- do
- addr = (void *)((char *)addr + 4);
- while ((uintptr_t)(void *)addr & 0xF);
- bcopy(&mcp->mc_fpstate, addr, sizeof(mcp->mc_fpstate));
- }
#ifdef DEV_NPX
#ifdef CPU_ENABLE_SSE
if (cpu_fxsr)
- addr->sv_xmm.sv_env.en_mxcsr &= cpu_mxcsr_mask;
+ ((union savefpu *)&mcp->mc_fpstate)->sv_xmm.sv_env.
+ en_mxcsr &= cpu_mxcsr_mask;
#endif
- npxsetuserregs(td, addr);
+ npxsetregs(td, (union savefpu *)&mcp->mc_fpstate);
#endif
- /*
- * Don't bother putting things back where they were in the
- * misaligned case, since we know that the caller won't use
- * them again.
- */
} else
return (EINVAL);
return (0);
@@ -2765,12 +2714,12 @@ fpstate_drop(struct thread *td)
#endif
/*
* XXX force a full drop of the npx. The above only drops it if we
- * owned it. npxusergetregs() has the same bug in the !cpu_fxsr case.
+ * owned it. npxgetregs() has the same bug in the !cpu_fxsr case.
*
- * XXX I don't much like npxgetuserregs()'s semantics of doing a full
+ * XXX I don't much like npxgetregs()'s semantics of doing a full
* drop. Dropping only to the pcb matches fnsave's behaviour.
* We only need to drop to !PCB_INITDONE in sendsig(). But
- * sendsig() is the only caller of npxgetuserregs()... perhaps we just
+ * sendsig() is the only caller of npxgetregs()... perhaps we just
* have too many layers.
*/
curthread->td_pcb->pcb_flags &= ~(PCB_NPXINITDONE |
OpenPOWER on IntegriCloud