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 * %sccs.include.redist.c% 10 * 11 * @(#)procfs_machdep.c 8.2 (Berkeley) 01/21/94 12 * 13 * From: 14 * $Id: procfs_i386.c,v 3.2 1993/12/15 09:40:17 jsp Exp $ 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_sstep(proc) 32 * Arrange for the process to trap after executing a single instruction. 33 * 34 * procfs_fix_sstep(proc) 35 * Cleanup process state after executing a single-step instruction. 36 */ 37 38 #include <sys/param.h> 39 #include <sys/systm.h> 40 #include <sys/time.h> 41 #include <sys/kernel.h> 42 #include <sys/proc.h> 43 #include <sys/user.h> 44 #include <sys/vnode.h> 45 #include <machine/psl.h> 46 #include <machine/reg.h> 47 /*#include <machine/frame.h>*/ 48 #include <miscfs/procfs/procfs.h> 49 50 int 51 procfs_read_regs(p, regs) 52 struct proc *p; 53 struct reg *regs; 54 { 55 struct frame *f; 56 57 if ((p->p_flag & P_INMEM) == 0) 58 return (EIO); 59 60 f = (struct frame *) p->p_md.md_regs; 61 bcopy((void *) f->f_regs, (void *) regs->r_regs, sizeof(regs->r_regs)); 62 regs->r_pc = f->f_pc; 63 regs->r_sr = f->f_sr; 64 65 return (0); 66 } 67 68 /* 69 * Update the process's current register 70 * set. Depending on the architecture this 71 * may have fix-up work to do, especially 72 * if the IAR or PCW are modified. 73 */ 74 int 75 procfs_write_regs(p, regs) 76 struct proc *p; 77 struct reg *regs; 78 { 79 struct frame *f; 80 81 if ((p->p_flag & P_INMEM) == 0) 82 return (EIO); 83 84 f = (struct frame *) p->p_md.md_regs; 85 bcopy((void *) regs->r_regs, (void *) f->f_regs, sizeof(f->f_regs)); 86 f->f_pc = regs->r_pc; 87 f->f_sr = regs->r_sr; 88 89 return (0); 90 } 91 92 int 93 procfs_sstep(p) 94 struct proc *p; 95 { 96 int error; 97 struct reg r; 98 99 error = procfs_read_regs(p, &r); 100 if (error == 0) { 101 r.r_sr |= PSL_T; 102 error = procfs_write_regs(p, &r); 103 } 104 105 return (error); 106 } 107 108 void 109 procfs_fix_sstep(p) 110 struct proc *p; 111 { 112 } 113