mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-01 08:27:59 +00:00
Change the clear_ret argument of get_mcontext() to be a flags argument.
Since all callers either passed 0 or 1 for clear_ret, define bit 0 in the flags for use as clear_ret. Reserve bits 1, 2 and 3 for use by MI code for possible (but unlikely) future use. The remaining bits are for use by MD code. This change is triggered by a need on ia64 to have another knob for get_mcontext().
This commit is contained in:
parent
116f7a3ddb
commit
fcaa2925a9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122364
@ -2027,14 +2027,14 @@ set_regs(td, regs)
|
||||
}
|
||||
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
|
||||
{
|
||||
/*
|
||||
* Use a trapframe for getsetcontext, so just copy the
|
||||
* threads trapframe.
|
||||
*/
|
||||
bcopy(td->td_frame, &mcp->mc_regs, sizeof(struct trapframe));
|
||||
if (clear_ret != 0) {
|
||||
if (flags & GET_MC_CLEAR_RET) {
|
||||
mcp->mc_regs[FRAME_V0] = 0;
|
||||
mcp->mc_regs[FRAME_A4] = 0;
|
||||
mcp->mc_regs[FRAME_A3] = 0;
|
||||
|
@ -1441,7 +1441,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs)
|
||||
* Get machine context.
|
||||
*/
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
|
||||
{
|
||||
struct trapframe *tp;
|
||||
|
||||
@ -1462,7 +1462,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
mcp->mc_rbp = tp->tf_rbp;
|
||||
mcp->mc_rbx = tp->tf_rbx;
|
||||
mcp->mc_rcx = tp->tf_rcx;
|
||||
if (clear_ret != 0) {
|
||||
if (flags & GET_MC_CLEAR_RET) {
|
||||
mcp->mc_rax = 0;
|
||||
mcp->mc_rdx = 0;
|
||||
} else {
|
||||
|
@ -2377,7 +2377,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs)
|
||||
* Get machine context.
|
||||
*/
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
|
||||
{
|
||||
struct trapframe *tp;
|
||||
|
||||
@ -2394,7 +2394,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
mcp->mc_esi = tp->tf_esi;
|
||||
mcp->mc_ebp = tp->tf_ebp;
|
||||
mcp->mc_isp = tp->tf_isp;
|
||||
if (clear_ret != 0) {
|
||||
if (flags & GET_MC_CLEAR_RET) {
|
||||
mcp->mc_eax = 0;
|
||||
mcp->mc_edx = 0;
|
||||
} else {
|
||||
|
@ -1073,7 +1073,7 @@ freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap)
|
||||
#endif
|
||||
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mc, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mc, int flags)
|
||||
{
|
||||
struct _special s;
|
||||
struct trapframe *tf;
|
||||
@ -1108,7 +1108,7 @@ get_mcontext(struct thread *td, mcontext_t *mc, int clear_ret)
|
||||
* return register, just like gr8-gr10.
|
||||
*/
|
||||
mc->mc_flags |= _MC_FLAGS_RETURN_VALID;
|
||||
if (!clear_ret) {
|
||||
if ((flags & GET_MC_CLEAR_RET) == 0) {
|
||||
mc->mc_scratch.gr8 = tf->tf_scratch.gr8;
|
||||
mc->mc_scratch.gr9 = tf->tf_scratch.gr9;
|
||||
mc->mc_scratch.gr10 = tf->tf_scratch.gr10;
|
||||
|
@ -70,7 +70,7 @@ getcontext(struct thread *td, struct getcontext_args *uap)
|
||||
if (uap->ucp == NULL)
|
||||
ret = EINVAL;
|
||||
else {
|
||||
get_mcontext(td, &uc.uc_mcontext, 1);
|
||||
get_mcontext(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
|
||||
PROC_LOCK(td->td_proc);
|
||||
uc.uc_sigmask = td->td_sigmask;
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
@ -114,7 +114,7 @@ swapcontext(struct thread *td, struct swapcontext_args *uap)
|
||||
if (uap->oucp == NULL || uap->ucp == NULL)
|
||||
ret = EINVAL;
|
||||
else {
|
||||
get_mcontext(td, &uc.uc_mcontext, 1);
|
||||
get_mcontext(td, &uc.uc_mcontext, GET_MC_CLEAR_RET);
|
||||
PROC_LOCK(td->td_proc);
|
||||
uc.uc_sigmask = td->td_sigmask;
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
|
@ -2435,7 +2435,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs)
|
||||
* Get machine context.
|
||||
*/
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
|
||||
{
|
||||
struct trapframe *tp;
|
||||
|
||||
@ -2453,7 +2453,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
mcp->mc_ebp = tp->tf_ebp;
|
||||
mcp->mc_isp = tp->tf_isp;
|
||||
mcp->mc_ebx = tp->tf_ebx;
|
||||
if (clear_ret != 0) {
|
||||
if (flags & GET_MC_CLEAR_RET) {
|
||||
mcp->mc_eax = 0;
|
||||
mcp->mc_edx = 0;
|
||||
} else {
|
||||
|
@ -2435,7 +2435,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs)
|
||||
* Get machine context.
|
||||
*/
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
|
||||
{
|
||||
struct trapframe *tp;
|
||||
|
||||
@ -2453,7 +2453,7 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
mcp->mc_ebp = tp->tf_ebp;
|
||||
mcp->mc_isp = tp->tf_isp;
|
||||
mcp->mc_ebx = tp->tf_ebx;
|
||||
if (clear_ret != 0) {
|
||||
if (flags & GET_MC_CLEAR_RET) {
|
||||
mcp->mc_eax = 0;
|
||||
mcp->mc_edx = 0;
|
||||
} else {
|
||||
|
@ -581,7 +581,7 @@ freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap)
|
||||
#endif
|
||||
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
|
||||
{
|
||||
|
||||
return (ENOSYS);
|
||||
|
@ -581,7 +581,7 @@ freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap)
|
||||
#endif
|
||||
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
|
||||
{
|
||||
|
||||
return (ENOSYS);
|
||||
|
@ -564,7 +564,7 @@ freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap)
|
||||
#endif
|
||||
|
||||
int
|
||||
get_mcontext(struct thread *td, mcontext_t *mc, int clear_ret)
|
||||
get_mcontext(struct thread *td, mcontext_t *mc, int flags)
|
||||
{
|
||||
struct trapframe *tf;
|
||||
struct pcb *pcb;
|
||||
@ -572,7 +572,7 @@ get_mcontext(struct thread *td, mcontext_t *mc, int clear_ret)
|
||||
tf = td->td_frame;
|
||||
pcb = td->td_pcb;
|
||||
bcopy(tf, mc, sizeof(*tf));
|
||||
if (clear_ret != 0) {
|
||||
if (flags & GET_MC_CLEAR_RET) {
|
||||
mc->mc_out[0] = 0;
|
||||
mc->mc_out[1] = 0;
|
||||
}
|
||||
|
@ -83,9 +83,16 @@ __END_DECLS
|
||||
|
||||
struct thread;
|
||||
|
||||
/*
|
||||
* Flags for get_mcontext(). The low order 4 bits (i.e a mask of 0x0f) are
|
||||
* reserved for use by machine independent code. All other bits are for use
|
||||
* by machine dependent code.
|
||||
*/
|
||||
#define GET_MC_CLEAR_RET 1
|
||||
|
||||
/* Machine-dependent functions: */
|
||||
int get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret);
|
||||
int set_mcontext(struct thread *td, const mcontext_t *mcp);
|
||||
int get_mcontext(struct thread *, mcontext_t *, int);
|
||||
int set_mcontext(struct thread *, const mcontext_t *);
|
||||
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user