1 /*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *
9 * All advertising materials mentioning features or use of this software
10 * must display the following acknowledgement:
11 * This product includes software developed by the University of
12 * California, Lawrence Berkeley Laboratory.
13 *
14 * %sccs.include.redist.c%
15 *
16 * @(#)sys_machdep.c 8.1 (Berkeley) 06/11/93
17 *
18 * from: $Header: sys_machdep.c,v 1.6 92/11/26 03:05:08 torek Exp $ (LBL)
19 */
20
21 #ifdef TRACE
22 #include <sys/param.h>
23 #include <sys/systm.h>
24 #include <sys/ioctl.h>
25 #include <sys/file.h>
26 #include <sys/time.h>
27 #include <sys/proc.h>
28 #include <sys/uio.h>
29 #include <sys/kernel.h>
30 #include <sys/mtio.h>
31 #include <sys/buf.h>
32 #include <sys/trace.h>
33
34 int nvualarm;
35
36 struct vtrace_args {
37 int request;
38 int value;
39 };
40 vtrace(p, uap, retval)
41 struct proc *p;
42 register struct vtrace_args *uap;
43 int *retval;
44 {
45 int vdoualarm();
46
47 switch (uap->request) {
48
49 case VTR_DISABLE: /* disable a trace point */
50 case VTR_ENABLE: /* enable a trace point */
51 if (uap->value < 0 || uap->value >= TR_NFLAGS)
52 return (EINVAL);
53 *retval = traceflags[uap->value];
54 traceflags[uap->value] = uap->request;
55 break;
56
57 case VTR_VALUE: /* return a trace point setting */
58 if (uap->value < 0 || uap->value >= TR_NFLAGS)
59 return (EINVAL);
60 *retval = traceflags[uap->value];
61 break;
62
63 case VTR_UALARM: /* set a real-time ualarm, less than 1 min */
64 if (uap->value <= 0 || uap->value > 60 * hz || nvualarm > 5)
65 return (EINVAL);
66 nvualarm++;
67 timeout(vdoualarm, (caddr_t)p->p_pid, uap->value);
68 break;
69
70 case VTR_STAMP:
71 trace(TR_STAMP, uap->value, p->p_pid);
72 break;
73 }
74 return (0);
75 }
76
vdoualarm(arg)77 vdoualarm(arg)
78 int arg;
79 {
80 register struct proc *p = pfind(arg);
81
82 if (p != NULL)
83 psignal(p, 16);
84 nvualarm--;
85 }
86 #endif
87