xref: /original-bsd/sys/pmax/pmax/procfs_machdep.c (revision 948d00a2)
1 /*
2  * Copyright (c) 1994
3  *	The Regents of the University of California.  All rights reserved.
4  * Copyright (c) 1994 Jan-Simon Pendry
5  *
6  * This code is derived from software contributed to Berkeley by
7  * Jan-Simon Pendry.
8  *
9  * %sccs.include.redist.c%
10  *
11  * From:
12  *	$Id: procfs_i386.c,v 3.2 1993/12/15 09:40:17 jsp Exp $
13  *
14  *	@(#)procfs_machdep.c	8.2 (Berkeley) 10/09/94
15  */
16 
17 /*
18  * Functions to be implemented here are:
19  *
20  * procfs_read_regs(proc, regs)
21  *	Get the current user-visible register set from the process
22  *	and copy it into the regs structure (<machine/reg.h>).
23  *	The process is stopped at the time read_regs is called.
24  *
25  * procfs_write_regs(proc, regs)
26  *	Update the current register set from the passed in regs
27  *	structure.  Take care to avoid clobbering special CPU
28  *	registers or privileged bits in the PSL.
29  *	The process is stopped at the time write_regs is called.
30  *
31  * procfs_read_fpregs, procfs_write_fpregs
32  *	deal with the floating point register set, otherwise as above.
33  *
34  * procfs_sstep(proc)
35  *	Arrange for the process to trap after executing a single instruction.
36  *
37  * procfs_fix_sstep(proc)
38  *	Cleanup process state after executing a single-step instruction.
39  */
40 
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/time.h>
44 #include <sys/kernel.h>
45 #include <sys/proc.h>
46 #include <sys/user.h>
47 #include <sys/vnode.h>
48 #include <machine/psl.h>
49 #include <machine/reg.h>
50 #include <miscfs/procfs/procfs.h>
51 
52 int
53 procfs_read_regs(p, regs)
54 	struct proc *p;
55 	struct reg *regs;
56 {
57 
58 	if ((p->p_flag & P_INMEM) == 0)
59 		return (EIO);
60 
61 	bcopy((void *) p->p_md.md_regs, (void *) regs->r_regs,
62 		sizeof(regs->r_regs));
63 
64 	return (0);
65 }
66 
67 /*
68  * Update the process's current register
69  * set.
70  */
71 int
72 procfs_write_regs(p, regs)
73 	struct proc *p;
74 	struct reg *regs;
75 {
76 	int oldsr;
77 
78 	if ((p->p_flag & P_INMEM) == 0)
79 		return (EIO);
80 
81 	/* no user modifiable bits in the SR register */
82 	oldsr = p->p_md.md_regs[SR];
83 	bcopy((void *) regs->r_regs, (void *) p->p_md.md_regs,
84 		sizeof(regs->r_regs));
85 	p->p_md.md_regs[SR] = oldsr;
86 
87 	return (0);
88 }
89 
90 int
91 procfs_read_fpregs(p, fpregs)
92 	struct proc *p;
93 	struct fpreg *fpregs;
94 {
95 
96 	return (EOPNOTSUPP);
97 }
98 
99 int
100 procfs_write_fpregs(p, fpregs)
101 	struct proc *p;
102 	struct fpreg *fpregs;
103 {
104 
105 	return (EOPNOTSUPP);
106 }
107 
108 int
109 procfs_sstep(p, sstep)
110 	struct proc *p;
111 	int sstep;
112 {
113 
114 	if (sstep && cpu_singlestep(p))
115 		return (EIO);
116 
117 	return (0);
118 }
119 
120 void
121 procfs_fix_sstep(p)
122 	struct proc *p;
123 {
124 }
125