|
|
1.1 root 1: /*
2: * Copyright (c) 1988 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)sys_machdep.c 7.1 (Berkeley) 5/21/88
7: */
8:
9: #include "param.h"
10: #include "systm.h"
11: #include "dir.h"
12: #include "user.h"
13: #include "ioctl.h"
14: #include "file.h"
15: #include "proc.h"
16: #include "uio.h"
17: #include "kernel.h"
18: #include "mtio.h"
19: #include "buf.h"
20:
21: #include "pte.h"
22:
23: #ifdef TRACE
24: int nvualarm;
25:
26: vtrace()
27: {
28: register struct a {
29: int request;
30: int value;
31: } *uap;
32: int vdoualarm();
33:
34: uap = (struct a *)u.u_ap;
35: switch (uap->request) {
36:
37: case VTR_DISABLE: /* disable a trace point */
38: case VTR_ENABLE: /* enable a trace point */
39: if (uap->value < 0 || uap->value >= TR_NFLAGS)
40: u.u_error = EINVAL;
41: else {
42: u.u_r.r_val1 = traceflags[uap->value];
43: traceflags[uap->value] = uap->request;
44: }
45: break;
46:
47: case VTR_VALUE: /* return a trace point setting */
48: if (uap->value < 0 || uap->value >= TR_NFLAGS)
49: u.u_error = EINVAL;
50: else
51: u.u_r.r_val1 = traceflags[uap->value];
52: break;
53:
54: case VTR_UALARM: /* set a real-time ualarm, less than 1 min */
55: if (uap->value <= 0 || uap->value > 60 * hz ||
56: nvualarm > 5)
57: u.u_error = EINVAL;
58: else {
59: nvualarm++;
60: timeout(vdoualarm, (caddr_t)u.u_procp->p_pid,
61: uap->value);
62: }
63: break;
64:
65: case VTR_STAMP:
66: trace(TR_STAMP, uap->value, u.u_procp->p_pid);
67: break;
68: }
69: }
70:
71: vdoualarm(arg)
72: int arg;
73: {
74: register struct proc *p;
75:
76: p = pfind(arg);
77: if (p)
78: psignal(p, 16);
79: nvualarm--;
80: }
81: #endif
82:
83: #ifdef COMPAT
84: /*
85: * Note: these tables are sorted by
86: * ioctl "code" (in ascending order).
87: */
88: int dctls[] = { DKIOCHDR, 0 };
89: int fctls[] = { FIOCLEX, FIONCLEX, FIOASYNC, FIONBIO, FIONREAD, 0 };
90: int mctls[] = { MTIOCTOP, MTIOCGET, 0 };
91: int tctls[] = {
92: TIOCGETD, TIOCSETD, TIOCHPCL, TIOCMODG, TIOCMODS,
93: TIOCGETP, TIOCSETP, TIOCSETN, TIOCEXCL, TIOCNXCL,
94: TIOCFLUSH,TIOCSETC, TIOCGETC, TIOCREMOTE,TIOCMGET,
95: TIOCMBIC, TIOCMBIS, TIOCMSET, TIOCSTART,TIOCSTOP,
96: TIOCPKT, TIOCNOTTY,TIOCSTI, TIOCOUTQ, TIOCGLTC,
97: TIOCSLTC, TIOCSPGRP,TIOCGPGRP,TIOCCDTR, TIOCSDTR,
98: TIOCCBRK, TIOCSBRK, TIOCLGET, TIOCLSET, TIOCLBIC,
99: TIOCLBIS, 0
100: };
101:
102: /*
103: * Map an old style ioctl command to new.
104: */
105: mapioctl(cmd)
106: int cmd;
107: {
108: register int *map, c;
109:
110: switch ((cmd >> 8) & 0xff) {
111:
112: case 'd':
113: map = dctls;
114: break;
115:
116: case 'f':
117: map = fctls;
118: break;
119:
120: case 'm':
121: map = mctls;
122: break;
123:
124: case 't':
125: map = tctls;
126: break;
127:
128: default:
129: return (0);
130: }
131: while ((c = *map) && (c&0xff) < (cmd&0xff))
132: map++;
133: if (c && (c&0xff) == (cmd&0xff))
134: return (c);
135: return (0);
136: }
137: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.