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. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94
38 *
39 * From:
40 * $FreeBSD: src/sys/i386/i386/procfs_machdep.c,v 1.6.4.1 1999/09/05 08:11:15 peter Exp $
41 */
42
43 /*
44 * Functions to be implemented here are:
45 *
46 * procfs_read_regs(proc, regs)
47 * Get the current user-visible register set from the process
48 * and copy it into the regs structure (<machine/reg.h>).
49 * The process is stopped at the time read_regs is called.
50 *
51 * procfs_write_regs(proc, regs)
52 * Update the current register set from the passed in regs
53 * structure. Take care to avoid clobbering special CPU
54 * registers or privileged bits in the PSL.
55 * Depending on the architecture this may have fix-up work to do,
56 * especially if the IAR or PCW are modified.
57 * The process is stopped at the time write_regs is called.
58 *
59 * procfs_read_fpregs, procfs_write_fpregs
60 * deal with the floating point register set, otherwise as above.
61 *
62 * procfs_sstep(proc)
63 * Arrange for the process to trap after executing a single instruction.
64 *
65 */
66
67 #include <sys/param.h>
68 #include <sys/systm.h>
69 #include <sys/time.h>
70 #include <sys/kernel.h>
71 #include <sys/proc.h>
72 #include <sys/ptrace.h>
73 #include <sys/vnode.h>
74 #include <machine/psl.h>
75 #include <machine/reg.h>
76 #include <machine/frame.h>
77 #include <machine/md_var.h>
78 #include <miscfs/procfs/procfs.h>
79
80 #include <vm/vm.h>
81 #include <vm/vm_param.h>
82 #include <vm/vm_prot.h>
83 #include <vm/lock.h>
84 #include <vm/pmap.h>
85 #include <vm/vm_map.h>
86
87 #include <sys/user.h>
88
89 int
90 procfs_read_regs(p, regs)
91 struct proc *p;
92 struct reg *regs;
93 {
94 if ((p->p_flag & P_INMEM) == 0)
95 return (EIO);
96 return (fill_regs(p, regs));
97 }
98
99 int
100 procfs_write_regs(p, regs)
101 struct proc *p;
102 struct reg *regs;
103 {
104 if ((p->p_flag & P_INMEM) == 0)
105 return (EIO);
106 return (set_regs(p, regs));
107 }
108
109 /*
110 * Ptrace doesn't support fpregs at all, and there are no security holes
111 * or translations for fpregs, so we can just copy them.
112 */
113
114 int
115 procfs_read_fpregs(p, fpregs)
116 struct proc *p;
117 struct fpreg *fpregs;
118 {
119 if ((p->p_flag & P_INMEM) == 0)
120 return (EIO);
121 bcopy(&p->p_addr->u_pcb.pcb_savefpu, fpregs, sizeof *fpregs);
122 return (0);
123 }
124
125 int
126 procfs_write_fpregs(p, fpregs)
127 struct proc *p;
128 struct fpreg *fpregs;
129 {
130 if ((p->p_flag & P_INMEM) == 0)
131 return (EIO);
132 bcopy(fpregs, &p->p_addr->u_pcb.pcb_savefpu, sizeof *fpregs);
133 return (0);
134 }
135
136 int
137 procfs_sstep(p)
138 struct proc *p;
139 {
140 if ((p->p_flag & P_INMEM) == 0)
141 return (EIO);
142 return (ptrace_single_step(p));
143 }
Cache object: 44fbc8771e8336a91fbdff3060036db8
|