This source file includes following definitions.
- osf1_sys_classcntl
- osf1_sys_reboot
- osf1_sys_set_program_attributes
- osf1_sys_setsysinfo
- osf1_sys_sysinfo
- osf1_sys_uname
- osf1_sys_usleep_thread
- osf1_sys_wait4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 #include <sys/param.h>
62 #include <sys/systm.h>
63 #include <sys/namei.h>
64 #include <sys/proc.h>
65 #include <sys/file.h>
66 #include <sys/stat.h>
67 #include <sys/filedesc.h>
68 #include <sys/kernel.h>
69 #include <sys/malloc.h>
70 #include <sys/mman.h>
71 #include <sys/mount.h>
72 #include <sys/signal.h>
73 #include <sys/signalvar.h>
74 #include <sys/reboot.h>
75 #include <sys/syscallargs.h>
76 #include <sys/exec.h>
77 #include <sys/vnode.h>
78 #include <sys/socketvar.h>
79 #include <sys/resource.h>
80 #include <sys/resourcevar.h>
81 #include <sys/wait.h>
82
83 #include <compat/osf1/osf1.h>
84 #include <compat/osf1/osf1_syscallargs.h>
85 #include <compat/osf1/osf1_util.h>
86 #include <compat/osf1/osf1_cvt.h>
87
88 #ifdef SYSCALL_DEBUG
89 extern int scdebug;
90 #endif
91
92 const char osf1_emul_path[] = "/emul/osf1";
93
94 int
95 osf1_sys_classcntl(p, v, retval)
96 struct proc *p;
97 void *v;
98 register_t *retval;
99 {
100
101
102 return (ENOSYS);
103 }
104
105 int
106 osf1_sys_reboot(p, v, retval)
107 struct proc *p;
108 void *v;
109 register_t *retval;
110 {
111 struct osf1_sys_reboot_args *uap = v;
112 struct sys_reboot_args a;
113 unsigned long leftovers;
114
115
116 SCARG(&a, opt) = emul_flags_translate(osf1_reboot_opt_xtab,
117 SCARG(uap, opt), &leftovers);
118 if (leftovers != 0)
119 return (EINVAL);
120
121
122
123 return sys_reboot(p, &a, retval);
124 }
125
126 int
127 osf1_sys_set_program_attributes(p, v, retval)
128 struct proc *p;
129 void *v;
130 register_t *retval;
131 {
132 struct osf1_sys_set_program_attributes_args *uap = v;
133 segsz_t tsize, dsize;
134
135 tsize = btoc(SCARG(uap, tsize));
136 dsize = btoc(SCARG(uap, dsize));
137
138 if (dsize > p->p_rlimit[RLIMIT_DATA].rlim_cur)
139 return (ENOMEM);
140 if (tsize > MAXTSIZ)
141 return (ENOMEM);
142
143 p->p_vmspace->vm_taddr = SCARG(uap, taddr);
144 p->p_vmspace->vm_tsize = tsize;
145 p->p_vmspace->vm_daddr = SCARG(uap, daddr);
146 p->p_vmspace->vm_dsize = dsize;
147
148 return (0);
149 }
150
151 int
152 osf1_sys_setsysinfo(p, v, retval)
153 struct proc *p;
154 void *v;
155 register_t *retval;
156 {
157
158
159 return (0);
160 }
161
162 int
163 osf1_sys_sysinfo(p, v, retval)
164 struct proc *p;
165 void *v;
166 register_t *retval;
167 {
168 struct osf1_sys_sysinfo_args *uap = v;
169 const char *string;
170 int error;
171
172 error = 0;
173 switch (SCARG(uap, cmd)) {
174 case OSF1_SI_SYSNAME:
175 goto should_handle;
176
177 break;
178
179 case OSF1_SI_HOSTNAME:
180 string = hostname;
181 break;
182
183 case OSF1_SI_RELEASE:
184 string = version;
185 break;
186
187 case OSF1_SI_VERSION:
188 goto should_handle;
189
190 case OSF1_SI_MACHINE:
191 string = MACHINE;
192 break;
193
194 case OSF1_SI_ARCHITECTURE:
195 string = MACHINE_ARCH;
196 break;
197
198 case OSF1_SI_HW_SERIAL:
199 string = "666";
200 break;
201
202 case OSF1_SI_HW_PROVIDER:
203 string = "unknown";
204 break;
205
206 case OSF1_SI_SRPC_DOMAIN:
207 goto dont_care;
208
209 case OSF1_SI_SET_HOSTNAME:
210 goto should_handle;
211
212 case OSF1_SI_SET_SYSNAME:
213 goto should_handle;
214
215 case OSF1_SI_SET_SRPC_DOMAIN:
216 goto dont_care;
217
218 default:
219 should_handle:
220 printf("osf1_sys_sysinfo(%d, %p, 0x%lx)\n", SCARG(uap, cmd),
221 SCARG(uap, buf), SCARG(uap,len));
222 dont_care:
223 error = EINVAL;
224 break;
225 };
226
227 if (error == 0)
228 error = copyoutstr(string, SCARG(uap, buf), SCARG(uap, len),
229 NULL);
230
231 return (error);
232 }
233
234 int
235 osf1_sys_uname(p, v, retval)
236 struct proc *p;
237 void *v;
238 register_t *retval;
239 {
240 struct osf1_sys_uname_args *uap = v;
241 struct osf1_utsname u;
242 const char *cp;
243 extern char hostname[], machine[];
244 char *dp, *ep;
245
246
247
248 bzero(&u, sizeof(u));
249 strlcpy(u.sysname, ostype, sizeof(u.sysname));
250 strlcpy(u.nodename, hostname, sizeof(u.nodename));
251 strlcpy(u.release, osrelease, sizeof(u.release));
252
253 dp = u.version;
254 ep = &u.version[sizeof(u.version) - 1];
255 for (cp = version; *cp && *cp != '('; cp++)
256 ;
257 for (cp++; *cp && *cp != ')' && dp < ep; cp++)
258 *dp++ = *cp;
259 for (; *cp && *cp != '#'; cp++)
260 ;
261 for (; *cp && *cp != ':' && dp < ep; cp++)
262 *dp++ = *cp;
263 *dp = '\0';
264
265 strlcpy(u.machine, machine, sizeof(u.machine));
266
267 return (copyout((caddr_t)&u, (caddr_t)SCARG(uap, name), sizeof u));
268 }
269
270 int
271 osf1_sys_usleep_thread(p, v, retval)
272 struct proc *p;
273 void *v;
274 register_t *retval;
275 {
276 struct osf1_sys_usleep_thread_args *uap = v;
277 struct osf1_timeval otv, endotv;
278 struct timeval tv, endtv;
279 u_long ticks;
280 int error;
281
282 if ((error = copyin(SCARG(uap, sleep), &otv, sizeof otv)))
283 return (error);
284 tv.tv_sec = otv.tv_sec;
285 tv.tv_usec = otv.tv_usec;
286
287 ticks = howmany((u_long)tv.tv_sec * 1000000 + tv.tv_usec, tick);
288 if (ticks == 0)
289 ticks = 1;
290
291 getmicrotime(&tv);
292
293 tsleep(p, PUSER|PCATCH, "uslpthrd", ticks);
294
295 if (SCARG(uap, slept) != NULL) {
296 struct timeval tv2;
297
298 getmicrotime(&tv2);
299 timersub(&tv2, &tv, &endtv);
300
301 if (endtv.tv_sec < 0 || endtv.tv_usec < 0)
302 endtv.tv_sec = endtv.tv_usec = 0;
303
304 endotv.tv_sec = endtv.tv_sec;
305 endotv.tv_usec = endtv.tv_usec;
306 error = copyout(&endotv, SCARG(uap, slept), sizeof endotv);
307 }
308 return (error);
309 }
310
311 int
312 osf1_sys_wait4(p, v, retval)
313 struct proc *p;
314 void *v;
315 register_t *retval;
316 {
317 struct osf1_sys_wait4_args *uap = v;
318 struct sys_wait4_args a;
319 struct osf1_rusage osf1_rusage;
320 struct rusage netbsd_rusage;
321 unsigned long leftovers;
322 caddr_t sg;
323 int error;
324
325 SCARG(&a, pid) = SCARG(uap, pid);
326 SCARG(&a, status) = SCARG(uap, status);
327
328
329 SCARG(&a, options) = emul_flags_translate(osf1_wait_options_xtab,
330 SCARG(uap, options), &leftovers);
331 if (leftovers != 0)
332 return (EINVAL);
333
334 if (SCARG(uap, rusage) == NULL)
335 SCARG(&a, rusage) = NULL;
336 else {
337 sg = stackgap_init(p->p_emul);
338 SCARG(&a, rusage) = stackgap_alloc(&sg, sizeof netbsd_rusage);
339 }
340
341 error = sys_wait4(p, &a, retval);
342
343 if (error == 0 && SCARG(&a, rusage) != NULL) {
344 error = copyin((caddr_t)SCARG(&a, rusage),
345 (caddr_t)&netbsd_rusage, sizeof netbsd_rusage);
346 if (error == 0) {
347 osf1_cvt_rusage_from_native(&netbsd_rusage,
348 &osf1_rusage);
349 error = copyout((caddr_t)&osf1_rusage,
350 (caddr_t)SCARG(uap, rusage), sizeof osf1_rusage);
351 }
352 }
353
354 return (error);
355 }