]>
Commit | Line | Data |
---|---|---|
c143ef62 MM |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1995, Andrew Cagney <[email protected]> | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 2 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
19 | */ | |
20 | ||
21 | ||
22 | #ifndef _EMUL_NETBSD_C_ | |
23 | #define _EMUL_NETBSD_C_ | |
24 | ||
c494cadd MM |
25 | #include "emul_generic.h" |
26 | ||
27 | #ifdef HAVE_STRING_H | |
28 | #include <string.h> | |
29 | #else | |
30 | #ifdef HAVE_STRINGS_H | |
31 | #include <strings.h> | |
32 | #endif | |
33 | #endif | |
34 | ||
c143ef62 MM |
35 | #include <sys/types.h> |
36 | #include <sys/stat.h> | |
37 | #include <stdio.h> | |
c143ef62 MM |
38 | #include <signal.h> |
39 | #include <fcntl.h> | |
c143ef62 MM |
40 | #include <sys/errno.h> |
41 | #include <sys/param.h> | |
42 | #include <sys/time.h> | |
43 | #include <sys/resource.h> | |
44 | #include <sys/ioctl.h> | |
45 | #include <sys/mount.h> | |
46 | #include <sys/dirent.h> | |
47 | ||
c494cadd MM |
48 | #ifdef HAVE_UNISTD_H |
49 | #include <unistd.h> | |
50 | #endif | |
51 | ||
52 | #ifdef HAVE_STDLIB_H | |
53 | #include <stdlib.h> | |
54 | #endif | |
55 | ||
c143ef62 MM |
56 | #define WITH_NetBSD_HOST (NetBSD >= 199306) |
57 | #if WITH_NetBSD_HOST /* here NetBSD as that is what we're emulating */ | |
58 | #include <sys/syscall.h> /* FIXME - should not be including this one */ | |
59 | #include <sys/sysctl.h> | |
60 | extern int getdirentries(int fd, char *buf, int nbytes, long *basep); | |
61 | #endif | |
62 | ||
63 | #if (BSD < 199306) /* here BSD as just a bug */ | |
64 | extern int errno; | |
65 | #endif | |
66 | ||
c143ef62 MM |
67 | #ifndef STATIC_INLINE_EMUL_NETBSD |
68 | #define STATIC_INLINE_EMUL_NETBSD STATIC_INLINE | |
69 | #endif | |
70 | ||
71 | ||
72 | #if WITH_NetBSD_HOST | |
73 | #define SYS(X) ASSERT(call == (SYS_##X)) | |
74 | #else | |
75 | #define SYS(X) | |
76 | #endif | |
77 | ||
78 | #if WITH_NetBSD_HOST && (PATH_MAX != 1024) | |
79 | #error "PATH_MAX not 1024" | |
80 | #elif !defined(PATH_MAX) | |
81 | #define PATH_MAX 1024 | |
82 | #endif | |
83 | ||
84 | ||
85 | STATIC_INLINE_EMUL_NETBSD void | |
86 | write_stat(unsigned_word addr, | |
87 | struct stat buf, | |
88 | cpu *processor, | |
89 | unsigned_word cia) | |
90 | { | |
91 | H2T(buf.st_dev); | |
92 | H2T(buf.st_ino); | |
93 | H2T(buf.st_mode); | |
94 | H2T(buf.st_nlink); | |
95 | H2T(buf.st_uid); | |
96 | H2T(buf.st_gid); | |
97 | H2T(buf.st_rdev); | |
98 | H2T(buf.st_size); | |
99 | H2T(buf.st_atime); | |
100 | /* H2T(buf.st_spare1); */ | |
101 | H2T(buf.st_mtime); | |
102 | /* H2T(buf.st_spare2); */ | |
103 | H2T(buf.st_ctime); | |
104 | /* H2T(buf.st_spare3); */ | |
105 | H2T(buf.st_blksize); | |
106 | H2T(buf.st_blocks); | |
107 | #if WITH_NetBSD_HOST | |
108 | H2T(buf.st_flags); | |
109 | H2T(buf.st_gen); | |
110 | #endif | |
111 | emul_write_buffer(&buf, addr, sizeof(buf), processor, cia); | |
112 | } | |
113 | ||
114 | ||
115 | #if NetBSD | |
116 | STATIC_INLINE_EMUL_NETBSD void | |
117 | write_statfs(unsigned_word addr, | |
118 | struct statfs buf, | |
119 | cpu *processor, | |
120 | unsigned_word cia) | |
121 | { | |
122 | H2T(buf.f_type); | |
123 | H2T(buf.f_flags); | |
124 | H2T(buf.f_bsize); | |
125 | H2T(buf.f_iosize); | |
126 | H2T(buf.f_blocks); | |
127 | H2T(buf.f_bfree); | |
128 | H2T(buf.f_bavail); | |
129 | H2T(buf.f_files); | |
130 | H2T(buf.f_ffree); | |
131 | H2T(buf.f_fsid.val[0]); | |
132 | H2T(buf.f_fsid.val[1]); | |
133 | H2T(buf.f_owner); | |
134 | /* f_spare[4]; */ | |
135 | /* f_fstypename[MFSNAMELEN]; */ | |
136 | /* f_mntonname[MNAMELEN]; */ | |
137 | /* f_mntfromname[MNAMELEN]; */ | |
138 | emul_write_buffer(&buf, addr, sizeof(buf), processor, cia); | |
139 | } | |
140 | #endif | |
141 | ||
142 | ||
143 | STATIC_INLINE_EMUL_NETBSD void | |
144 | write_timeval(unsigned_word addr, | |
145 | struct timeval t, | |
146 | cpu *processor, | |
147 | unsigned_word cia) | |
148 | { | |
149 | H2T(t.tv_sec); | |
150 | H2T(t.tv_usec); | |
151 | emul_write_buffer(&t, addr, sizeof(t), processor, cia); | |
152 | } | |
153 | ||
154 | ||
155 | STATIC_INLINE_EMUL_NETBSD void | |
156 | write_timezone(unsigned_word addr, | |
157 | struct timezone tz, | |
158 | cpu *processor, | |
159 | unsigned_word cia) | |
160 | { | |
161 | H2T(tz.tz_minuteswest); | |
162 | H2T(tz.tz_dsttime); | |
163 | emul_write_buffer(&tz, addr, sizeof(tz), processor, cia); | |
164 | } | |
165 | ||
166 | ||
167 | #if WITH_NetBSD_HOST | |
168 | STATIC_INLINE_EMUL_NETBSD void | |
169 | write_direntries(unsigned_word addr, | |
170 | char *buf, | |
171 | int nbytes, | |
172 | cpu *processor, | |
173 | unsigned_word cia) | |
174 | { | |
175 | while (nbytes > 0) { | |
176 | struct dirent *out; | |
177 | struct dirent *in = (struct dirent*)buf; | |
178 | ASSERT(in->d_reclen <= nbytes); | |
179 | out = (struct dirent*)zalloc(in->d_reclen); | |
180 | bcopy(in, out, in->d_reclen); | |
181 | H2T(out->d_fileno); | |
182 | H2T(out->d_reclen); | |
183 | H2T(out->d_type); | |
184 | H2T(out->d_namlen); | |
185 | emul_write_buffer(out, addr, in->d_reclen, processor, cia); | |
186 | nbytes -= in->d_reclen; | |
187 | addr += in->d_reclen; | |
188 | buf += in->d_reclen; | |
189 | zfree(out); | |
190 | } | |
191 | } | |
192 | #endif | |
193 | ||
194 | ||
195 | STATIC_INLINE_EMUL_NETBSD void | |
196 | write_rusage(unsigned_word addr, | |
197 | struct rusage rusage, | |
198 | cpu *processor, | |
199 | unsigned_word cia) | |
200 | { | |
201 | H2T(rusage.ru_utime.tv_sec); /* user time used */ | |
202 | H2T(rusage.ru_utime.tv_usec); | |
203 | H2T(rusage.ru_stime.tv_sec); /* system time used */ | |
204 | H2T(rusage.ru_stime.tv_usec); | |
205 | H2T(rusage.ru_maxrss); /* integral max resident set size */ | |
206 | H2T(rusage.ru_ixrss); /* integral shared text memory size */ | |
207 | H2T(rusage.ru_idrss); /* integral unshared data size */ | |
208 | H2T(rusage.ru_isrss); /* integral unshared stack size */ | |
209 | H2T(rusage.ru_minflt); /* page reclaims */ | |
210 | H2T(rusage.ru_majflt); /* page faults */ | |
211 | H2T(rusage.ru_nswap); /* swaps */ | |
212 | H2T(rusage.ru_inblock); /* block input operations */ | |
213 | H2T(rusage.ru_oublock); /* block output operations */ | |
214 | H2T(rusage.ru_msgsnd); /* messages sent */ | |
215 | H2T(rusage.ru_msgrcv); /* messages received */ | |
216 | H2T(rusage.ru_nsignals); /* signals received */ | |
217 | H2T(rusage.ru_nvcsw); /* voluntary context switches */ | |
218 | H2T(rusage.ru_nivcsw); /* involuntary context switches */ | |
219 | emul_write_buffer(&rusage, addr, sizeof(rusage), processor, cia); | |
220 | } | |
221 | ||
222 | ||
223 | STATIC_INLINE_EMUL_NETBSD void | |
224 | do_exit(emulation *emul, | |
225 | unsigned call, | |
226 | const int arg0, | |
227 | cpu *processor, | |
228 | unsigned_word cia) | |
229 | { | |
230 | int status = (int)cpu_registers(processor)->gpr[arg0]; | |
231 | SYS(exit); | |
232 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
233 | printf_filtered ("%d)\n", status); | |
234 | ||
235 | cpu_halt(processor, cia, was_exited, status); | |
236 | } | |
237 | ||
238 | ||
239 | STATIC_INLINE_EMUL_NETBSD void | |
240 | do_read(emulation *emul, | |
241 | unsigned call, | |
242 | const int arg0, | |
243 | cpu *processor, | |
244 | unsigned_word cia) | |
245 | { | |
246 | void *scratch_buffer; | |
247 | int d = (int)cpu_registers(processor)->gpr[arg0]; | |
248 | unsigned_word buf = cpu_registers(processor)->gpr[arg0+1]; | |
249 | int nbytes = cpu_registers(processor)->gpr[arg0+2]; | |
250 | int status; | |
c143ef62 MM |
251 | SYS(read); |
252 | ||
253 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
254 | printf_filtered ("%d, 0x%lx, %d", d, (long)buf, nbytes); | |
255 | ||
256 | /* get a tempoary bufer */ | |
257 | scratch_buffer = zalloc(nbytes); | |
258 | ||
259 | /* check if buffer exists by reading it */ | |
260 | emul_read_buffer(scratch_buffer, buf, nbytes, processor, cia); | |
261 | ||
262 | /* read */ | |
263 | #if 0 | |
264 | if (d == 0) { | |
265 | status = fread (scratch_buffer, 1, nbytes, stdin); | |
266 | if (status == 0 && ferror (stdin)) | |
267 | status = -1; | |
268 | } | |
269 | #endif | |
270 | status = read (d, scratch_buffer, nbytes); | |
271 | ||
272 | if (status == -1) { | |
273 | cpu_registers(processor)->gpr[0] = errno; | |
274 | } else { | |
275 | cpu_registers(processor)->gpr[3] = status; | |
276 | ||
277 | if (status > 0) | |
278 | emul_write_buffer(scratch_buffer, buf, status, processor, cia); | |
279 | } | |
280 | ||
281 | zfree(scratch_buffer); | |
282 | } | |
283 | ||
284 | ||
285 | STATIC_INLINE_EMUL_NETBSD void | |
286 | do_write(emulation *emul, | |
287 | unsigned call, | |
288 | const int arg0, | |
289 | cpu *processor, | |
290 | unsigned_word cia) | |
291 | { | |
292 | void *scratch_buffer = NULL; | |
293 | int nr_moved; | |
294 | int d = (int)cpu_registers(processor)->gpr[arg0]; | |
295 | unsigned_word buf = cpu_registers(processor)->gpr[arg0+1]; | |
296 | int nbytes = cpu_registers(processor)->gpr[arg0+2]; | |
297 | int status; | |
298 | SYS(write); | |
299 | ||
300 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
301 | printf_filtered ("%d, 0x%lx, %d", d, (long)buf, nbytes); | |
302 | ||
303 | /* get a tempoary bufer */ | |
304 | scratch_buffer = zalloc(nbytes); /* FIXME - nbytes == 0 */ | |
305 | ||
306 | /* copy in */ | |
307 | nr_moved = vm_data_map_read_buffer(cpu_data_map(processor), | |
308 | scratch_buffer, | |
309 | buf, | |
310 | nbytes); | |
311 | if (nr_moved != nbytes) { | |
312 | /* FIXME - should handle better */ | |
313 | error("system_call()write copy failed (nr_moved=%d != nbytes=%d)\n", | |
314 | nr_moved, nbytes); | |
315 | } | |
316 | ||
317 | /* write */ | |
318 | status = write(d, scratch_buffer, nbytes); | |
319 | emul_write_status(processor, status, errno); | |
320 | zfree(scratch_buffer); | |
321 | } | |
322 | ||
323 | ||
324 | STATIC_INLINE_EMUL_NETBSD void | |
325 | do_open(emulation *emul, | |
326 | unsigned call, | |
327 | const int arg0, | |
328 | cpu *processor, | |
329 | unsigned_word cia) | |
330 | { | |
331 | unsigned_word path_addr = cpu_registers(processor)->gpr[arg0]; | |
332 | char path_buf[PATH_MAX]; | |
333 | char *path = emul_read_string(path_buf, path_addr, PATH_MAX, processor, cia); | |
334 | int flags = (int)cpu_registers(processor)->gpr[arg0+1]; | |
335 | int mode = (int)cpu_registers(processor)->gpr[arg0+2]; | |
336 | ||
337 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
338 | printf_filtered ("0x%lx [%s], 0x%x, 0x%x", (long)path_addr, path, flags, mode); | |
339 | ||
340 | SYS(open); | |
341 | emul_write_status(processor, open(path, flags, mode), errno); | |
342 | } | |
343 | ||
344 | ||
345 | STATIC_INLINE_EMUL_NETBSD void | |
346 | do_close(emulation *emul, | |
347 | unsigned call, | |
348 | const int arg0, | |
349 | cpu *processor, | |
350 | unsigned_word cia) | |
351 | { | |
352 | int d = (int)cpu_registers(processor)->gpr[arg0]; | |
353 | ||
354 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
355 | printf_filtered ("%d", d); | |
356 | ||
357 | SYS(close); | |
358 | emul_write_status(processor, close(d), errno); | |
359 | } | |
360 | ||
361 | ||
362 | STATIC_INLINE_EMUL_NETBSD void | |
363 | do_break(emulation *emul, | |
364 | unsigned call, | |
365 | const int arg0, | |
366 | cpu *processor, | |
367 | unsigned_word cia) | |
368 | /* just pass this onto the `vm' device */ | |
369 | { | |
370 | psim *system = cpu_system(processor); | |
371 | const device *vm = psim_device(system, "/vm"); | |
372 | ||
373 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
374 | printf_filtered ("0x%lx", (long)cpu_registers(processor)->gpr[arg0]); | |
375 | ||
376 | SYS(break); | |
377 | vm->callback->ioctl(vm, | |
378 | system, | |
379 | processor, | |
380 | cia, | |
381 | 0, /*ioctl*/ | |
382 | NULL); /*ioctl-data*/ | |
383 | } | |
384 | ||
385 | ||
386 | STATIC_INLINE_EMUL_NETBSD void | |
387 | do_getpid(emulation *emul, | |
388 | unsigned call, | |
389 | const int arg0, | |
390 | cpu *processor, | |
391 | unsigned_word cia) | |
392 | { | |
393 | SYS(getpid); | |
394 | cpu_registers(processor)->gpr[3] = (int)getpid(); | |
395 | } | |
396 | ||
397 | ||
398 | STATIC_INLINE_EMUL_NETBSD void | |
399 | do_getuid(emulation *emul, | |
400 | unsigned call, | |
401 | const int arg0, | |
402 | cpu *processor, | |
403 | unsigned_word cia) | |
404 | { | |
405 | SYS(getuid); | |
406 | cpu_registers(processor)->gpr[3] = (int)getuid(); | |
407 | } | |
408 | ||
409 | ||
410 | STATIC_INLINE_EMUL_NETBSD void | |
411 | do_geteuid(emulation *emul, | |
412 | unsigned call, | |
413 | const int arg0, | |
414 | cpu *processor, | |
415 | unsigned_word cia) | |
416 | { | |
417 | SYS(geteuid); | |
418 | cpu_registers(processor)->gpr[3] = (int)geteuid(); | |
419 | } | |
420 | ||
421 | ||
422 | STATIC_INLINE_EMUL_NETBSD void | |
423 | do_kill(emulation *emul, | |
424 | unsigned call, | |
425 | const int arg0, | |
426 | cpu *processor, | |
427 | unsigned_word cia) | |
428 | { | |
429 | pid_t pid = cpu_registers(processor)->gpr[arg0]; | |
430 | int sig = cpu_registers(processor)->gpr[arg0+1]; | |
431 | ||
432 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
433 | printf_filtered ("%d, %d", (int)pid, sig); | |
434 | ||
435 | SYS(kill); | |
436 | printf_filtered("SYS_kill at 0x%x - more to this than just being killed\n", | |
437 | cia); | |
438 | cpu_halt(processor, cia, was_signalled, sig); | |
439 | } | |
440 | ||
441 | ||
442 | STATIC_INLINE_EMUL_NETBSD void | |
443 | do_dup(emulation *emul, | |
444 | unsigned call, | |
445 | const int arg0, | |
446 | cpu *processor, | |
447 | unsigned_word cia) | |
448 | { | |
449 | int oldd = cpu_registers(processor)->gpr[arg0]; | |
450 | int status = dup(oldd); | |
451 | ||
452 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
453 | printf_filtered ("%d", oldd); | |
454 | ||
455 | SYS(dup); | |
456 | emul_write_status(processor, status, errno); | |
457 | } | |
458 | ||
459 | ||
460 | STATIC_INLINE_EMUL_NETBSD void | |
461 | do_getegid(emulation *emul, | |
462 | unsigned call, | |
463 | const int arg0, | |
464 | cpu *processor, | |
465 | unsigned_word cia) | |
466 | { | |
467 | SYS(getegid); | |
468 | cpu_registers(processor)->gpr[3] = (int)getegid(); | |
469 | } | |
470 | ||
471 | ||
472 | STATIC_INLINE_EMUL_NETBSD void | |
473 | do_getgid(emulation *emul, | |
474 | unsigned call, | |
475 | const int arg0, | |
476 | cpu *processor, | |
477 | unsigned_word cia) | |
478 | { | |
479 | SYS(getgid); | |
480 | cpu_registers(processor)->gpr[3] = (int)getgid(); | |
481 | } | |
482 | ||
483 | ||
484 | STATIC_INLINE_EMUL_NETBSD void | |
485 | do_sigprocmask(emulation *emul, | |
486 | unsigned call, | |
487 | const int arg0, | |
488 | cpu *processor, | |
489 | unsigned_word cia) | |
490 | { | |
491 | natural_word how = cpu_registers(processor)->gpr[arg0]; | |
492 | unsigned_word set = cpu_registers(processor)->gpr[arg0+1]; | |
493 | unsigned_word oset = cpu_registers(processor)->gpr[arg0+2]; | |
494 | SYS(sigprocmask); | |
495 | ||
496 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
497 | printf_filtered ("%ld, 0x%ld, 0x%ld", (long)how, (long)set, (long)oset); | |
498 | ||
499 | cpu_registers(processor)->gpr[3] = 0; | |
500 | cpu_registers(processor)->gpr[4] = set; | |
501 | } | |
502 | ||
503 | ||
504 | STATIC_INLINE_EMUL_NETBSD void | |
505 | do_ioctl(emulation *emul, | |
506 | unsigned call, | |
507 | const int arg0, | |
508 | cpu *processor, | |
509 | unsigned_word cia) | |
510 | { | |
511 | int d = cpu_registers(processor)->gpr[arg0]; | |
512 | unsigned request = cpu_registers(processor)->gpr[arg0+1]; | |
513 | unsigned_word argp_addr = cpu_registers(processor)->gpr[arg0+2]; | |
514 | ||
515 | #if !WITH_NetBSD_HOST | |
516 | cpu_registers(processor)->gpr[arg0] = 0; /* just succeed */ | |
517 | #else | |
518 | unsigned param_len = IOCPARM_LEN(request); | |
519 | unsigned basecmd = IOCBASECMD(request); | |
520 | unsigned group = IOCGROUP(request); | |
521 | unsigned dir = request & IOC_DIRMASK; | |
522 | char *argp = NULL; | |
523 | int status; | |
524 | SYS(ioctl); | |
525 | /* what we haven't done */ | |
526 | if (dir & IOC_IN /* write into the io device */ | |
527 | || dir & IOC_OUT | |
528 | || !(dir & IOC_VOID)) | |
529 | error("do_ioctl() read or write of parameter not implemented\n"); | |
530 | status = ioctl(d, request, NULL); | |
531 | emul_write_status(processor, status, errno); | |
532 | #endif | |
533 | ||
534 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
535 | printf_filtered ("%d, 0x%x, 0x%lx", d, request, (long)argp_addr); | |
536 | } | |
537 | ||
538 | ||
539 | STATIC_INLINE_EMUL_NETBSD void | |
540 | do_umask(emulation *emul, | |
541 | unsigned call, | |
542 | const int arg0, | |
543 | cpu *processor, | |
544 | unsigned_word cia) | |
545 | { | |
546 | int mask = cpu_registers(processor)->gpr[arg0]; | |
547 | ||
548 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
549 | printf_filtered ("0%o", mask); | |
550 | ||
551 | SYS(umask); | |
552 | cpu_registers(processor)->gpr[3] = umask(mask); | |
553 | } | |
554 | ||
555 | ||
556 | STATIC_INLINE_EMUL_NETBSD void | |
557 | do_dup2(emulation *emul, | |
558 | unsigned call, | |
559 | const int arg0, | |
560 | cpu *processor, | |
561 | unsigned_word cia) | |
562 | { | |
563 | int oldd = cpu_registers(processor)->gpr[arg0]; | |
564 | int newd = cpu_registers(processor)->gpr[arg0+1]; | |
565 | int status = dup2(oldd, newd); | |
566 | ||
567 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
568 | printf_filtered ("%d, %d", oldd, newd); | |
569 | ||
570 | SYS(dup2); | |
571 | emul_write_status(processor, status, errno); | |
572 | } | |
573 | ||
574 | ||
575 | STATIC_INLINE_EMUL_NETBSD void | |
576 | do_fcntl(emulation *emul, | |
577 | unsigned call, | |
578 | const int arg0, | |
579 | cpu *processor, | |
580 | unsigned_word cia) | |
581 | { | |
582 | int fd = cpu_registers(processor)->gpr[arg0]; | |
583 | int cmd = cpu_registers(processor)->gpr[arg0+1]; | |
584 | int arg = cpu_registers(processor)->gpr[arg0+2]; | |
585 | int status; | |
586 | ||
587 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
588 | printf_filtered ("%d, %d, %d", fd, cmd, arg); | |
589 | ||
590 | SYS(fcntl); | |
591 | status = fcntl(fd, cmd, arg); | |
592 | emul_write_status(processor, status, errno); | |
593 | } | |
594 | ||
595 | ||
596 | STATIC_INLINE_EMUL_NETBSD void | |
597 | do_gettimeofday(emulation *emul, | |
598 | unsigned call, | |
599 | const int arg0, | |
600 | cpu *processor, | |
601 | unsigned_word cia) | |
602 | { | |
603 | unsigned_word t_addr = cpu_registers(processor)->gpr[arg0]; | |
604 | unsigned_word tz_addr = cpu_registers(processor)->gpr[arg0+1]; | |
605 | struct timeval t; | |
606 | struct timezone tz; | |
607 | int status = gettimeofday((t_addr != 0 ? &t : NULL), | |
608 | (tz_addr != 0 ? &tz : NULL)); | |
609 | ||
610 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
611 | printf_filtered ("0x%lx, 0x%lx", (long)t_addr, (long)tz_addr); | |
612 | ||
613 | SYS(gettimeofday); | |
614 | emul_write_status(processor, status, errno); | |
615 | if (status == 0) { | |
616 | if (t_addr != 0) | |
617 | write_timeval(t_addr, t, processor, cia); | |
618 | if (tz_addr != 0) | |
619 | write_timezone(tz_addr, tz, processor, cia); | |
620 | } | |
621 | } | |
622 | ||
623 | ||
624 | STATIC_INLINE_EMUL_NETBSD void | |
625 | do_getrusage(emulation *emul, | |
626 | unsigned call, | |
627 | const int arg0, | |
628 | cpu *processor, | |
629 | unsigned_word cia) | |
630 | { | |
631 | int who = cpu_registers(processor)->gpr[arg0]; | |
632 | unsigned_word rusage_addr = cpu_registers(processor)->gpr[arg0+1]; | |
633 | struct rusage rusage; | |
634 | int status = getrusage(who, (rusage_addr != 0 ? &rusage : NULL)); | |
635 | ||
636 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
637 | printf_filtered ("%d, 0x%lx", who, (long)rusage_addr); | |
638 | ||
639 | SYS(getrusage); | |
640 | emul_write_status(processor, status, errno); | |
641 | if (status == 0) { | |
642 | if (rusage_addr != 0) | |
643 | write_rusage(rusage_addr, rusage, processor, cia); | |
644 | } | |
645 | } | |
646 | ||
647 | ||
648 | #if !WITH_NetBSD_HOST | |
649 | #define do_fstatfs 0 | |
650 | #else | |
651 | STATIC_INLINE_EMUL_NETBSD void | |
652 | do_fstatfs(emulation *emul, | |
653 | unsigned call, | |
654 | const int arg0, | |
655 | cpu *processor, | |
656 | unsigned_word cia) | |
657 | { | |
658 | int fd = cpu_registers(processor)->gpr[arg0]; | |
659 | unsigned_word buf_addr = cpu_registers(processor)->gpr[arg0+1]; | |
660 | struct statfs buf; | |
661 | int status; | |
662 | ||
663 | if (WITH_TRACE && ppc_trace[trace_os_emul]) | |
664 | printf_filtered ("%d, 0x%lx", fd, (long)buf_addr); | |
665 | ||
666 | SYS(fstatfs); | |
667 | status = fstatfs(fd, (buf_addr == 0 ? NULL : &buf)); | |
668 | emul_write_status(processor, status, errno); | |
669 | if (status == 0) { | |
670 | if (buf_addr != 0) | |
671 | write_statfs(buf_addr, buf, processor, cia); | |
672 | } | |
673 | } | |
674 | #endif | |
675 | ||
676 | ||
677 | STATIC_INLINE_EMUL_NETBSD void | |
678 | do_stat(emulation *emul, | |
679 | unsigned call, | |
680 | const int arg0, | |
681 | cpu *processor, | |
682 | unsigned_word cia) | |
683 | { | |
684 | char path_buf[PATH_MAX]; | |
685 | unsigned_word path_addr = cpu_registers(processor)->gpr[arg0]; | |
686 | unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1]; | |
687 | char *path = emul_read_string(path_buf, path_addr, PATH_MAX, processor, cia); | |
688 | struct stat buf; | |
689 | int status; | |
690 | SYS(stat); | |
691 | status = stat(path, &buf); | |
692 | emul_write_status(processor, status, errno); | |
693 | if (status == 0) | |
694 | write_stat(stat_buf_addr, buf, processor, cia); | |
695 | } | |
696 | ||
697 | ||
698 | STATIC_INLINE_EMUL_NETBSD void | |
699 | do_fstat(emulation *emul, | |
700 | unsigned call, | |
701 | const int arg0, | |
702 | cpu *processor, | |
703 | unsigned_word cia) | |
704 | { | |
705 | int fd = cpu_registers(processor)->gpr[arg0]; | |
706 | unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1]; | |
707 | struct stat buf; | |
708 | SYS(fstat); | |
709 | emul_write_status(processor, fstat(fd, &buf), errno); | |
710 | write_stat(stat_buf_addr, buf, processor, cia); | |
711 | } | |
712 | ||
713 | ||
714 | STATIC_INLINE_EMUL_NETBSD void | |
715 | do_lstat(emulation *emul, | |
716 | unsigned call, | |
717 | const int arg0, | |
718 | cpu *processor, | |
719 | unsigned_word cia) | |
720 | { | |
721 | char path_buf[PATH_MAX]; | |
722 | unsigned_word path_addr = cpu_registers(processor)->gpr[arg0]; | |
723 | char *path = emul_read_string(path_buf, path_addr, PATH_MAX, processor, cia); | |
724 | unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1]; | |
725 | struct stat buf; | |
726 | SYS(lstat); | |
727 | emul_write_status(processor, stat(path, &buf), errno); | |
728 | write_stat(stat_buf_addr, buf, processor, cia); | |
729 | } | |
730 | ||
731 | ||
732 | #if !WITH_NetBSD_HOST | |
733 | #define do_getdirentries 0 | |
734 | #else | |
735 | STATIC_INLINE_EMUL_NETBSD void | |
736 | do_getdirentries(emulation *emul, | |
737 | unsigned call, | |
738 | const int arg0, | |
739 | cpu *processor, | |
740 | unsigned_word cia) | |
741 | { | |
742 | int fd = cpu_registers(processor)->gpr[arg0]; | |
743 | unsigned_word buf_addr = cpu_registers(processor)->gpr[arg0+1]; | |
744 | char *buf; | |
745 | int nbytes = cpu_registers(processor)->gpr[arg0+2]; | |
746 | unsigned_word basep_addr = cpu_registers(processor)->gpr[arg0+3]; | |
747 | long basep; | |
748 | int status; | |
749 | SYS(getdirentries); | |
750 | if (buf_addr != 0 && nbytes >= 0) | |
751 | buf = zalloc(nbytes); | |
752 | else | |
753 | buf = NULL; | |
754 | status = getdirentries(fd, | |
755 | (buf_addr == 0 ? NULL : buf), | |
756 | nbytes, | |
757 | (basep_addr == 0 ? NULL : &basep)); | |
758 | emul_write_status(processor, status, errno); | |
759 | if (basep_addr != 0) | |
760 | emul_write_word(basep_addr, basep, processor, cia); | |
761 | if (status > 0) | |
762 | write_direntries(buf_addr, buf, status, processor, cia); | |
763 | if (buf != NULL) | |
764 | zfree(buf); | |
765 | } | |
766 | #endif | |
767 | ||
768 | ||
769 | STATIC_INLINE_EMUL_NETBSD void | |
770 | do___syscall(emulation *emul, | |
771 | unsigned call, | |
772 | const int arg0, | |
773 | cpu *processor, | |
774 | unsigned_word cia) | |
775 | { | |
776 | SYS(__syscall); | |
777 | emul_do_call(emul, | |
778 | cpu_registers(processor)->gpr[arg0], | |
779 | arg0 + 1, | |
780 | processor, | |
781 | cia); | |
782 | } | |
783 | ||
784 | ||
785 | STATIC_INLINE_EMUL_NETBSD void | |
786 | do_lseek(emulation *emul, | |
787 | unsigned call, | |
788 | const int arg0, | |
789 | cpu *processor, | |
790 | unsigned_word cia) | |
791 | { | |
792 | int fildes = cpu_registers(processor)->gpr[arg0]; | |
793 | off_t offset = emul_read_gpr64(processor, arg0+2); | |
794 | int whence = cpu_registers(processor)->gpr[arg0+4]; | |
795 | off_t status; | |
796 | SYS(lseek); | |
797 | status = lseek(fildes, offset, whence); | |
798 | if (status == -1) | |
799 | emul_write_status(processor, -1, errno); | |
800 | else { | |
801 | emul_write_gpr64(processor, 3, status); | |
802 | } | |
803 | } | |
804 | ||
805 | ||
806 | STATIC_INLINE_EMUL_NETBSD void | |
807 | do___sysctl(emulation *emul, | |
808 | unsigned call, | |
809 | const int arg0, | |
810 | cpu *processor, | |
811 | unsigned_word cia) | |
812 | { | |
813 | /* call the arguments by their real name */ | |
814 | unsigned_word name = cpu_registers(processor)->gpr[arg0]; | |
815 | natural_word namelen = cpu_registers(processor)->gpr[arg0+1]; | |
816 | unsigned_word oldp = cpu_registers(processor)->gpr[arg0+2]; | |
817 | unsigned_word oldlenp = cpu_registers(processor)->gpr[arg0+3]; | |
818 | natural_word oldlen; | |
819 | natural_word mib; | |
820 | natural_word int_val; | |
821 | SYS(__sysctl); | |
822 | ||
823 | /* pluck out the management information base id */ | |
824 | if (namelen < 1) | |
825 | error("system_call()SYS___sysctl bad name[0]\n"); | |
826 | mib = vm_data_map_read_word(cpu_data_map(processor), | |
827 | name, | |
828 | processor, | |
829 | cia); | |
830 | name += sizeof(mib); | |
831 | ||
832 | /* see what to do with it ... */ | |
833 | switch (mib) { | |
834 | case 6/*CTL_HW*/: | |
835 | #if WITH_NetBSD_HOST && (CTL_HW != 6) | |
836 | # error "CTL_HW" | |
837 | #endif | |
838 | if (namelen < 2) | |
839 | error("system_call()SYS___sysctl - CTL_HW - bad name[1]\n"); | |
840 | mib = vm_data_map_read_word(cpu_data_map(processor), | |
841 | name, | |
842 | processor, | |
843 | cia); | |
844 | name += sizeof(mib); | |
845 | switch (mib) { | |
846 | case 7/*HW_PAGESIZE*/: | |
847 | #if WITH_NetBSD_HOST && (HW_PAGESIZE != 7) | |
848 | # error "HW_PAGESIZE" | |
849 | #endif | |
850 | oldlen = vm_data_map_read_word(cpu_data_map(processor), | |
851 | oldlenp, | |
852 | processor, | |
853 | cia); | |
854 | if (sizeof(natural_word) > oldlen) | |
855 | error("system_call()sysctl - CTL_HW.HW_PAGESIZE - to small\n"); | |
856 | int_val = 8192; | |
857 | oldlen = sizeof(int_val); | |
858 | emul_write_word(oldp, int_val, processor, cia); | |
859 | emul_write_word(oldlenp, oldlen, processor, cia); | |
860 | break; | |
861 | default: | |
862 | error("sysctl() CTL_HW.%d unknown\n", mib); | |
863 | break; | |
864 | } | |
865 | break; | |
866 | default: | |
867 | error("sysctl() name[0]=%s unknown\n", (int)mib); | |
868 | break; | |
869 | } | |
870 | cpu_registers(processor)->gpr[3] = 0; | |
871 | } | |
872 | ||
873 | ||
874 | ||
875 | static emul_call_descriptor netbsd_descriptors[] = { | |
876 | /* 0 */ { 0, "syscall", { 0, }, 0 }, | |
877 | /* 1 */ { do_exit, "exit", { 0, }, 0 }, | |
878 | /* 2 */ { 0, "fork", { 0, }, 0 }, | |
879 | /* 3 */ { do_read, "read", { 0, }, 0 }, | |
880 | /* 4 */ { do_write, "write", { 0, }, 0 }, | |
881 | /* 5 */ { do_open, "open", { 0, }, 0 }, | |
882 | /* 6 */ { do_close, "close", { 0, }, 0 }, | |
883 | /* 7 */ { 0, "wait4", { 0, }, 0 }, | |
884 | { 0, }, /* 8 is old creat */ | |
885 | /* 9 */ { 0, "link", { 0, }, 0 }, | |
886 | /* 10 */ { 0, "unlink", { 0, }, 0 }, | |
887 | { 0, }, /* 11 is obsolete execv */ | |
888 | /* 12 */ { 0, "chdir", { 0, }, 0 }, | |
889 | /* 13 */ { 0, "fchdir", { 0, }, 0 }, | |
890 | /* 14 */ { 0, "mknod", { 0, }, 0 }, | |
891 | /* 15 */ { 0, "chmod", { 0, }, 0 }, | |
892 | /* 16 */ { 0, "chown", { 0, }, 0 }, | |
893 | /* 17 */ { do_break, "break", { 0, }, 0 }, | |
894 | /* 18 */ { 0, "getfsstat", { 0, }, 0 }, | |
895 | { 0, }, /* 19 is old lseek */ | |
896 | /* 20 */ { do_getpid, "getpid", { 0, }, 0 }, | |
897 | /* 21 */ { 0, "mount", { 0, }, 0 }, | |
898 | /* 22 */ { 0, "unmount", { 0, }, 0 }, | |
899 | /* 23 */ { 0, "setuid", { 0, }, 0 }, | |
900 | /* 24 */ { do_getuid, "getuid", { 0, }, 0 }, | |
901 | /* 25 */ { do_geteuid, "geteuid", { 0, }, 0 }, | |
902 | /* 26 */ { 0, "ptrace", { 0, }, 0 }, | |
903 | /* 27 */ { 0, "recvmsg", { 0, }, 0 }, | |
904 | /* 28 */ { 0, "sendmsg", { 0, }, 0 }, | |
905 | /* 29 */ { 0, "recvfrom", { 0, }, 0 }, | |
906 | /* 30 */ { 0, "accept", { 0, }, 0 }, | |
907 | /* 31 */ { 0, "getpeername", { 0, }, 0 }, | |
908 | /* 32 */ { 0, "getsockname", { 0, }, 0 }, | |
909 | /* 33 */ { 0, "access", { 0, }, 0 }, | |
910 | /* 34 */ { 0, "chflags", { 0, }, 0 }, | |
911 | /* 35 */ { 0, "fchflags", { 0, }, 0 }, | |
912 | /* 36 */ { 0, "sync", { 0, }, 0 }, | |
913 | /* 37 */ { do_kill, "kill", { 0, }, 0 }, | |
914 | { 0, }, /* 38 is old stat */ | |
915 | /* 39 */ { 0, "getppid", { 0, }, 0 }, | |
916 | { 0, }, /* 40 is old lstat */ | |
917 | /* 41 */ { do_dup, "dup", { 0, }, 0 }, | |
918 | /* 42 */ { 0, "pipe", { 0, }, 0 }, | |
919 | /* 43 */ { do_getegid, "getegid", { 0, }, 0 }, | |
920 | /* 44 */ { 0, "profil", { 0, }, 0 }, | |
921 | /* 45 */ { 0, "ktrace", { 0, }, 0 }, | |
922 | /* 46 */ { 0, "sigaction", { 0, }, 0 }, | |
923 | /* 47 */ { do_getgid, "getgid", { 0, }, 0 }, | |
924 | /* 48 */ { do_sigprocmask, "sigprocmask", { 0, }, 0 }, | |
925 | /* 49 */ { 0, "getlogin", { 0, }, 0 }, | |
926 | /* 50 */ { 0, "setlogin", { 0, }, 0 }, | |
927 | /* 51 */ { 0, "acct", { 0, }, 0 }, | |
928 | /* 52 */ { 0, "sigpending", { 0, }, 0 }, | |
929 | /* 53 */ { 0, "sigaltstack", { 0, }, 0 }, | |
930 | /* 54 */ { do_ioctl, "ioctl", { 0, }, 0 }, | |
931 | /* 55 */ { 0, "reboot", { 0, }, 0 }, | |
932 | /* 56 */ { 0, "revoke", { 0, }, 0 }, | |
933 | /* 57 */ { 0, "symlink", { 0, }, 0 }, | |
934 | /* 58 */ { 0, "readlink", { 0, }, 0 }, | |
935 | /* 59 */ { 0, "execve", { 0, }, 0 }, | |
936 | /* 60 */ { do_umask, "umask", { 0, }, 0 }, | |
937 | /* 61 */ { 0, "chroot", { 0, }, 0 }, | |
938 | { 0, }, /* 62 is old fstat */ | |
939 | { 0, }, /* 63 is old getkerninfo */ | |
940 | { 0, }, /* 64 is old getpagesize */ | |
941 | /* 65 */ { 0, "msync", { 0, }, 0 }, | |
942 | /* 66 */ { 0, "vfork", { 0, }, 0 }, | |
943 | { 0, }, /* 67 is obsolete vread */ | |
944 | { 0, }, /* 68 is obsolete vwrite */ | |
945 | /* 69 */ { 0, "sbrk", { 0, }, 0 }, | |
946 | /* 70 */ { 0, "sstk", { 0, }, 0 }, | |
947 | { 0, }, /* 71 is old mmap */ | |
948 | /* 72 */ { 0, "vadvise", { 0, }, 0 }, | |
949 | /* 73 */ { 0, "munmap", { 0, }, 0 }, | |
950 | /* 74 */ { 0, "mprotect", { 0, }, 0 }, | |
951 | /* 75 */ { 0, "madvise", { 0, }, 0 }, | |
952 | { 0, }, /* 76 is obsolete vhangup */ | |
953 | { 0, }, /* 77 is obsolete vlimit */ | |
954 | /* 78 */ { 0, "mincore", { 0, }, 0 }, | |
955 | /* 79 */ { 0, "getgroups", { 0, }, 0 }, | |
956 | /* 80 */ { 0, "setgroups", { 0, }, 0 }, | |
957 | /* 81 */ { 0, "getpgrp", { 0, }, 0 }, | |
958 | /* 82 */ { 0, "setpgid", { 0, }, 0 }, | |
959 | /* 83 */ { 0, "setitimer", { 0, }, 0 }, | |
960 | { 0, }, /* 84 is old wait */ | |
961 | /* 85 */ { 0, "swapon", { 0, }, 0 }, | |
962 | /* 86 */ { 0, "getitimer", { 0, }, 0 }, | |
963 | { 0, }, /* 87 is old gethostname */ | |
964 | { 0, }, /* 88 is old sethostname */ | |
965 | { 0, }, /* 89 is old getdtablesize */ | |
966 | { do_dup2, "dup2", { 0, }, 0 }, | |
967 | { 0, }, /* 91 */ | |
968 | /* 92 */ { do_fcntl, "fcntl", { 0, }, 0 }, | |
969 | /* 93 */ { 0, "select", { 0, }, 0 }, | |
970 | { 0, }, /* 94 */ | |
971 | /* 95 */ { 0, "fsync", { 0, }, 0 }, | |
972 | /* 96 */ { 0, "setpriority", { 0, }, 0 }, | |
973 | /* 97 */ { 0, "socket", { 0, }, 0 }, | |
974 | /* 98 */ { 0, "connect", { 0, }, 0 }, | |
975 | { 0, }, /* 99 is old accept */ | |
976 | /* 100 */ { 0, "getpriority", { 0, }, 0 }, | |
977 | { 0, }, /* 101 is old send */ | |
978 | { 0, }, /* 102 is old recv */ | |
979 | /* 103 */ { 0, "sigreturn", { 0, }, 0 }, | |
980 | /* 104 */ { 0, "bind", { 0, }, 0 }, | |
981 | /* 105 */ { 0, "setsockopt", { 0, }, 0 }, | |
982 | /* 106 */ { 0, "listen", { 0, }, 0 }, | |
983 | { 0, }, /* 107 is obsolete vtimes */ | |
984 | { 0, }, /* 108 is old sigvec */ | |
985 | { 0, }, /* 109 is old sigblock */ | |
986 | { 0, }, /* 110 is old sigsetmask */ | |
987 | /* 111 */ { 0, "sigsuspend", { 0, }, 0 }, | |
988 | { 0, }, /* 112 is old sigstack */ | |
989 | { 0, }, /* 113 is old recvmsg */ | |
990 | { 0, }, /* 114 is old sendmsg */ | |
991 | /* - is obsolete vtrace */ { 0, "vtrace 115", { 0, }, 0 }, | |
992 | /* 116 */ { do_gettimeofday, "gettimeofday", { 0, }, 0 }, | |
993 | /* 117 */ { do_getrusage, "getrusage", { 0, }, 0 }, | |
994 | /* 118 */ { 0, "getsockopt", { 0, }, 0 }, | |
995 | /* 119 */ { 0, "resuba", { 0, }, 0 }, | |
996 | /* 120 */ { 0, "readv", { 0, }, 0 }, | |
997 | /* 121 */ { 0, "writev", { 0, }, 0 }, | |
998 | /* 122 */ { 0, "settimeofday", { 0, }, 0 }, | |
999 | /* 123 */ { 0, "fchown", { 0, }, 0 }, | |
1000 | /* 124 */ { 0, "fchmod", { 0, }, 0 }, | |
1001 | { 0, }, /* 125 is old recvfrom */ | |
1002 | { 0, }, /* 126 is old setreuid */ | |
1003 | { 0, }, /* 127 is old setregid */ | |
1004 | /* 128 */ { 0, "rename", { 0, }, 0 }, | |
1005 | { 0, }, /* 129 is old truncate */ | |
1006 | { 0, }, /* 130 is old ftruncate */ | |
1007 | /* 131 */ { 0, "flock", { 0, }, 0 }, | |
1008 | /* 132 */ { 0, "mkfifo", { 0, }, 0 }, | |
1009 | /* 133 */ { 0, "sendto", { 0, }, 0 }, | |
1010 | /* 134 */ { 0, "shutdown", { 0, }, 0 }, | |
1011 | /* 135 */ { 0, "socketpair", { 0, }, 0 }, | |
1012 | /* 136 */ { 0, "mkdir", { 0, }, 0 }, | |
1013 | /* 137 */ { 0, "rmdir", { 0, }, 0 }, | |
1014 | /* 138 */ { 0, "utimes", { 0, }, 0 }, | |
1015 | { 0, }, /* 139 is obsolete 4.2 sigreturn */ | |
1016 | /* 140 */ { 0, "adjtime", { 0, }, 0 }, | |
1017 | { 0, }, /* 141 is old getpeername */ | |
1018 | { 0, }, /* 142 is old gethostid */ | |
1019 | { 0, }, /* 143 is old sethostid */ | |
1020 | { 0, }, /* 144 is old getrlimit */ | |
1021 | { 0, }, /* 145 is old setrlimit */ | |
1022 | { 0, }, /* 146 is old killpg */ | |
1023 | /* 147 */ { 0, "setsid", { 0, }, 0 }, | |
1024 | /* 148 */ { 0, "quotactl", { 0, }, 0 }, | |
1025 | { 0, }, /* 149 is old quota */ | |
1026 | { 0, }, /* 150 is old getsockname */ | |
1027 | { 0, }, /* 151 */ | |
1028 | { 0, }, /* 152 */ | |
1029 | { 0, }, /* 153 */ | |
1030 | { 0, }, /* 154 */ | |
1031 | /* 155 */ { 0, "nfssvc", { 0, }, 0 }, | |
1032 | { 0, }, /* 156 is old getdirentries */ | |
1033 | /* 157 */ { 0, "statfs", { 0, }, 0 }, | |
1034 | /* 158 */ { do_fstatfs, "fstatfs", { 0, }, 0 }, | |
1035 | { 0, }, /* 159 */ | |
1036 | { 0, }, /* 160 */ | |
1037 | /* 161 */ { 0, "getfh", { 0, }, 0 }, | |
1038 | { 0, }, /* 162 is old getdomainname */ | |
1039 | { 0, }, /* 163 is old setdomainname */ | |
1040 | { 0, }, /* 164 is old uname */ | |
1041 | /* 165 */ { 0, "sysarch", { 0, }, 0 }, | |
1042 | { 0, }, /* 166 */ | |
1043 | { 0, }, /* 167 */ | |
1044 | { 0, }, /* 168 */ | |
1045 | /* 169 */ { 0, "semsys", { 0, }, 0 }, | |
1046 | /* 170 */ { 0, "msgsys", { 0, }, 0 }, | |
1047 | /* 171 */ { 0, "shmsys", { 0, }, 0 }, | |
1048 | { 0, }, /* 172 */ | |
1049 | { 0, }, /* 173 */ | |
1050 | { 0, }, /* 174 */ | |
1051 | { 0, }, /* 175 */ | |
1052 | { 0, }, /* 176 */ | |
1053 | { 0, }, /* 177 */ | |
1054 | { 0, }, /* 178 */ | |
1055 | { 0, }, /* 179 */ | |
1056 | { 0, }, /* 180 */ | |
1057 | /* 181 */ { 0, "setgid", { 0, }, 0 }, | |
1058 | /* 182 */ { 0, "setegid", { 0, }, 0 }, | |
1059 | /* 183 */ { 0, "seteuid", { 0, }, 0 }, | |
1060 | /* 184 */ { 0, "lfs_bmapv", { 0, }, 0 }, | |
1061 | /* 185 */ { 0, "lfs_markv", { 0, }, 0 }, | |
1062 | /* 186 */ { 0, "lfs_segclean", { 0, }, 0 }, | |
1063 | /* 187 */ { 0, "lfs_segwait", { 0, }, 0 }, | |
1064 | /* 188 */ { do_stat, "stat", { 0, }, 0 }, | |
1065 | /* 189 */ { do_fstat, "fstat", { 0, }, 0 }, | |
1066 | /* 190 */ { do_lstat, "lstat", { 0, }, 0 }, | |
1067 | /* 191 */ { 0, "pathconf", { 0, }, 0 }, | |
1068 | /* 192 */ { 0, "fpathconf", { 0, }, 0 }, | |
1069 | { 0, }, /* 193 */ | |
1070 | /* 194 */ { 0, "getrlimit", { 0, }, 0 }, | |
1071 | /* 195 */ { 0, "setrlimit", { 0, }, 0 }, | |
1072 | /* 196 */ { do_getdirentries, "getdirentries", { 0, }, 0 }, | |
1073 | /* 197 */ { 0, "mmap", { 0, }, 0 }, | |
1074 | /* 198 */ { do___syscall, "__syscall", { 0, }, 0 }, | |
1075 | /* 199 */ { do_lseek, "lseek", { 0, }, 0 }, | |
1076 | /* 200 */ { 0, "truncate", { 0, }, 0 }, | |
1077 | /* 201 */ { 0, "ftruncate", { 0, }, 0 }, | |
1078 | /* 202 */ { do___sysctl, "__sysctl", { 0, }, 0 }, | |
1079 | /* 203 */ { 0, "mlock", { 0, }, 0 }, | |
1080 | /* 204 */ { 0, "munlock", { 0, }, 0 }, | |
1081 | }; | |
1082 | ||
1083 | static char *(netbsd_error_names[]) = { | |
1084 | /* 0 */ "ESUCCESS", | |
1085 | /* 1 */ "EPERM", | |
1086 | /* 2 */ "ENOENT", | |
1087 | /* 3 */ "ESRCH", | |
1088 | /* 4 */ "EINTR", | |
1089 | /* 5 */ "EIO", | |
1090 | /* 6 */ "ENXIO", | |
1091 | /* 7 */ "E2BIG", | |
1092 | /* 8 */ "ENOEXEC", | |
1093 | /* 9 */ "EBADF", | |
1094 | /* 10 */ "ECHILD", | |
1095 | /* 11 */ "EDEADLK", | |
1096 | /* 12 */ "ENOMEM", | |
1097 | /* 13 */ "EACCES", | |
1098 | /* 14 */ "EFAULT", | |
1099 | /* 15 */ "ENOTBLK", | |
1100 | /* 16 */ "EBUSY", | |
1101 | /* 17 */ "EEXIST", | |
1102 | /* 18 */ "EXDEV", | |
1103 | /* 19 */ "ENODEV", | |
1104 | /* 20 */ "ENOTDIR", | |
1105 | /* 21 */ "EISDIR", | |
1106 | /* 22 */ "EINVAL", | |
1107 | /* 23 */ "ENFILE", | |
1108 | /* 24 */ "EMFILE", | |
1109 | /* 25 */ "ENOTTY", | |
1110 | /* 26 */ "ETXTBSY", | |
1111 | /* 27 */ "EFBIG", | |
1112 | /* 28 */ "ENOSPC", | |
1113 | /* 29 */ "ESPIPE", | |
1114 | /* 30 */ "EROFS", | |
1115 | /* 31 */ "EMLINK", | |
1116 | /* 32 */ "EPIPE", | |
1117 | /* 33 */ "EDOM", | |
1118 | /* 34 */ "ERANGE", | |
1119 | /* 35 */ "EAGAIN", | |
1120 | /* 36 */ "EINPROGRESS", | |
1121 | /* 37 */ "EALREADY", | |
1122 | /* 38 */ "ENOTSOCK", | |
1123 | /* 39 */ "EDESTADDRREQ", | |
1124 | /* 40 */ "EMSGSIZE", | |
1125 | /* 41 */ "EPROTOTYPE", | |
1126 | /* 42 */ "ENOPROTOOPT", | |
1127 | /* 43 */ "EPROTONOSUPPORT", | |
1128 | /* 44 */ "ESOCKTNOSUPPORT", | |
1129 | /* 45 */ "EOPNOTSUPP", | |
1130 | /* 46 */ "EPFNOSUPPORT", | |
1131 | /* 47 */ "EAFNOSUPPORT", | |
1132 | /* 48 */ "EADDRINUSE", | |
1133 | /* 49 */ "EADDRNOTAVAIL", | |
1134 | /* 50 */ "ENETDOWN", | |
1135 | /* 51 */ "ENETUNREACH", | |
1136 | /* 52 */ "ENETRESET", | |
1137 | /* 53 */ "ECONNABORTED", | |
1138 | /* 54 */ "ECONNRESET", | |
1139 | /* 55 */ "ENOBUFS", | |
1140 | /* 56 */ "EISCONN", | |
1141 | /* 57 */ "ENOTCONN", | |
1142 | /* 58 */ "ESHUTDOWN", | |
1143 | /* 59 */ "ETOOMANYREFS", | |
1144 | /* 60 */ "ETIMEDOUT", | |
1145 | /* 61 */ "ECONNREFUSED", | |
1146 | /* 62 */ "ELOOP", | |
1147 | /* 63 */ "ENAMETOOLONG", | |
1148 | /* 64 */ "EHOSTDOWN", | |
1149 | /* 65 */ "EHOSTUNREACH", | |
1150 | /* 66 */ "ENOTEMPTY", | |
1151 | /* 67 */ "EPROCLIM", | |
1152 | /* 68 */ "EUSERS", | |
1153 | /* 69 */ "EDQUOT", | |
1154 | /* 70 */ "ESTALE", | |
1155 | /* 71 */ "EREMOTE", | |
1156 | /* 72 */ "EBADRPC", | |
1157 | /* 73 */ "ERPCMISMATCH", | |
1158 | /* 74 */ "EPROGUNAVAIL", | |
1159 | /* 75 */ "EPROGMISMATCH", | |
1160 | /* 76 */ "EPROCUNAVAIL", | |
1161 | /* 77 */ "ENOLCK", | |
1162 | /* 78 */ "ENOSYS", | |
1163 | /* 79 */ "EFTYPE", | |
1164 | /* 80 */ "EAUTH", | |
1165 | /* 81 */ "ENEEDAUTH", | |
1166 | /* 81 */ "ELAST", | |
1167 | }; | |
1168 | ||
1169 | static char *(netbsd_signal_names[]) = { | |
1170 | /* 0 */ 0, | |
1171 | /* 1 */ "SIGHUP", | |
1172 | /* 2 */ "SIGINT", | |
1173 | /* 3 */ "SIGQUIT", | |
1174 | /* 4 */ "SIGILL", | |
1175 | /* 5 */ "SIGTRAP", | |
1176 | /* 6 */ "SIGABRT", | |
1177 | /* 7 */ "SIGEMT", | |
1178 | /* 8 */ "SIGFPE", | |
1179 | /* 9 */ "SIGKILL", | |
1180 | /* 10 */ "SIGBUS", | |
1181 | /* 11 */ "SIGSEGV", | |
1182 | /* 12 */ "SIGSYS", | |
1183 | /* 13 */ "SIGPIPE", | |
1184 | /* 14 */ "SIGALRM", | |
1185 | /* 15 */ "SIGTERM", | |
1186 | /* 16 */ "SIGURG", | |
1187 | /* 17 */ "SIGSTOP", | |
1188 | /* 18 */ "SIGTSTP", | |
1189 | /* 19 */ "SIGCONT", | |
1190 | /* 20 */ "SIGCHLD", | |
1191 | /* 21 */ "SIGTTIN", | |
1192 | /* 22 */ "SIGTTOU", | |
1193 | /* 23 */ "SIGIO", | |
1194 | /* 24 */ "SIGXCPU", | |
1195 | /* 25 */ "SIGXFSZ", | |
1196 | /* 26 */ "SIGVTALRM", | |
1197 | /* 27 */ "SIGPROF", | |
1198 | /* 28 */ "SIGWINCH", | |
1199 | /* 29 */ "SIGINFO", | |
1200 | /* 30 */ "SIGUSR1", | |
1201 | /* 31 */ "SIGUSR2", | |
1202 | }; | |
1203 | ||
1204 | emulation emul_netbsd = { | |
1205 | netbsd_descriptors, | |
1206 | sizeof(netbsd_descriptors) / sizeof(netbsd_descriptors[0]), | |
1207 | netbsd_error_names, | |
1208 | sizeof(netbsd_error_names) / sizeof(netbsd_error_names[0]), | |
1209 | netbsd_signal_names, | |
1210 | sizeof(netbsd_signal_names) / sizeof(netbsd_signal_names[0]), | |
1211 | }; | |
1212 | ||
1213 | #endif /* _EMUL_NETBSD_C_ */ |