aboutsummaryrefslogtreecommitdiff
path: root/sys/cddl/contrib/opensolaris/uts/powerpc
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2015-12-07 21:33:15 +0000
committerMark Johnston <markj@FreeBSD.org>2015-12-07 21:33:15 +0000
commit711fbd17ecb5c73100aeb4991e158efcd50b8e7b (patch)
tree395bb015ca7c3a283ed4a6f10d9206628be6e3f3 /sys/cddl/contrib/opensolaris/uts/powerpc
parent23d63288c2d79b9355a24fc35381fb62ea12035a (diff)
downloadsrc-711fbd17ecb5c73100aeb4991e158efcd50b8e7b.tar.gz
src-711fbd17ecb5c73100aeb4991e158efcd50b8e7b.zip
Add helper functions proc_readmem() and proc_writemem().
These helper functions can be used to read in or write a buffer from or to an arbitrary process' address space. Without them, this can only be done using proc_rwmem(), which requires the caller to fill out a uio. This is onerous and results in code duplication; the new functions provide a simpler interface which is sufficient for most existing callers of proc_rwmem(). This change also adds a manual page for proc_rwmem() and the new functions. Reviewed by: jhb, kib Differential Revision: https://reviews.freebsd.org/D4245
Notes
Notes: svn path=/head/; revision=291961
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/powerpc')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
index ea01d5f44616..8e4c647199ce 100644
--- a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
+++ b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
@@ -43,44 +43,30 @@
#define OP_RA(x) (((x) & 0x001F0000) >> 16)
#define OP_RB(x) (((x) & 0x0000F100) >> 11)
-
static int
-proc_ops(int op, proc_t *p, void *kaddr, off_t uaddr, size_t len)
+uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr)
{
- struct iovec iov;
- struct uio uio;
-
- iov.iov_base = kaddr;
- iov.iov_len = len;
- uio.uio_offset = uaddr;
- uio.uio_iov = &iov;
- uio.uio_resid = len;
- uio.uio_iovcnt = 1;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_td = curthread;
- uio.uio_rw = op;
+ ssize_t n;
+
PHOLD(p);
- if (proc_rwmem(p, &uio) != 0) {
- PRELE(p);
- return (-1);
- }
+ n = proc_readmem(curthread, p, uaddr, kaddr, len);
PRELE(p);
-
+ if (n <= 0 || n < len)
+ return (ENOMEM);
return (0);
}
static int
-uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr)
-{
-
- return (proc_ops(UIO_READ, p, kaddr, uaddr, len));
-}
-
-static int
uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr)
{
+ ssize_t n;
- return (proc_ops(UIO_WRITE, p, kaddr, uaddr, len));
+ PHOLD(p);
+ n = proc_writemem(curthread, p, uaddr, kaddr, len);
+ PRELE(p);
+ if (n <= 0 || n < len)
+ return (ENOMEM);
+ return (0);
}
int