MFi386: revisions 1.539, 1.540 and 1.541.

This commit is contained in:
Yoshihiro Takahashi 2002-10-08 12:53:26 +00:00
parent 6d8c8fabad
commit de62287d07
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104675
2 changed files with 40 additions and 24 deletions

View File

@ -2179,15 +2179,14 @@ get_mcontext(struct thread *td, mcontext_t *mcp)
/*
* Set machine context.
*
* However, we don't set any but the user modifyable flags, and
* we we won't touch the cs selector.
* However, we don't set any but the user modifiable flags, and we won't
* touch the cs selector.
*/
int
set_mcontext(struct thread *td, const mcontext_t *mcp)
{
struct trapframe *tp;
int ret;
int eflags;
int eflags, ret;
tp = td->td_frame;
if (mcp->mc_len != sizeof(*mcp))
@ -2221,7 +2220,7 @@ get_fpcontext(struct thread *td, mcontext_t *mcp)
#ifndef DEV_NPX
mcp->mc_fpformat = _MC_FPFMT_NODEV;
mcp->mc_ownedfp = _MC_FPOWNED_NONE;
#else
#else /* DEV_NPX */
union savefpu *addr;
/*
@ -2251,8 +2250,9 @@ get_fpcontext(struct thread *td, mcontext_t *mcp)
bcopy(addr, &mcp->mc_fpstate, sizeof(mcp->mc_fpstate));
bzero(&mcp->mc_spare2, sizeof(mcp->mc_spare2));
}
bcopy(&mcp->mc_fpstate, &td->td_pcb->pcb_save, sizeof(mcp->mc_fpstate));
mcp->mc_fpformat = npxformat();
#endif
#endif /* !DEV_NPX */
}
static int
@ -2262,10 +2262,7 @@ set_fpcontext(struct thread *td, const mcontext_t *mcp)
if (mcp->mc_fpformat == _MC_FPFMT_NODEV)
return (0);
else if (mcp->mc_fpformat != _MC_FPFMT_387 &&
mcp->mc_fpformat != _MC_FPFMT_XMM)
return (EINVAL);
else if (mcp->mc_ownedfp == _MC_FPOWNED_NONE)
if (mcp->mc_ownedfp == _MC_FPOWNED_NONE)
/* We don't care what state is left in the FPU or PCB. */
fpstate_drop(td);
else if (mcp->mc_ownedfp == _MC_FPOWNED_FPU ||
@ -2288,14 +2285,25 @@ set_fpcontext(struct thread *td, const mcontext_t *mcp)
* be called with interrupts disabled.
*/
npxsetregs(td, addr);
#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
} else {
/*
* There is no valid FPU state in *mcp, so use the saved
* state in the PCB if there is one. XXX the test for
* whether there is one seems to be quite broken. We
* forcibly drop the state in sendsig().
*/
if ((td->td_pcb->pcb_flags & PCB_NPXINITDONE) != 0)
npxsetregs(td, &td->td_pcb->pcb_save);
#endif
#if !defined(COMPAT_FREEBSD4) && !defined(COMPAT_43)
return (EINVAL);
#endif
}
return (0);
}

View File

@ -2179,15 +2179,14 @@ get_mcontext(struct thread *td, mcontext_t *mcp)
/*
* Set machine context.
*
* However, we don't set any but the user modifyable flags, and
* we we won't touch the cs selector.
* However, we don't set any but the user modifiable flags, and we won't
* touch the cs selector.
*/
int
set_mcontext(struct thread *td, const mcontext_t *mcp)
{
struct trapframe *tp;
int ret;
int eflags;
int eflags, ret;
tp = td->td_frame;
if (mcp->mc_len != sizeof(*mcp))
@ -2221,7 +2220,7 @@ get_fpcontext(struct thread *td, mcontext_t *mcp)
#ifndef DEV_NPX
mcp->mc_fpformat = _MC_FPFMT_NODEV;
mcp->mc_ownedfp = _MC_FPOWNED_NONE;
#else
#else /* DEV_NPX */
union savefpu *addr;
/*
@ -2251,8 +2250,9 @@ get_fpcontext(struct thread *td, mcontext_t *mcp)
bcopy(addr, &mcp->mc_fpstate, sizeof(mcp->mc_fpstate));
bzero(&mcp->mc_spare2, sizeof(mcp->mc_spare2));
}
bcopy(&mcp->mc_fpstate, &td->td_pcb->pcb_save, sizeof(mcp->mc_fpstate));
mcp->mc_fpformat = npxformat();
#endif
#endif /* !DEV_NPX */
}
static int
@ -2262,10 +2262,7 @@ set_fpcontext(struct thread *td, const mcontext_t *mcp)
if (mcp->mc_fpformat == _MC_FPFMT_NODEV)
return (0);
else if (mcp->mc_fpformat != _MC_FPFMT_387 &&
mcp->mc_fpformat != _MC_FPFMT_XMM)
return (EINVAL);
else if (mcp->mc_ownedfp == _MC_FPOWNED_NONE)
if (mcp->mc_ownedfp == _MC_FPOWNED_NONE)
/* We don't care what state is left in the FPU or PCB. */
fpstate_drop(td);
else if (mcp->mc_ownedfp == _MC_FPOWNED_FPU ||
@ -2288,14 +2285,25 @@ set_fpcontext(struct thread *td, const mcontext_t *mcp)
* be called with interrupts disabled.
*/
npxsetregs(td, addr);
#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
} else {
/*
* There is no valid FPU state in *mcp, so use the saved
* state in the PCB if there is one. XXX the test for
* whether there is one seems to be quite broken. We
* forcibly drop the state in sendsig().
*/
if ((td->td_pcb->pcb_flags & PCB_NPXINITDONE) != 0)
npxsetregs(td, &td->td_pcb->pcb_save);
#endif
#if !defined(COMPAT_FREEBSD4) && !defined(COMPAT_43)
return (EINVAL);
#endif
}
return (0);
}