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