1*65923Spendry /*
2*65923Spendry  * Copyright (c) 1993 Jan-Simon Pendry
3*65923Spendry  * Copyright (c) 1993
4*65923Spendry  *	The Regents of the University of California.  All rights reserved.
5*65923Spendry  *
6*65923Spendry  * This code is derived from software contributed to Berkeley by
7*65923Spendry  * Jan-Simon Pendry.
8*65923Spendry  *
9*65923Spendry  * %sccs.include.redist.c%
10*65923Spendry  *
11*65923Spendry  *	@(#)procfs_fpregs.c	8.1 (Berkeley) 01/27/94
12*65923Spendry  *
13*65923Spendry  * From:
14*65923Spendry  *	$Id: procfs_regs.c,v 3.2 1993/12/15 09:40:17 jsp Exp $
15*65923Spendry  */
16*65923Spendry 
17*65923Spendry #include <sys/param.h>
18*65923Spendry #include <sys/systm.h>
19*65923Spendry #include <sys/time.h>
20*65923Spendry #include <sys/kernel.h>
21*65923Spendry #include <sys/proc.h>
22*65923Spendry #include <sys/vnode.h>
23*65923Spendry #include <machine/reg.h>
24*65923Spendry #include <miscfs/procfs/procfs.h>
25*65923Spendry 
26*65923Spendry int
27*65923Spendry procfs_dofpregs(curp, p, pfs, uio)
28*65923Spendry 	struct proc *curp;
29*65923Spendry 	struct proc *p;
30*65923Spendry 	struct pfsnode *pfs;
31*65923Spendry 	struct uio *uio;
32*65923Spendry {
33*65923Spendry 	int error;
34*65923Spendry 	struct fpreg r;
35*65923Spendry 	char *kv;
36*65923Spendry 	int kl;
37*65923Spendry 
38*65923Spendry 	kl = sizeof(r);
39*65923Spendry 	kv = (char *) &r;
40*65923Spendry 
41*65923Spendry 	kv += uio->uio_offset;
42*65923Spendry 	kl -= uio->uio_offset;
43*65923Spendry 	if (kl > uio->uio_resid)
44*65923Spendry 		kl = uio->uio_resid;
45*65923Spendry 
46*65923Spendry 	if (kl < 0)
47*65923Spendry 		error = EINVAL;
48*65923Spendry 	else
49*65923Spendry 		error = procfs_read_fpregs(p, &r);
50*65923Spendry 	if (error == 0)
51*65923Spendry 		error = uiomove(kv, kl, uio);
52*65923Spendry 	if (error == 0 && uio->uio_rw == UIO_WRITE) {
53*65923Spendry 		if (p->p_stat != SSTOP)
54*65923Spendry 			error = EBUSY;
55*65923Spendry 		else
56*65923Spendry 			error = procfs_write_fpregs(p, &r);
57*65923Spendry 	}
58*65923Spendry 
59*65923Spendry 	uio->uio_offset = 0;
60*65923Spendry 	return (error);
61*65923Spendry }
62