165523Spendry /* 265523Spendry * Copyright (c) 1993 Jan-Simon Pendry 3*65809Sbostic * Copyright (c) 1993 4*65809Sbostic * The Regents of the University of California. All rights reserved. 565523Spendry * 665523Spendry * This code is derived from software contributed to Berkeley by 765523Spendry * Jan-Simon Pendry. 865523Spendry * 965523Spendry * %sccs.include.redist.c% 1065523Spendry * 11*65809Sbostic * @(#)procfs_regs.c 8.2 (Berkeley) 01/21/94 1265523Spendry * 1365523Spendry * From: 1465523Spendry * $Id: procfs_regs.c,v 3.2 1993/12/15 09:40:17 jsp Exp $ 1565523Spendry */ 1665523Spendry 1765523Spendry #include <sys/param.h> 1865523Spendry #include <sys/systm.h> 1965523Spendry #include <sys/time.h> 2065523Spendry #include <sys/kernel.h> 2165523Spendry #include <sys/proc.h> 2265523Spendry #include <sys/vnode.h> 2365523Spendry #include <machine/reg.h> 2465523Spendry #include <miscfs/procfs/procfs.h> 2565523Spendry 2665523Spendry int 2765523Spendry procfs_doregs(curp, p, pfs, uio) 2865523Spendry struct proc *curp; 2965523Spendry struct proc *p; 3065523Spendry struct pfsnode *pfs; 3165523Spendry struct uio *uio; 3265523Spendry { 3365523Spendry int error; 3465523Spendry struct reg r; 3565523Spendry char *kv; 3665523Spendry int kl; 3765523Spendry 3865523Spendry kl = sizeof(r); 3965523Spendry kv = (char *) &r; 4065523Spendry 4165523Spendry kv += uio->uio_offset; 4265523Spendry kl -= uio->uio_offset; 4365523Spendry if (kl > uio->uio_resid) 4465523Spendry kl = uio->uio_resid; 4565523Spendry 4665523Spendry if (kl < 0) 4765523Spendry error = EINVAL; 4865523Spendry else 4965523Spendry error = procfs_read_regs(p, &r); 5065523Spendry if (error == 0) 5165523Spendry error = uiomove(kv, kl, uio); 5265523Spendry if (error == 0 && uio->uio_rw == UIO_WRITE) { 5365523Spendry if (p->p_stat != SSTOP) 5465523Spendry error = EBUSY; 5565523Spendry else 5665523Spendry error = procfs_write_regs(p, &r); 5765523Spendry } 5865523Spendry 5965523Spendry uio->uio_offset = 0; 6065523Spendry return (error); 6165523Spendry } 62