165923Spendry /*
265923Spendry * Copyright (c) 1993 Jan-Simon Pendry
365923Spendry * Copyright (c) 1993
465923Spendry * The Regents of the University of California. All rights reserved.
565923Spendry *
665923Spendry * This code is derived from software contributed to Berkeley by
765923Spendry * Jan-Simon Pendry.
865923Spendry *
965923Spendry * %sccs.include.redist.c%
1065923Spendry *
11*67389Spendry * @(#)procfs_fpregs.c 8.2 (Berkeley) 06/15/94
1265923Spendry *
1365923Spendry * From:
1465923Spendry * $Id: procfs_regs.c,v 3.2 1993/12/15 09:40:17 jsp Exp $
1565923Spendry */
1665923Spendry
1765923Spendry #include <sys/param.h>
1865923Spendry #include <sys/systm.h>
1965923Spendry #include <sys/time.h>
2065923Spendry #include <sys/kernel.h>
2165923Spendry #include <sys/proc.h>
2265923Spendry #include <sys/vnode.h>
2365923Spendry #include <machine/reg.h>
2465923Spendry #include <miscfs/procfs/procfs.h>
2565923Spendry
2665923Spendry int
procfs_dofpregs(curp,p,pfs,uio)2765923Spendry procfs_dofpregs(curp, p, pfs, uio)
2865923Spendry struct proc *curp;
2965923Spendry struct proc *p;
3065923Spendry struct pfsnode *pfs;
3165923Spendry struct uio *uio;
3265923Spendry {
3365923Spendry int error;
3465923Spendry struct fpreg r;
3565923Spendry char *kv;
3665923Spendry int kl;
3765923Spendry
3865923Spendry kl = sizeof(r);
3965923Spendry kv = (char *) &r;
4065923Spendry
4165923Spendry kv += uio->uio_offset;
4265923Spendry kl -= uio->uio_offset;
4365923Spendry if (kl > uio->uio_resid)
4465923Spendry kl = uio->uio_resid;
4565923Spendry
4665923Spendry if (kl < 0)
4765923Spendry error = EINVAL;
4865923Spendry else
4965923Spendry error = procfs_read_fpregs(p, &r);
5065923Spendry if (error == 0)
5165923Spendry error = uiomove(kv, kl, uio);
5265923Spendry if (error == 0 && uio->uio_rw == UIO_WRITE) {
5365923Spendry if (p->p_stat != SSTOP)
5465923Spendry error = EBUSY;
5565923Spendry else
5665923Spendry error = procfs_write_fpregs(p, &r);
5765923Spendry }
5865923Spendry
5965923Spendry uio->uio_offset = 0;
6065923Spendry return (error);
6165923Spendry }
62*67389Spendry
63*67389Spendry int
procfs_validfpregs(p)64*67389Spendry procfs_validfpregs(p)
65*67389Spendry struct proc *p;
66*67389Spendry {
67*67389Spendry
68*67389Spendry return ((p->p_flag & P_SYSTEM) == 0);
69*67389Spendry }
70