Commit | Line | Data |
---|---|---|
cb7a6892 MM |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au> | |
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 _SYSTEM_C_ | |
23 | #define _SYSTEM_C_ | |
24 | ||
25 | #include <sys/types.h> | |
26 | #include <sys/stat.h> | |
27 | #include <stdio.h> | |
28 | #include <stdlib.h> | |
29 | #include <unistd.h> | |
30 | #include <signal.h> | |
31 | #include <sys/errno.h> | |
32 | #include <sys/param.h> | |
dec38dac | 33 | #include <fcntl.h> |
cb7a6892 MM |
34 | |
35 | #if (NetBSD >= 199306) /* here NetBSD as that is what we're emulating */ | |
36 | #include <sys/syscall.h> /* FIXME - should not be including this one */ | |
37 | #include <sys/sysctl.h> | |
38 | #endif | |
39 | ||
40 | #if (BSD < 199306) /* here BSD as just a bug */ | |
41 | extern int errno; | |
42 | #endif | |
43 | ||
44 | #include "cpu.h" | |
45 | #include "idecode.h" | |
46 | #include "system.h" | |
47 | ||
48 | ||
dec38dac MM |
49 | #ifndef STATIC_INLINE_SYSTEM |
50 | #define STATIC_INLINE_SYSTEM STATIC_INLINE | |
cb7a6892 | 51 | #endif |
cb7a6892 | 52 | |
cb7a6892 | 53 | |
dec38dac MM |
54 | #if (NetBSD >= 199306) |
55 | #define SYS(X) ASSERT(call == (SYS_##X)) | |
56 | #else | |
57 | #define SYS(X) | |
cb7a6892 | 58 | #endif |
cb7a6892 | 59 | |
dec38dac MM |
60 | #if (NetBSD >= 199306 && PATH_MAX != 1024) |
61 | #error "PATH_MAX not 1024" | |
62 | #elif !defined(PATH_MAX) | |
63 | #define PATH_MAX 1024 | |
cb7a6892 | 64 | #endif |
cb7a6892 MM |
65 | |
66 | ||
dec38dac MM |
67 | STATIC_INLINE_SYSTEM char * |
68 | read_string(cpu *processor, | |
69 | char *dest, | |
70 | unsigned_word addr, | |
71 | unsigned nr_bytes) | |
72 | { | |
73 | unsigned nr_moved = 0; | |
74 | if (addr == 0) | |
75 | return NULL; | |
76 | while (1) { | |
77 | if (vm_data_map_read_buffer(cpu_data_map(processor), | |
78 | &dest[nr_moved], | |
79 | addr + nr_moved, | |
80 | sizeof(dest[nr_moved])) | |
81 | != sizeof(dest[nr_moved])) | |
82 | return NULL; | |
83 | if (dest[nr_moved] == '\0' || nr_moved >= nr_bytes) | |
cb7a6892 | 84 | break; |
dec38dac MM |
85 | nr_moved++; |
86 | } | |
87 | dest[nr_moved] = '\0'; | |
88 | return dest; | |
89 | } | |
cb7a6892 | 90 | |
cb7a6892 | 91 | |
dec38dac MM |
92 | STATIC_INLINE_SYSTEM void |
93 | write_status(cpu *processor, | |
94 | int status) | |
95 | { | |
96 | cpu_registers(processor)->gpr[3] = status; | |
97 | if (status < 0) | |
98 | cpu_registers(processor)->gpr[0] = errno; | |
99 | else | |
100 | cpu_registers(processor)->gpr[0] = 0; | |
101 | } | |
cb7a6892 MM |
102 | |
103 | ||
dec38dac MM |
104 | STATIC_INLINE_SYSTEM void |
105 | write_stat(cpu *processor, | |
106 | unsigned_word addr, | |
107 | struct stat buf) | |
108 | { | |
109 | int nr_moved; | |
110 | H2T(buf.st_dev); | |
111 | H2T(buf.st_ino); | |
112 | H2T(buf.st_mode); | |
113 | H2T(buf.st_nlink); | |
114 | H2T(buf.st_uid); | |
115 | H2T(buf.st_gid); | |
116 | H2T(buf.st_rdev); | |
117 | H2T(buf.st_size); | |
118 | H2T(buf.st_atime); | |
119 | /* H2T(buf.st_spare1); */ | |
120 | H2T(buf.st_mtime); | |
121 | /* H2T(buf.st_spare2); */ | |
122 | H2T(buf.st_ctime); | |
123 | /* H2T(buf.st_spare3); */ | |
124 | H2T(buf.st_blksize); | |
125 | H2T(buf.st_blocks); | |
126 | #if (NetBSD >= 199306) | |
127 | H2T(buf.st_flags); | |
128 | H2T(buf.st_gen); | |
cb7a6892 | 129 | #endif |
dec38dac MM |
130 | nr_moved = vm_data_map_write_buffer(cpu_data_map(processor), |
131 | &buf, | |
132 | addr, | |
133 | sizeof(buf), | |
134 | 0/*violate_ro*/); | |
135 | if (nr_moved != sizeof(buf)) | |
136 | error("write_stat() write failed\n"); | |
137 | } | |
138 | ||
139 | ||
140 | STATIC_INLINE_SYSTEM void | |
141 | do_exit(unsigned call, | |
142 | cpu *processor, | |
143 | unsigned_word cia) | |
144 | { | |
145 | int status = (int)cpu_registers(processor)->gpr[3]; | |
146 | SYS(exit); | |
147 | cpu_halt(processor, cia, was_exited, status); | |
148 | } | |
cb7a6892 MM |
149 | |
150 | ||
dec38dac MM |
151 | STATIC_INLINE_SYSTEM void |
152 | do_read(unsigned call, | |
153 | cpu *processor, | |
154 | unsigned_word cia) | |
155 | { | |
156 | void *scratch_buffer; | |
157 | int d = (int)cpu_registers(processor)->gpr[3]; | |
158 | unsigned_word buf = cpu_registers(processor)->gpr[4]; | |
159 | int nbytes = cpu_registers(processor)->gpr[5]; | |
160 | int status; | |
161 | int nr_moved; | |
162 | SYS(read); | |
163 | ||
164 | /* get a tempoary bufer */ | |
165 | scratch_buffer = zalloc(nbytes); | |
166 | ||
167 | /* check if buffer exists by reading it */ | |
168 | nr_moved = vm_data_map_read_buffer(cpu_data_map(processor), | |
169 | scratch_buffer, | |
170 | buf, | |
171 | nbytes); | |
172 | if (nr_moved != nbytes) | |
173 | error("system_call()read - check on buffer failed\n"); | |
174 | ||
175 | /* read */ | |
176 | #if 0 | |
177 | if (d == 0) { | |
178 | status = fread (scratch_buffer, 1, nbytes, stdin); | |
179 | if (status == 0 && ferror (stdin)) | |
180 | status = -1; | |
181 | } | |
cb7a6892 | 182 | #endif |
dec38dac MM |
183 | status = read (d, scratch_buffer, nbytes); |
184 | ||
185 | if (status == -1) { | |
186 | cpu_registers(processor)->gpr[0] = errno; | |
187 | } else { | |
188 | cpu_registers(processor)->gpr[3] = status; | |
189 | ||
190 | if (status > 0) { | |
cb7a6892 | 191 | nr_moved = vm_data_map_write_buffer(cpu_data_map(processor), |
dec38dac MM |
192 | scratch_buffer, |
193 | buf, | |
194 | status, | |
cb7a6892 | 195 | 0/*violate_ro*/); |
dec38dac MM |
196 | if (nr_moved != status) |
197 | error("system_call()read - write to buffer failed\n"); | |
cb7a6892 | 198 | } |
dec38dac MM |
199 | } |
200 | ||
201 | zfree(scratch_buffer); | |
202 | } | |
cb7a6892 MM |
203 | |
204 | ||
dec38dac MM |
205 | STATIC_INLINE_SYSTEM void |
206 | do_write(unsigned call, | |
207 | cpu *processor, | |
208 | unsigned_word cia) | |
209 | { | |
210 | void *scratch_buffer = NULL; | |
211 | int nr_moved; | |
212 | int d = (int)cpu_registers(processor)->gpr[3]; | |
213 | unsigned_word buf = cpu_registers(processor)->gpr[4]; | |
214 | int nbytes = cpu_registers(processor)->gpr[5]; | |
215 | int status; | |
216 | SYS(write); | |
217 | ||
218 | /* get a tempoary bufer */ | |
219 | scratch_buffer = zalloc(nbytes); /* FIXME - nbytes == 0 */ | |
220 | ||
221 | /* copy in */ | |
222 | nr_moved = vm_data_map_read_buffer(cpu_data_map(processor), | |
223 | scratch_buffer, | |
224 | buf, | |
225 | nbytes); | |
226 | if (nr_moved != nbytes) { | |
227 | /* FIXME - should handle better */ | |
228 | error("system_call()write copy failed (nr_moved=%d != nbytes=%d)\n", | |
229 | nr_moved, nbytes); | |
230 | } | |
231 | ||
232 | /* write */ | |
233 | status = write(d, scratch_buffer, nbytes); | |
234 | if (status == -1) { | |
235 | cpu_registers(processor)->gpr[0] = errno; | |
236 | } | |
237 | cpu_registers(processor)->gpr[3] = status; | |
238 | ||
239 | zfree(scratch_buffer); | |
240 | } | |
241 | ||
242 | ||
243 | STATIC_INLINE_SYSTEM void | |
244 | do_open(unsigned call, | |
245 | cpu *processor, | |
246 | unsigned_word cia) | |
247 | { | |
248 | unsigned_word path_addr = cpu_registers(processor)->gpr[3]; | |
249 | char path_buf[PATH_MAX]; | |
250 | char *path = read_string(processor, path_buf, path_addr, PATH_MAX); | |
251 | int flags = (int)cpu_registers(processor)->gpr[4]; | |
252 | int mode = (int)cpu_registers(processor)->gpr[4]; | |
253 | SYS(open); | |
254 | write_status(processor, open(path, flags, mode)); | |
255 | } | |
256 | ||
257 | ||
258 | STATIC_INLINE_SYSTEM void | |
259 | do_close(unsigned call, | |
260 | cpu *processor, | |
261 | unsigned_word cia) | |
262 | { | |
263 | int d = (int)cpu_registers(processor)->gpr[3]; | |
264 | SYS(close); | |
265 | write_status(processor, close(d)); | |
266 | } | |
267 | ||
268 | ||
269 | STATIC_INLINE_SYSTEM void | |
270 | do_break(unsigned call, | |
271 | cpu *processor, | |
272 | unsigned_word cia) | |
273 | /* just pass this onto the `vm' device */ | |
274 | { | |
275 | psim *system = cpu_system(processor); | |
276 | const device *vm = psim_device(system, "/vm"); | |
277 | SYS(break); | |
278 | vm->callback->ioctl(vm, | |
279 | system, | |
280 | processor, | |
281 | cia, | |
282 | 0, /*ioctl*/ | |
283 | NULL); /*ioctl-data*/ | |
284 | } | |
285 | ||
286 | ||
287 | STATIC_INLINE_SYSTEM void | |
288 | do_getpid(unsigned call, | |
289 | cpu *processor, | |
290 | unsigned_word cia) | |
291 | { | |
292 | SYS(getpid); | |
293 | cpu_registers(processor)->gpr[3] = (int)getpid(); | |
294 | } | |
295 | ||
296 | ||
297 | STATIC_INLINE_SYSTEM void | |
298 | do_getuid(unsigned call, | |
299 | cpu *processor, | |
300 | unsigned_word cia) | |
301 | { | |
302 | SYS(getuid); | |
303 | cpu_registers(processor)->gpr[3] = (int)getuid(); | |
304 | } | |
305 | ||
306 | ||
307 | STATIC_INLINE_SYSTEM void | |
308 | do_geteuid(unsigned call, | |
309 | cpu *processor, | |
310 | unsigned_word cia) | |
311 | { | |
312 | SYS(geteuid); | |
313 | cpu_registers(processor)->gpr[3] = (int)geteuid(); | |
314 | } | |
315 | ||
316 | ||
317 | STATIC_INLINE_SYSTEM void | |
318 | do_kill(unsigned call, | |
319 | cpu *processor, | |
320 | unsigned_word cia) | |
321 | { | |
322 | pid_t pid = cpu_registers(processor)->gpr[3]; | |
323 | int sig = cpu_registers(processor)->gpr[4]; | |
324 | SYS(kill); | |
325 | error("SYS_kill - more to this than just a kill\n"); | |
326 | cpu_halt(processor, cia, was_signalled, sig); | |
327 | } | |
328 | ||
329 | ||
330 | STATIC_INLINE_SYSTEM void | |
331 | do_sigprocmask(unsigned call, | |
332 | cpu *processor, | |
333 | unsigned_word cia) | |
334 | { | |
335 | natural_word how = cpu_registers(processor)->gpr[3]; | |
336 | unsigned_word set = cpu_registers(processor)->gpr[4]; | |
337 | unsigned_word oset = cpu_registers(processor)->gpr[5]; | |
338 | SYS(sigprocmask); | |
339 | TRACE(trace_system, ("SYS_sigprocmask: how=%d, set=0x%x, oset=0x%x\n", | |
340 | how, set, oset)); | |
341 | cpu_registers(processor)->gpr[3] = 0; | |
342 | cpu_registers(processor)->gpr[4] = set; | |
343 | } | |
344 | ||
345 | ||
346 | STATIC_INLINE_SYSTEM void | |
347 | do_ioctl(unsigned call, | |
348 | cpu *processor, | |
349 | unsigned_word cia) | |
350 | { | |
351 | SYS(ioctl); | |
352 | TRACE(trace_system, ("SYS_ioctl: d=%d, request=0x%x, argp=0x%x\n", | |
353 | cpu_registers(processor)->gpr[3], cpu_registers(processor)->gpr[4], cpu_registers(processor)->gpr[5])); | |
354 | cpu_registers(processor)->gpr[3] = 0; | |
355 | } | |
356 | ||
357 | ||
358 | STATIC_INLINE_SYSTEM void | |
359 | do_umask(unsigned call, | |
360 | cpu *processor, | |
361 | unsigned_word cia) | |
362 | { | |
363 | SYS(umask); | |
364 | cpu_registers(processor)->gpr[3] = umask(cpu_registers(processor)->gpr[3]); | |
365 | } | |
366 | ||
367 | ||
368 | STATIC_INLINE_SYSTEM void | |
369 | do_stat(unsigned call, | |
370 | cpu *processor, | |
371 | unsigned_word cia) | |
372 | { | |
373 | char path_buf[PATH_MAX]; | |
374 | unsigned_word path_addr = cpu_registers(processor)->gpr[3]; | |
375 | unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[4]; | |
376 | char *path = read_string(processor, path_buf, path_addr, PATH_MAX); | |
377 | struct stat buf; | |
378 | SYS(stat); | |
379 | write_status(processor, stat(path, &buf)); | |
380 | write_stat(processor, stat_buf_addr, buf); | |
381 | } | |
382 | ||
383 | ||
384 | STATIC_INLINE_SYSTEM void | |
385 | do_fstat(unsigned call, | |
386 | cpu *processor, | |
387 | unsigned_word cia) | |
388 | { | |
389 | int fd = cpu_registers(processor)->gpr[3]; | |
390 | unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[4]; | |
391 | struct stat buf; | |
392 | SYS(fstat); | |
393 | write_status(processor, fstat(fd, &buf)); | |
394 | write_stat(processor, stat_buf_addr, buf); | |
395 | } | |
396 | ||
397 | ||
398 | STATIC_INLINE_SYSTEM void | |
399 | do_lstat(unsigned call, | |
400 | cpu *processor, | |
401 | unsigned_word cia) | |
402 | { | |
403 | char path_buf[PATH_MAX]; | |
404 | unsigned_word path_addr = cpu_registers(processor)->gpr[3]; | |
405 | char *path = read_string(processor, path_buf, path_addr, PATH_MAX); | |
406 | unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[4]; | |
407 | struct stat buf; | |
408 | SYS(lstat); | |
409 | write_status(processor, stat(path, &buf)); | |
410 | write_stat(processor, stat_buf_addr, buf); | |
411 | } | |
412 | ||
413 | ||
414 | STATIC_INLINE_SYSTEM void | |
415 | do___sysctl(unsigned call, | |
416 | cpu *processor, | |
417 | unsigned_word cia) | |
418 | { | |
419 | /* call the arguments by their real name */ | |
420 | unsigned_word name = cpu_registers(processor)->gpr[3]; | |
421 | natural_word namelen = cpu_registers(processor)->gpr[4]; | |
422 | unsigned_word oldp = cpu_registers(processor)->gpr[5]; | |
423 | unsigned_word oldlenp = cpu_registers(processor)->gpr[6]; | |
424 | natural_word oldlen; | |
425 | natural_word mib; | |
426 | natural_word int_val; | |
427 | SYS(__sysctl); | |
428 | ||
429 | /* pluck out the management information base id */ | |
430 | if (namelen < 1) | |
431 | error("system_call()SYS___sysctl bad name[0]\n"); | |
432 | mib = vm_data_map_read_word(cpu_data_map(processor), | |
433 | name, | |
434 | processor, | |
435 | cia); | |
436 | name += sizeof(mib); | |
437 | ||
438 | /* see what to do with it ... */ | |
439 | switch (mib) { | |
440 | case 6/*CTL_HW*/: | |
cb7a6892 MM |
441 | #if (NetBSD >= 199306) && (CTL_HW != 6) |
442 | # error "CTL_HW" | |
443 | #endif | |
dec38dac MM |
444 | if (namelen < 2) |
445 | error("system_call()SYS___sysctl - CTL_HW - bad name[1]\n"); | |
446 | mib = vm_data_map_read_word(cpu_data_map(processor), | |
447 | name, | |
448 | processor, | |
449 | cia); | |
450 | name += sizeof(mib); | |
451 | switch (mib) { | |
452 | case 7/*HW_PAGESIZE*/: | |
cb7a6892 MM |
453 | #if (NetBSD >= 199306) && (HW_PAGESIZE != 7) |
454 | # error "HW_PAGESIZE" | |
455 | #endif | |
dec38dac MM |
456 | oldlen = vm_data_map_read_word(cpu_data_map(processor), |
457 | oldlenp, | |
458 | processor, | |
459 | cia); | |
460 | if (sizeof(natural_word) > oldlen) | |
461 | error("system_call()sysctl - CTL_HW.HW_PAGESIZE - to small\n"); | |
462 | int_val = 8192; | |
463 | oldlen = sizeof(int_val); | |
464 | vm_data_map_write_word(cpu_data_map(processor), | |
465 | oldp, | |
466 | int_val, | |
467 | processor, | |
468 | cia); | |
469 | vm_data_map_write_word(cpu_data_map(processor), | |
470 | oldlenp, | |
471 | oldlen, | |
472 | processor, | |
473 | cia); | |
474 | break; | |
475 | default: | |
476 | error("sysctl() CTL_HW.%d unknown\n", mib); | |
cb7a6892 MM |
477 | break; |
478 | } | |
dec38dac | 479 | break; |
cb7a6892 | 480 | default: |
dec38dac | 481 | error("sysctl() name[0]=%s unknown\n", (int)mib); |
cb7a6892 | 482 | break; |
cb7a6892 | 483 | } |
dec38dac MM |
484 | cpu_registers(processor)->gpr[3] = 0; |
485 | } | |
486 | ||
487 | STATIC_INLINE_SYSTEM void | |
488 | unimp(unsigned call, | |
489 | cpu *processor, | |
490 | unsigned_word cia) | |
491 | { | |
492 | error("unimplemented system call %d, cia=0x%x\n", call, cia); | |
493 | } | |
494 | ||
495 | ||
496 | typedef void (sys_handler) | |
497 | (unsigned call, | |
498 | cpu *processor, | |
499 | unsigned_word cia); | |
500 | ||
501 | static sys_handler *(handlers[]) = { | |
502 | unimp, /* SYS_syscall 0 */ | |
503 | do_exit, /* 1*/ | |
504 | unimp, /* SYS_fork 2 */ | |
505 | do_read, /* 3 */ | |
506 | do_write, /* 4 */ | |
507 | do_open, /* 5 */ | |
508 | do_close, /* 6 */ | |
509 | unimp, /* SYS_wait4 7 */ | |
510 | unimp, /* 8 is old creat */ | |
511 | unimp, /* SYS_link 9 */ | |
512 | unimp, /* SYS_unlink 10 */ | |
513 | unimp, /* 11 is obsolete execv */ | |
514 | unimp, /* SYS_chdir 12 */ | |
515 | unimp, /* SYS_fchdir 13 */ | |
516 | unimp, /* SYS_mknod 14 */ | |
517 | unimp, /* SYS_chmod 15 */ | |
518 | unimp, /* SYS_chown 16 */ | |
519 | do_break, /* 17 */ | |
520 | unimp, /* SYS_getfsstat 18 */ | |
521 | unimp, /* 19 is old lseek */ | |
522 | do_getpid, /* 20 */ | |
523 | unimp, /* SYS_mount 21 */ | |
524 | unimp, /* SYS_unmount 22 */ | |
525 | unimp, /* SYS_setuid 23 */ | |
526 | do_getuid, /* 24 */ | |
527 | do_geteuid, /* 25 */ | |
528 | unimp, /* SYS_ptrace 26 */ | |
529 | unimp, /* SYS_recvmsg 27 */ | |
530 | unimp, /* SYS_sendmsg 28 */ | |
531 | unimp, /* SYS_recvfrom 29 */ | |
532 | unimp, /* SYS_accept 30 */ | |
533 | unimp, /* SYS_getpeername 31 */ | |
534 | unimp, /* SYS_getsockname 32 */ | |
535 | unimp, /* SYS_access 33 */ | |
536 | unimp, /* SYS_chflags 34 */ | |
537 | unimp, /* SYS_fchflags 35 */ | |
538 | unimp, /* SYS_sync 36 */ | |
539 | do_kill, /* 37 */ | |
540 | unimp, /* 38 is old stat */ | |
541 | unimp, /* SYS_getppid 39 */ | |
542 | unimp, /* 40 is old lstat */ | |
543 | unimp, /* SYS_dup 41 */ | |
544 | unimp, /* SYS_pipe 42 */ | |
545 | unimp, /* SYS_getegid 43 */ | |
546 | unimp, /* SYS_profil 44 */ | |
547 | unimp, /* SYS_ktrace 45 */ | |
548 | unimp, /* SYS_sigaction 46 */ | |
549 | unimp, /* SYS_getgid 47 */ | |
550 | do_sigprocmask, /* 48 */ | |
551 | unimp, /* SYS_getlogin 49 */ | |
552 | unimp, /* SYS_setlogin 50 */ | |
553 | unimp, /* SYS_acct 51 */ | |
554 | unimp, /* SYS_sigpending 52 */ | |
555 | unimp, /* SYS_sigaltstack 53 */ | |
556 | do_ioctl, /* 54 */ | |
557 | unimp, /* SYS_reboot 55 */ | |
558 | unimp, /* SYS_revoke 56 */ | |
559 | unimp, /* SYS_symlink 57 */ | |
560 | unimp, /* SYS_readlink 58 */ | |
561 | unimp, /* SYS_execve 59 */ | |
562 | do_umask, /* 60 */ | |
563 | unimp, /* SYS_chroot 61 */ | |
564 | unimp, /* 62 is old fstat */ | |
565 | unimp, /* 63 is old getkerninfo */ | |
566 | unimp, /* 64 is old getpagesize */ | |
567 | unimp, /* SYS_msync 65 */ | |
568 | unimp, /* SYS_vfork 66 */ | |
569 | unimp, /* 67 is obsolete vread */ | |
570 | unimp, /* 68 is obsolete vwrite */ | |
571 | unimp, /* SYS_sbrk 69 */ | |
572 | unimp, /* SYS_sstk 70 */ | |
573 | unimp, /* 71 is old mmap */ | |
574 | unimp, /* SYS_vadvise 72 */ | |
575 | unimp, /* SYS_munmap 73 */ | |
576 | unimp, /* SYS_mprotect 74 */ | |
577 | unimp, /* SYS_madvise 75 */ | |
578 | unimp, /* 76 is obsolete vhangup */ | |
579 | unimp, /* 77 is obsolete vlimit */ | |
580 | unimp, /* SYS_mincore 78 */ | |
581 | unimp, /* SYS_getgroups 79 */ | |
582 | unimp, /* SYS_setgroups 80 */ | |
583 | unimp, /* SYS_getpgrp 81 */ | |
584 | unimp, /* SYS_setpgid 82 */ | |
585 | unimp, /* SYS_setitimer 83 */ | |
586 | unimp, /* 84 is old wait */ | |
587 | unimp, /* SYS_swapon 85 */ | |
588 | unimp, /* SYS_getitimer 86 */ | |
589 | unimp, /* 87 is old gethostname */ | |
590 | unimp, /* 88 is old sethostname */ | |
591 | unimp, /* 89 is old getdtablesize */ | |
592 | unimp, /* SYS_dup2 90 */ | |
593 | unimp, /* 91 */ | |
594 | unimp, /* SYS_fcntl 92 */ | |
595 | unimp, /* SYS_select 93 */ | |
596 | unimp, /* 94 */ | |
597 | unimp, /* SYS_fsync 95 */ | |
598 | unimp, /* SYS_setpriority 96 */ | |
599 | unimp, /* SYS_socket 97 */ | |
600 | unimp, /* SYS_connect 98 */ | |
601 | unimp, /* 99 is old accept */ | |
602 | unimp, /* SYS_getpriority 100 */ | |
603 | unimp, /* 101 is old send */ | |
604 | unimp, /* 102 is old recv */ | |
605 | unimp, /* SYS_sigreturn 103 */ | |
606 | unimp, /* SYS_bind 104 */ | |
607 | unimp, /* SYS_setsockopt 105 */ | |
608 | unimp, /* SYS_listen 106 */ | |
609 | unimp, /* 107 is obsolete vtimes */ | |
610 | unimp, /* 108 is old sigvec */ | |
611 | unimp, /* 109 is old sigblock */ | |
612 | unimp, /* 110 is old sigsetmask */ | |
613 | unimp, /* SYS_sigsuspend 111 */ | |
614 | unimp, /* 112 is old sigstack */ | |
615 | unimp, /* 113 is old recvmsg */ | |
616 | unimp, /* 114 is old sendmsg */ | |
617 | unimp, /* SYS_vtrace 115 - is obsolete vtrace */ | |
618 | unimp, /* SYS_gettimeofday 116 */ | |
619 | unimp, /* SYS_getrusage 117 */ | |
620 | unimp, /* SYS_getsockopt 118 */ | |
621 | unimp, /* SYS_resuba 119 */ | |
622 | unimp, /* SYS_readv 120 */ | |
623 | unimp, /* SYS_writev 121 */ | |
624 | unimp, /* SYS_settimeofday 122 */ | |
625 | unimp, /* SYS_fchown 123 */ | |
626 | unimp, /* SYS_fchmod 124 */ | |
627 | unimp, /* 125 is old recvfrom */ | |
628 | unimp, /* 126 is old setreuid */ | |
629 | unimp, /* 127 is old setregid */ | |
630 | unimp, /* SYS_rename 128 */ | |
631 | unimp, /* 129 is old truncate */ | |
632 | unimp, /* 130 is old ftruncate */ | |
633 | unimp, /* SYS_flock 131 */ | |
634 | unimp, /* SYS_mkfifo 132 */ | |
635 | unimp, /* SYS_sendto 133 */ | |
636 | unimp, /* SYS_shutdown 134 */ | |
637 | unimp, /* SYS_socketpair 135 */ | |
638 | unimp, /* SYS_mkdir 136 */ | |
639 | unimp, /* SYS_rmdir 137 */ | |
640 | unimp, /* SYS_utimes 138 */ | |
641 | unimp, /* 139 is obsolete 4.2 sigreturn */ | |
642 | unimp, /* SYS_adjtime 140 */ | |
643 | unimp, /* 141 is old getpeername */ | |
644 | unimp, /* 142 is old gethostid */ | |
645 | unimp, /* 143 is old sethostid */ | |
646 | unimp, /* 144 is old getrlimit */ | |
647 | unimp, /* 145 is old setrlimit */ | |
648 | unimp, /* 146 is old killpg */ | |
649 | unimp, /* SYS_setsid 147 */ | |
650 | unimp, /* SYS_quotactl 148 */ | |
651 | unimp, /* 149 is old quota */ | |
652 | unimp, /* 150 is old getsockname */ | |
653 | unimp, /* 151 */ | |
654 | unimp, /* 152 */ | |
655 | unimp, /* 153 */ | |
656 | unimp, /* 154 */ | |
657 | unimp, /* SYS_nfssvc 155 */ | |
658 | unimp, /* 156 is old getdirentries */ | |
659 | unimp, /* SYS_statfs 157 */ | |
660 | unimp, /* SYS_fstatfs 158 */ | |
661 | unimp, /* 159 */ | |
662 | unimp, /* 160 */ | |
663 | unimp, /* SYS_getfh 161 */ | |
664 | unimp, /* 162 is old getdomainname */ | |
665 | unimp, /* 163 is old setdomainname */ | |
666 | unimp, /* 164 is old uname */ | |
667 | unimp, /* SYS_sysarch 165 */ | |
668 | unimp, /* 166 */ | |
669 | unimp, /* 167 */ | |
670 | unimp, /* 168 */ | |
671 | unimp, /* SYS_semsys 169 */ | |
672 | unimp, /* SYS_msgsys 170 */ | |
673 | unimp, /* SYS_shmsys 171 */ | |
674 | unimp, /* 172 */ | |
675 | unimp, /* 173 */ | |
676 | unimp, /* 174 */ | |
677 | unimp, /* 175 */ | |
678 | unimp, /* 176 */ | |
679 | unimp, /* 177 */ | |
680 | unimp, /* 178 */ | |
681 | unimp, /* 179 */ | |
682 | unimp, /* 180 */ | |
683 | unimp, /* SYS_setgid 181 */ | |
684 | unimp, /* SYS_setegid 182 */ | |
685 | unimp, /* SYS_seteuid 183 */ | |
686 | unimp, /* SYS_lfs_bmapv 184 */ | |
687 | unimp, /* SYS_lfs_markv 185 */ | |
688 | unimp, /* SYS_lfs_segclean 186 */ | |
689 | unimp, /* SYS_lfs_segwait 187 */ | |
690 | do_stat, /* 188 */ | |
691 | do_fstat, /* 189 */ | |
692 | do_lstat, /* 190 */ | |
693 | unimp, /* SYS_pathconf 191 */ | |
694 | unimp, /* SYS_fpathconf 192 */ | |
695 | unimp, /* 193 */ | |
696 | unimp, /* SYS_getrlimit 194 */ | |
697 | unimp, /* SYS_setrlimit 195 */ | |
698 | unimp, /* SYS_getdirentries 196 */ | |
699 | unimp, /* SYS_mmap 197 */ | |
700 | unimp, /* SYS___syscall 198 */ | |
701 | unimp, /* SYS_lseek 199 */ | |
702 | unimp, /* SYS_truncate 200 */ | |
703 | unimp, /* SYS_ftruncate 201 */ | |
704 | do___sysctl, /* 202 */ | |
705 | unimp, /* SYS_mlock 203 */ | |
706 | unimp, /* SYS_munlock 204 */ | |
707 | }; | |
708 | ||
709 | INLINE_SYSTEM void | |
710 | system_call(cpu *processor, | |
711 | unsigned_word cia) | |
712 | { | |
713 | unsigned call = cpu_registers(processor)->gpr[0]; | |
714 | if (call >= sizeof(handlers)/sizeof(handlers[0])) | |
715 | error("system call %d out-of-range\n", call); | |
716 | cpu_registers(processor)->gpr[0] = 0; /* default success */ | |
717 | handlers[call](call, processor, cia); | |
cb7a6892 MM |
718 | } |
719 | ||
720 | #endif /* _SYSTEM_C_ */ |