1 /*
2  * Copyright (c) 1993 Jan-Simon Pendry
3  * Copyright (c) 1993
4  *	The Regents of the University of California.  All rights reserved.
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_fpregs.c	8.2 (Berkeley) 06/15/94
12  *
13  * From:
14  *	$Id: procfs_regs.c,v 3.2 1993/12/15 09:40:17 jsp Exp $
15  */
16 
17 #include <sys/param.h>
18 #include <sys/systm.h>
19 #include <sys/time.h>
20 #include <sys/kernel.h>
21 #include <sys/proc.h>
22 #include <sys/vnode.h>
23 #include <machine/reg.h>
24 #include <miscfs/procfs/procfs.h>
25 
26 int
27 procfs_dofpregs(curp, p, pfs, uio)
28 	struct proc *curp;
29 	struct proc *p;
30 	struct pfsnode *pfs;
31 	struct uio *uio;
32 {
33 	int error;
34 	struct fpreg r;
35 	char *kv;
36 	int kl;
37 
38 	kl = sizeof(r);
39 	kv = (char *) &r;
40 
41 	kv += uio->uio_offset;
42 	kl -= uio->uio_offset;
43 	if (kl > uio->uio_resid)
44 		kl = uio->uio_resid;
45 
46 	if (kl < 0)
47 		error = EINVAL;
48 	else
49 		error = procfs_read_fpregs(p, &r);
50 	if (error == 0)
51 		error = uiomove(kv, kl, uio);
52 	if (error == 0 && uio->uio_rw == UIO_WRITE) {
53 		if (p->p_stat != SSTOP)
54 			error = EBUSY;
55 		else
56 			error = procfs_write_fpregs(p, &r);
57 	}
58 
59 	uio->uio_offset = 0;
60 	return (error);
61 }
62 
63 int
64 procfs_validfpregs(p)
65 	struct proc *p;
66 {
67 
68 	return ((p->p_flag & P_SYSTEM) == 0);
69 }
70