Move procfs_* from procfs_machdep.c into sys_process.c, and rename them to

proc_* in the process; procfs_machdep.c is no longer needed.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
This commit is contained in:
Dag-Erling Smørgrav 2001-10-21 23:57:24 +00:00
parent 1f04261973
commit 7c62990641
17 changed files with 50 additions and 811 deletions

View File

@ -1,160 +0,0 @@
/*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1993 Jan-Simon Pendry
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94
*
* From:
* $FreeBSD$
*/
/*
* Functions to be implemented here are:
*
* procfs_read_regs(proc, regs)
* Get the current user-visible register set from the process
* and copy it into the regs structure (<machine/reg.h>).
* The process is stopped at the time read_regs is called.
*
* procfs_write_regs(proc, regs)
* Update the current register set from the passed in regs
* structure. Take care to avoid clobbering special CPU
* registers or privileged bits in the PSL.
* Depending on the architecture this may have fix-up work to do,
* especially if the IAR or PCW are modified.
* The process is stopped at the time write_regs is called.
*
* procfs_read_fpregs, procfs_write_fpregs
* deal with the floating point register set, otherwise as above.
*
* procfs_sstep(proc)
* Arrange for the process to trap after executing a single instruction.
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/user.h>
#include <sys/vnode.h>
#include <machine/md_var.h>
#include <machine/reg.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#define PROCFS_ACTION(action) do { \
int error; \
\
mtx_lock_spin(&sched_lock); \
if ((td->td_proc->p_sflag & PS_INMEM) == 0) \
error = EIO; \
else \
error = (action); \
mtx_unlock_spin(&sched_lock); \
return (error); \
} while(0)
int
procfs_read_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(fill_regs(td, regs));
}
int
procfs_write_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(set_regs(td, regs));
}
/*
* Ptrace doesn't support fpregs at all, and there are no security holes
* or translations for fpregs, so we can just copy them.
*/
int
procfs_read_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(fill_fpregs(td, fpregs));
}
int
procfs_write_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(set_fpregs(td, fpregs));
}
int
procfs_sstep(td)
struct thread *td;
{
return (EINVAL);
}
/*
* Placeholders
*/
int
procfs_read_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
return (EIO);
}
int
procfs_write_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
return (EIO);
}

View File

@ -72,7 +72,6 @@ alpha/alpha/pal.s standard
alpha/alpha/perfmon.c optional perfmon profiling-routine
alpha/alpha/perfmon.c optional perfmon
alpha/alpha/pmap.c standard
alpha/alpha/procfs_machdep.c standard
alpha/alpha/mp_machdep.c optional smp
alpha/alpha/prom.c standard
alpha/alpha/promcons.c standard

View File

@ -202,7 +202,6 @@ i386/i386/nexus.c standard
i386/i386/perfmon.c optional perfmon
i386/i386/perfmon.c optional perfmon profiling-routine
i386/i386/pmap.c standard
i386/i386/procfs_machdep.c standard
i386/i386/support.s standard
i386/i386/swtch.s standard
i386/i386/sys_machdep.c standard

View File

@ -48,7 +48,6 @@ ia64/ia64/pal_stub.s optional ski
ia64/ia64/perfmon.c optional perfmon profiling-routine
ia64/ia64/perfmon.c optional perfmon
ia64/ia64/pmap.c standard
ia64/ia64/procfs_machdep.c standard
ia64/ia64/sal.c standard
ia64/ia64/sapic.c standard
ia64/ia64/setjmp.s standard

View File

@ -196,7 +196,6 @@ i386/i386/nexus.c standard
i386/i386/perfmon.c optional perfmon
i386/i386/perfmon.c optional perfmon profiling-routine
i386/i386/pmap.c standard
i386/i386/procfs_machdep.c standard
i386/i386/support.s standard
i386/i386/swtch.s standard
i386/i386/sys_machdep.c standard

View File

@ -25,7 +25,6 @@ powerpc/powerpc/machdep.c standard
powerpc/powerpc/ofwmagic.s standard
powerpc/powerpc/ofw_machdep.c standard
powerpc/powerpc/pmap.c standard
powerpc/powerpc/procfs_machdep.c standard
powerpc/powerpc/subyte.c standard
powerpc/powerpc/suswintr.c standard
powerpc/powerpc/suword.c standard

View File

@ -26,7 +26,6 @@ sparc64/sparc64/identcpu.c standard
sparc64/sparc64/intr_machdep.c standard
sparc64/sparc64/machdep.c standard
sparc64/sparc64/pmap.c standard
sparc64/sparc64/procfs_machdep.c standard
sparc64/sparc64/pv.c standard
sparc64/sparc64/rwindow.c standard
sparc64/sparc64/support.s standard

View File

@ -242,7 +242,7 @@ procfs_control(curp, p, op)
case PROCFS_CTL_STEP:
_PHOLD(p);
PROC_UNLOCK(p);
error = procfs_sstep(&p->p_thread); /* XXXKSE */
error = proc_sstep(&p->p_thread); /* XXXKSE */
PRELE(p);
if (error)
return (error);

View File

@ -84,14 +84,14 @@ procfs_dodbregs(curp, p, pfs, uio)
if (kl < 0)
error = EINVAL;
else
error = procfs_read_dbregs(&p->p_thread, &r); /* XXXKSE */
error = proc_read_dbregs(&p->p_thread, &r); /* XXXKSE */
if (error == 0)
error = uiomove(kv, kl, uio);
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (p->p_stat != SSTOP)
error = EBUSY;
else
error = procfs_write_dbregs(&p->p_thread, &r); /* XXXKSE */
error = proc_write_dbregs(&p->p_thread, &r); /* XXXKSE */
}
PRELE(p);

View File

@ -81,14 +81,14 @@ procfs_dofpregs(curp, p, pfs, uio)
if (kl < 0)
error = EINVAL;
else
error = procfs_read_fpregs(&p->p_thread, &r);
error = proc_read_fpregs(&p->p_thread, &r);
if (error == 0)
error = uiomove(kv, kl, uio);
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (p->p_stat != SSTOP)
error = EBUSY;
else
error = procfs_write_fpregs(&p->p_thread, &r);
error = proc_write_fpregs(&p->p_thread, &r);
}
PRELE(p);

View File

@ -82,14 +82,14 @@ procfs_doregs(curp, p, pfs, uio)
if (kl < 0)
error = EINVAL;
else
error = procfs_read_regs(&p->p_thread, &r); /* XXXKSE */
error = proc_read_regs(&p->p_thread, &r); /* XXXKSE */
if (error == 0)
error = uiomove(kv, kl, uio);
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (p->p_stat != SSTOP)
error = EBUSY;
else
error = procfs_write_regs(&p->p_thread, &r); /* XXXKSE */
error = proc_write_regs(&p->p_thread, &r); /* XXXKSE */
}
PRELE(p);

View File

@ -1,162 +0,0 @@
/*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1993 Jan-Simon Pendry
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94
*
* From:
* $FreeBSD$
*/
/*
* Functions to be implemented here are:
*
* procfs_read_regs(proc, regs)
* Get the current user-visible register set from the process
* and copy it into the regs structure (<machine/reg.h>).
* The process is stopped at the time read_regs is called.
*
* procfs_write_regs(proc, regs)
* Update the current register set from the passed in regs
* structure. Take care to avoid clobbering special CPU
* registers or privileged bits in the PSL.
* Depending on the architecture this may have fix-up work to do,
* especially if the IAR or PCW are modified.
* The process is stopped at the time write_regs is called.
*
* procfs_read_fpregs, procfs_write_fpregs
* deal with the floating point register set, otherwise as above.
*
* procfs_read_dbregs, procfs_write_dbregs
* deal with the processor debug register set, otherwise as above.
*
* procfs_sstep(proc)
* Arrange for the process to trap after executing a single instruction.
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/vnode.h>
#include <machine/reg.h>
#include <machine/md_var.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#define PROCFS_ACTION(action) do { \
int error; \
\
mtx_lock_spin(&sched_lock); \
if ((td->td_proc->p_sflag & PS_INMEM) == 0) \
error = EIO; \
else \
error = (action); \
mtx_unlock_spin(&sched_lock); \
return (error); \
} while(0)
int
procfs_read_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(fill_regs(td, regs));
}
int
procfs_write_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(set_regs(td, regs));
}
int
procfs_read_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
PROCFS_ACTION(fill_dbregs(td, dbregs));
}
int
procfs_write_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
PROCFS_ACTION(set_dbregs(td, dbregs));
}
/*
* Ptrace doesn't support fpregs at all, and there are no security holes
* or translations for fpregs, so we can just copy them.
*/
int
procfs_read_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(fill_fpregs(td, fpregs));
}
int
procfs_write_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(set_fpregs(td, fpregs));
}
int
procfs_sstep(td)
struct thread *td;
{
PROCFS_ACTION(ptrace_single_step(td));
}

View File

@ -1,160 +0,0 @@
/*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1993 Jan-Simon Pendry
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94
*
* From:
* $FreeBSD$
*/
/*
* Functions to be implemented here are:
*
* procfs_read_regs(proc, regs)
* Get the current user-visible register set from the process
* and copy it into the regs structure (<machine/reg.h>).
* The process is stopped at the time read_regs is called.
*
* procfs_write_regs(proc, regs)
* Update the current register set from the passed in regs
* structure. Take care to avoid clobbering special CPU
* registers or privileged bits in the PSL.
* Depending on the architecture this may have fix-up work to do,
* especially if the IAR or PCW are modified.
* The process is stopped at the time write_regs is called.
*
* procfs_read_fpregs, procfs_write_fpregs
* deal with the floating point register set, otherwise as above.
*
* procfs_sstep(proc)
* Arrange for the process to trap after executing a single instruction.
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/vnode.h>
#include <machine/reg.h>
#include <machine/md_var.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <sys/user.h>
#define PROCFS_ACTION(action) do { \
int error; \
\
mtx_lock_spin(&sched_lock); \
if ((td->td_proc->p_sflag & PS_INMEM) == 0) \
error = EIO; \
else \
error = (action); \
mtx_unlock_spin(&sched_lock); \
return (error); \
} while(0)
int
procfs_read_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(fill_regs(td, regs));
}
int
procfs_write_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(set_regs(td, regs));
}
/*
* Ptrace doesn't support fpregs at all, and there are no security holes
* or translations for fpregs, so we can just copy them.
*/
int
procfs_read_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(fill_fpregs(td, fpregs));
}
int
procfs_write_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(set_fpregs(td, fpregs));
}
int
procfs_sstep(td)
struct thread *td;
{
return (EINVAL);
}
/*
* Placeholders
*/
int
procfs_read_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
return (EIO);
}
int
procfs_write_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
return (EIO);
}

View File

@ -53,6 +53,36 @@
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#define PROC_REG_ACTION(name, action, type) \
int \
proc_##name##_##type##s(struct thread *td, struct type *regs) \
{ \
int error; \
\
mtx_lock_spin(&sched_lock); \
error = (action##_##type##s(td, regs)); \
mtx_unlock_spin(&sched_lock); \
return (error); \
}
PROC_REG_ACTION(read, fill, reg);
PROC_REG_ACTION(write, set, reg);
PROC_REG_ACTION(read, fill, dbreg);
PROC_REG_ACTION(write, set, dbreg);
PROC_REG_ACTION(read, fill, fpreg);
PROC_REG_ACTION(write, set, fpreg);
int
proc_sstep(struct thread *td)
{
int error;
mtx_lock_spin(&sched_lock);
error = ptrace_single_step(td);
mtx_unlock_spin(&sched_lock);
return (error);
}
int
proc_rwmem(struct proc *p, struct uio *uio)
{
@ -495,7 +525,7 @@ ptrace(struct thread *td, struct ptrace_args *uap)
error = copyin(uap->addr, &r.reg, sizeof r.reg);
if (error == 0) {
PHOLD(p);
error = procfs_write_regs(&p->p_thread, &r.reg);
error = proc_write_regs(&p->p_thread, &r.reg);
PRELE(p);
}
return (error);
@ -504,7 +534,7 @@ ptrace(struct thread *td, struct ptrace_args *uap)
#ifdef PT_GETREGS
case PT_GETREGS:
PHOLD(p);
error = procfs_read_regs(&p->p_thread, &r.reg);
error = proc_read_regs(&p->p_thread, &r.reg);
PRELE(p);
if (error == 0)
error = copyout(&r.reg, uap->addr, sizeof r.reg);
@ -516,7 +546,7 @@ ptrace(struct thread *td, struct ptrace_args *uap)
error = copyin(uap->addr, &r.fpreg, sizeof r.fpreg);
if (error == 0) {
PHOLD(p);
error = procfs_write_fpregs(&p->p_thread, &r.fpreg);
error = proc_write_fpregs(&p->p_thread, &r.fpreg);
PRELE(p);
}
return (error);
@ -525,7 +555,7 @@ ptrace(struct thread *td, struct ptrace_args *uap)
#ifdef PT_GETFPREGS
case PT_GETFPREGS:
PHOLD(p);
error = procfs_read_fpregs(&p->p_thread, &r.fpreg);
error = proc_read_fpregs(&p->p_thread, &r.fpreg);
PRELE(p);
if (error == 0)
error = copyout(&r.fpreg, uap->addr, sizeof r.fpreg);
@ -537,7 +567,7 @@ ptrace(struct thread *td, struct ptrace_args *uap)
error = copyin(uap->addr, &r.dbreg, sizeof r.dbreg);
if (error == 0) {
PHOLD(p);
error = procfs_write_dbregs(&p->p_thread, &r.dbreg);
error = proc_write_dbregs(&p->p_thread, &r.dbreg);
PRELE(p);
}
return (error);
@ -546,7 +576,7 @@ ptrace(struct thread *td, struct ptrace_args *uap)
#ifdef PT_GETDBREGS
case PT_GETDBREGS:
PHOLD(p);
error = procfs_read_dbregs(&p->p_thread, &r.dbreg);
error = proc_read_dbregs(&p->p_thread, &r.dbreg);
PRELE(p);
if (error == 0)
error = copyout(&r.dbreg, uap->addr, sizeof r.dbreg);

View File

@ -1,156 +0,0 @@
/*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1993 Jan-Simon Pendry
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94
*
* $FreeBSD$
*/
/*
* Functions to be implemented here are:
*
* procfs_read_regs(proc, regs)
* Get the current user-visible register set from the process
* and copy it into the regs structure (<machine/reg.h>).
* The process is stopped at the time read_regs is called.
*
* procfs_write_regs(proc, regs)
* Update the current register set from the passed in regs
* structure. Take care to avoid clobbering special CPU
* registers or privileged bits in the PSL.
* Depending on the architecture this may have fix-up work to do,
* especially if the IAR or PCW are modified.
* The process is stopped at the time write_regs is called.
*
* procfs_read_fpregs, procfs_write_fpregs
* deal with the floating point register set, otherwise as above.
*
* procfs_sstep(proc)
* Arrange for the process to trap after executing a single instruction.
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/vnode.h>
#include <machine/md_var.h>
#include <machine/reg.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <sys/user.h>
#define PROCFS_ACTION(action) do { \
int error; \
\
mtx_lock_spin(&sched_lock); \
if ((td->td_proc->p_sflag & PS_INMEM) == 0) \
error = EIO; \
else \
error = (action); \
mtx_unlock_spin(&sched_lock); \
return (error); \
} while(0)
int
procfs_read_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(fill_regs(td, regs));
}
int
procfs_write_regs(td, regs)
struct thread *td;
struct reg *regs;
{
PROCFS_ACTION(set_regs(td, regs));
}
/*
* Ptrace doesn't support fpregs at all, and there are no security holes
* or translations for fpregs, so we can just copy them.
*/
int
procfs_read_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(fill_fpregs(td, fpregs));
}
int
procfs_write_fpregs(td, fpregs)
struct thread *td;
struct fpreg *fpregs;
{
PROCFS_ACTION(set_fpregs(td, fpregs));
}
int
procfs_sstep(td)
struct thread *td;
{
return (EINVAL);
}
/*
* Placeholders
*/
int
procfs_read_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
return (EIO);
}
int
procfs_write_dbregs(td, dbregs)
struct thread *td;
struct dbreg *dbregs;
{
return (EIO);
}

View File

@ -1,147 +0,0 @@
/*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1993 Jan-Simon Pendry
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94
* $FreeBSD$
*/
/*
* Functions to be implemented here are:
*
* procfs_read_regs(proc, regs)
* Get the current user-visible register set from the process
* and copy it into the regs structure (<machine/reg.h>).
* The process is stopped at the time read_regs is called.
*
* procfs_write_regs(proc, regs)
* Update the current register set from the passed in regs
* structure. Take care to avoid clobbering special CPU
* registers or privileged bits in the PSL.
* Depending on the architecture this may have fix-up work to do,
* especially if the IAR or PCW are modified.
* The process is stopped at the time write_regs is called.
*
* procfs_read_fpregs, procfs_write_fpregs
* deal with the floating point register set, otherwise as above.
*
* procfs_read_dbregs, procfs_write_dbregs
* deal with the processor debug register set, otherwise as above.
*
* procfs_sstep(proc)
* Arrange for the process to trap after executing a single instruction.
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/vnode.h>
#include <machine/reg.h>
#include <machine/md_var.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#define PROCFS_ACTION(action) do { \
int error; \
\
mtx_lock_spin(&sched_lock); \
if ((td->td_proc->p_sflag & PS_INMEM) == 0) \
error = EIO; \
else \
error = (action); \
mtx_unlock_spin(&sched_lock); \
return (error); \
} while(0)
int
procfs_read_regs(struct thread *td, struct reg *regs)
{
PROCFS_ACTION(fill_regs(td, regs));
}
int
procfs_write_regs(struct thread *td, struct reg *regs)
{
PROCFS_ACTION(set_regs(td, regs));
}
int
procfs_read_dbregs(struct thread *td, struct dbreg *dbregs)
{
return (EIO);
}
int
procfs_write_dbregs(struct thread *td, struct dbreg *dbregs)
{
return (EIO);
}
/*
* Ptrace doesn't support fpregs at all, and there are no security holes
* or translations for fpregs, so we can just copy them.
*/
int
procfs_read_fpregs(struct thread *td, struct fpreg *fpregs)
{
PROCFS_ACTION(fill_fpregs(td, fpregs));
}
int
procfs_write_fpregs(struct thread *td, struct fpreg *fpregs)
{
PROCFS_ACTION(set_fpregs(td, fpregs));
}
int
procfs_sstep(struct thread *td)
{
PROCFS_ACTION(ptrace_single_step(td));
}

View File

@ -67,13 +67,13 @@ int ptrace_single_step(struct thread *_td);
struct reg;
struct fpreg;
struct dbreg;
int procfs_read_regs(struct thread *_td, struct reg *_reg);
int procfs_write_regs(struct thread *_td, struct reg *_reg);
int procfs_read_fpregs(struct thread *_td, struct fpreg *_fpreg);
int procfs_write_fpregs(struct thread *_td, struct fpreg *_fpreg);
int procfs_read_dbregs(struct thread *_td, struct dbreg *_dbreg);
int procfs_write_dbregs(struct thread *_td, struct dbreg *_dbreg);
int procfs_sstep(struct thread *_td);
int proc_read_regs(struct thread *_td, struct reg *_reg);
int proc_write_regs(struct thread *_td, struct reg *_reg);
int proc_read_fpregs(struct thread *_td, struct fpreg *_fpreg);
int proc_write_fpregs(struct thread *_td, struct fpreg *_fpreg);
int proc_read_dbregs(struct thread *_td, struct dbreg *_dbreg);
int proc_write_dbregs(struct thread *_td, struct dbreg *_dbreg);
int proc_sstep(struct thread *_td);
int proc_rwmem(struct proc *_p, struct uio *_uio);
#else /* !_KERNEL */