1 /* 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1993 Jan-Simon Pendry 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Jan-Simon Pendry. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94 34 * 35 * From: 36 * $FreeBSD: src/sys/i386/i386/procfs_machdep.c,v 1.14 1999/10/11 14:50:03 peter Exp $ 37 */ 38 39 /* 40 * Functions to be implemented here are: 41 * 42 * procfs_read_regs(lwp, regs) 43 * Get the current user-visible register set from the process 44 * and copy it into the regs structure (<machine/reg.h>). 45 * The process is stopped at the time read_regs is called. 46 * 47 * procfs_write_regs(lwp, regs) 48 * Update the current register set from the passed in regs 49 * structure. Take care to avoid clobbering special CPU 50 * registers or privileged bits in the PSL. 51 * Depending on the architecture this may have fix-up work to do, 52 * especially if the IAR or PCW are modified. 53 * The process is stopped at the time write_regs is called. 54 * 55 * procfs_read_fpregs, procfs_write_fpregs 56 * deal with the floating point register set, otherwise as above. 57 * 58 * procfs_read_dbregs, procfs_write_dbregs 59 * deal with the processor debug register set, otherwise as above. 60 * 61 * procfs_sstep(lwp) 62 * Arrange for the process to trap after executing a single instruction. 63 * 64 */ 65 66 #include <sys/param.h> 67 #include <sys/proc.h> 68 #include <sys/ptrace.h> 69 #include <sys/vnode.h> 70 #include <sys/reg.h> 71 #include <machine/md_var.h> 72 #include <vfs/procfs/procfs.h> 73 74 #include <vm/vm.h> 75 #include <sys/lock.h> 76 #include <vm/pmap.h> 77 #include <vm/vm_map.h> 78 79 int 80 procfs_read_regs(struct lwp *lp, struct reg *regs) 81 { 82 return (fill_regs(lp, regs)); 83 } 84 85 int 86 procfs_write_regs(struct lwp *lp, struct reg *regs) 87 { 88 return (set_regs(lp, regs)); 89 } 90 91 int 92 procfs_read_dbregs(struct lwp *lp, struct dbreg *dbregs) 93 { 94 return (fill_dbregs(lp, dbregs)); 95 } 96 97 int 98 procfs_write_dbregs(struct lwp *lp, struct dbreg *dbregs) 99 { 100 return (set_dbregs(lp, dbregs)); 101 } 102 103 /* 104 * Ptrace doesn't support fpregs at all, and there are no security holes 105 * or translations for fpregs, so we can just copy them. 106 */ 107 108 int 109 procfs_read_fpregs(struct lwp *lp, struct fpreg *fpregs) 110 { 111 return (fill_fpregs(lp, fpregs)); 112 } 113 114 int 115 procfs_write_fpregs(struct lwp *lp, struct fpreg *fpregs) 116 { 117 return (set_fpregs(lp, fpregs)); 118 } 119 120 int 121 procfs_sstep(struct lwp *lp) 122 { 123 return (ptrace_single_step(lp)); 124 } 125