2 * Copyright (c) 2003 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <fcntl.h> // for host open() flags
32 #include <sys/types.h>
34 #include <string.h> // for memset()
37 #include "sim/host.hh"
38 #include "cpu/base_cpu.hh"
39 #include "mem/functional_mem/functional_memory.hh"
40 #include "sim/process.hh"
41 #include "cpu/exec_context.hh"
42 #include "sim/fake_syscall.hh"
43 #include "sim/sim_events.hh"
45 #include "sim/syscall_emul.hh"
46 #include "arch/alpha/alpha_common_syscall_emul.hh"
47 #include "sim/universe.hh" // for curTick & ticksPerSecond
49 #include "arch/alpha/alpha_linux_process.hh"
51 #include "base/trace.hh"
56 /// This class encapsulates the types, structures, constants,
57 /// functions, and syscall-number mappings specific to the Alpha Linux
58 /// syscall interface.
65 /// Basic Linux types.
66 typedef uint64_t size_t;
67 typedef uint64_t off_t
;
68 typedef int64_t time_t;
69 typedef uint32_t uid_t
;
70 typedef uint32_t gid_t
;
74 /// open(2) flag values.
75 static const int TGT_O_RDONLY
= 00000000; //!< O_RDONLY
76 static const int TGT_O_WRONLY
= 00000001; //!< O_WRONLY
77 static const int TGT_O_RDWR
= 00000002; //!< O_RDWR
78 static const int TGT_O_NONBLOCK
= 00000004; //!< O_NONBLOCK
79 static const int TGT_O_APPEND
= 00000010; //!< O_APPEND
80 static const int TGT_O_CREAT
= 00001000; //!< O_CREAT
81 static const int TGT_O_TRUNC
= 00002000; //!< O_TRUNC
82 static const int TGT_O_EXCL
= 00004000; //!< O_EXCL
83 static const int TGT_O_NOCTTY
= 00010000; //!< O_NOCTTY
84 static const int TGT_O_SYNC
= 00040000; //!< O_SYNC
85 static const int TGT_O_DRD
= 00100000; //!< O_DRD
86 static const int TGT_O_DIRECTIO
= 00200000; //!< O_DIRECTIO
87 static const int TGT_O_CACHE
= 00400000; //!< O_CACHE
88 static const int TGT_O_DSYNC
= 02000000; //!< O_DSYNC
89 static const int TGT_O_RSYNC
= 04000000; //!< O_RSYNC
92 /// This table maps the target open() flags to the corresponding
93 /// host open() flags.
94 static OpenFlagTransTable openFlagTable
[];
96 /// Number of entries in openFlagTable[].
97 static const int NUM_OPEN_FLAGS
;
99 /// Stat buffer. Note that we can't call it 'stat' since that
100 /// gets #defined to something else on some systems.
102 uint32_t st_dev
; //!< device
103 uint32_t st_ino
; //!< inode
104 uint32_t st_mode
; //!< mode
105 uint32_t st_nlink
; //!< link count
106 uint32_t st_uid
; //!< owner's user ID
107 uint32_t st_gid
; //!< owner's group ID
108 uint32_t st_rdev
; //!< device number
109 int64_t st_size
; //!< file size in bytes
110 uint64_t st_atimeX
; //!< time of last access
111 uint64_t st_mtimeX
; //!< time of last modification
112 uint64_t st_ctimeX
; //!< time of last status change
113 uint32_t st_blksize
; //!< optimal I/O block size
114 int32_t st_blocks
; //!< number of blocks allocated
115 uint32_t st_flags
; //!< flags
116 uint32_t st_gen
; //!< unknown
120 /// Length of strings in struct utsname (plus 1 for null char).
121 static const int _SYS_NMLN
= 65;
123 /// Interface struct for uname().
125 char sysname
[_SYS_NMLN
]; //!< System name.
126 char nodename
[_SYS_NMLN
]; //!< Node name.
127 char release
[_SYS_NMLN
]; //!< OS release.
128 char version
[_SYS_NMLN
]; //!< OS version.
129 char machine
[_SYS_NMLN
]; //!< Machine type.
134 /// ioctl() command codes.
135 static const unsigned TIOCGETP
= 0x40067408;
136 static const unsigned TIOCSETP
= 0x80067409;
137 static const unsigned TIOCSETN
= 0x8006740a;
138 static const unsigned TIOCSETC
= 0x80067411;
139 static const unsigned TIOCGETC
= 0x40067412;
140 static const unsigned FIONREAD
= 0x4004667f;
141 static const unsigned TIOCISATTY
= 0x2000745e;
144 /// Resource enumeration for getrlimit().
145 enum rlimit_resources
{
160 /// Limit struct for getrlimit/setrlimit.
162 uint64_t rlim_cur
; //!< soft limit
163 uint64_t rlim_max
; //!< hard limit
168 static const unsigned TGT_MAP_ANONYMOUS
= 0x10;
170 /// For gettimeofday().
172 int64_t tv_sec
; //!< seconds
173 int64_t tv_usec
; //!< microseconds
178 static const int RUSAGE_SELF
= 0;
179 static const int RUSAGE_CHILDREN
= -1;
180 static const int RUSAGE_BOTH
= -2;
185 struct timeval ru_utime
; //!< user time used
186 struct timeval ru_stime
; //!< system time used
187 int64_t ru_maxrss
; //!< max rss
188 int64_t ru_ixrss
; //!< integral shared memory size
189 int64_t ru_idrss
; //!< integral unshared data "
190 int64_t ru_isrss
; //!< integral unshared stack "
191 int64_t ru_minflt
; //!< page reclaims - total vmfaults
192 int64_t ru_majflt
; //!< page faults
193 int64_t ru_nswap
; //!< swaps
194 int64_t ru_inblock
; //!< block input operations
195 int64_t ru_oublock
; //!< block output operations
196 int64_t ru_msgsnd
; //!< messages sent
197 int64_t ru_msgrcv
; //!< messages received
198 int64_t ru_nsignals
; //!< signals received
199 int64_t ru_nvcsw
; //!< voluntary context switches
200 int64_t ru_nivcsw
; //!< involuntary "
203 /// Helper function to convert a host stat buffer to a target stat
204 /// buffer. Also copies the target buffer out to the simulated
205 /// memorty space. Used by stat(), fstat(), and lstat().
207 copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
, struct stat
*host
)
209 TypedBufferArg
<Linux::tgt_stat
> tgt(addr
);
211 tgt
->st_dev
= host
->st_dev
;
212 tgt
->st_ino
= host
->st_ino
;
213 tgt
->st_mode
= host
->st_mode
;
214 tgt
->st_nlink
= host
->st_nlink
;
215 tgt
->st_uid
= host
->st_uid
;
216 tgt
->st_gid
= host
->st_gid
;
217 tgt
->st_rdev
= host
->st_rdev
;
218 tgt
->st_size
= host
->st_size
;
219 tgt
->st_atimeX
= host
->st_atime
;
220 tgt
->st_mtimeX
= host
->st_mtime
;
221 tgt
->st_ctimeX
= host
->st_ctime
;
222 tgt
->st_blksize
= host
->st_blksize
;
223 tgt
->st_blocks
= host
->st_blocks
;
228 /// The target system's hostname.
229 static const char *hostname
;
231 /// Target uname() handler.
233 unameFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
236 TypedBufferArg
<Linux::utsname
> name(xc
->getSyscallArg(0));
238 strcpy(name
->sysname
, "Linux");
239 strcpy(name
->nodename
, hostname
);
240 strcpy(name
->release
, "2.4.20");
241 strcpy(name
->version
, "#1 Mon Aug 18 11:32:15 EDT 2003");
242 strcpy(name
->machine
, "alpha");
244 name
.copyOut(xc
->mem
);
248 /// Target osf_getsysyinfo() handler. Even though this call is
249 /// borrowed from Tru64, the subcases that get used appear to be
250 /// different in practice from those used by Tru64 processes.
252 osf_getsysinfoFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
255 unsigned op
= xc
->getSyscallArg(0);
256 // unsigned nbytes = xc->getSyscallArg(2);
260 case 45: { // GSI_IEEE_FP_CONTROL
261 TypedBufferArg
<uint64_t> fpcr(xc
->getSyscallArg(1));
262 // I don't think this exactly matches the HW FPCR
264 fpcr
.copyOut(xc
->mem
);
269 cerr
<< "osf_getsysinfo: unknown op " << op
<< endl
;
277 /// Target osf_setsysinfo() handler.
279 osf_setsysinfoFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
282 unsigned op
= xc
->getSyscallArg(0);
283 // unsigned nbytes = xc->getSyscallArg(2);
287 case 14: { // SSI_IEEE_FP_CONTROL
288 TypedBufferArg
<uint64_t> fpcr(xc
->getSyscallArg(1));
289 // I don't think this exactly matches the HW FPCR
290 fpcr
.copyIn(xc
->mem
);
291 DPRINTFR(SyscallVerbose
, "osf_setsysinfo(SSI_IEEE_FP_CONTROL): "
292 " setting FPCR to 0x%x\n", *(uint64_t*)fpcr
);
297 cerr
<< "osf_getsysinfo: unknown op " << op
<< endl
;
305 /// Target fnctl() handler.
307 fcntlFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
310 int fd
= xc
->getSyscallArg(0);
312 if (fd
< 0 || process
->sim_fd(fd
) < 0)
315 int cmd
= xc
->getSyscallArg(1);
318 // if we really wanted to support this, we'd need to do it
319 // in the target fd space.
320 warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd
);
323 case 1: // F_GETFD (get close-on-exec flag)
324 case 2: // F_SETFD (set close-on-exec flag)
327 case 3: // F_GETFL (get file flags)
328 case 4: // F_SETFL (set file flags)
329 // not sure if this is totally valid, but we'll pass it through
330 // to the underlying OS
331 warn("fcntl(%d, %d) passed through to host\n", fd
, cmd
);
332 return fcntl(process
->sim_fd(fd
), cmd
);
335 case 7: // F_GETLK (get lock)
336 case 8: // F_SETLK (set lock)
337 case 9: // F_SETLKW (set lock and wait)
338 // don't mess with file locking... just act like it's OK
339 warn("File lock call (fcntl(%d, %d)) ignored.\n", fd
, cmd
);
343 warn("Unknown fcntl command %d\n", cmd
);
348 /// Array of syscall descriptors, indexed by call number.
349 static SyscallDesc syscallDescs
[];
351 /// Number of syscalls in syscallDescs[].
352 static const int Num_Syscall_Descs
;
354 /// Max supported syscall number.
355 static const int Max_Syscall_Desc
;
357 /// Do the specified syscall. Just looks the call number up in
358 /// the table and invokes the appropriate handler.
360 doSyscall(int callnum
, Process
*process
, ExecContext
*xc
)
362 if (callnum
< 0 || callnum
> Max_Syscall_Desc
) {
363 fatal("Syscall %d out of range", callnum
);
366 SyscallDesc
*desc
= &syscallDescs
[callnum
];
368 desc
->doSyscall(callnum
, process
, xc
);
373 // open(2) flags translation table
374 OpenFlagTransTable
Linux::openFlagTable
[] = {
376 { Linux::TGT_O_RDONLY
, _O_RDONLY
},
377 { Linux::TGT_O_WRONLY
, _O_WRONLY
},
378 { Linux::TGT_O_RDWR
, _O_RDWR
},
379 { Linux::TGT_O_APPEND
, _O_APPEND
},
380 { Linux::TGT_O_CREAT
, _O_CREAT
},
381 { Linux::TGT_O_TRUNC
, _O_TRUNC
},
382 { Linux::TGT_O_EXCL
, _O_EXCL
},
384 { Linux::TGT_O_NONBLOCK
, _O_NONBLOCK
},
387 { Linux::TGT_O_NOCTTY
, _O_NOCTTY
},
390 { Linux::TGT_O_SYNC
, _O_SYNC
},
392 #else /* !_MSC_VER */
393 { Linux::TGT_O_RDONLY
, O_RDONLY
},
394 { Linux::TGT_O_WRONLY
, O_WRONLY
},
395 { Linux::TGT_O_RDWR
, O_RDWR
},
396 { Linux::TGT_O_APPEND
, O_APPEND
},
397 { Linux::TGT_O_CREAT
, O_CREAT
},
398 { Linux::TGT_O_TRUNC
, O_TRUNC
},
399 { Linux::TGT_O_EXCL
, O_EXCL
},
400 { Linux::TGT_O_NONBLOCK
, O_NONBLOCK
},
401 { Linux::TGT_O_NOCTTY
, O_NOCTTY
},
403 { Linux::TGT_O_SYNC
, O_SYNC
},
405 #endif /* _MSC_VER */
408 const int Linux::NUM_OPEN_FLAGS
=
409 (sizeof(Linux::openFlagTable
)/sizeof(Linux::openFlagTable
[0]));
411 const char *Linux::hostname
= "m5.eecs.umich.edu";
413 SyscallDesc
Linux::syscallDescs
[] = {
414 /* 0 */ SyscallDesc("osf_syscall", unimplementedFunc
),
415 /* 1 */ SyscallDesc("exit", exitFunc
),
416 /* 2 */ SyscallDesc("fork", unimplementedFunc
),
417 /* 3 */ SyscallDesc("read", readFunc
),
418 /* 4 */ SyscallDesc("write", writeFunc
),
419 /* 5 */ SyscallDesc("osf_old_open", unimplementedFunc
),
420 /* 6 */ SyscallDesc("close", closeFunc
),
421 /* 7 */ SyscallDesc("osf_wait4", unimplementedFunc
),
422 /* 8 */ SyscallDesc("osf_old_creat", unimplementedFunc
),
423 /* 9 */ SyscallDesc("link", unimplementedFunc
),
424 /* 10 */ SyscallDesc("unlink", unimplementedFunc
),
425 /* 11 */ SyscallDesc("osf_execve", unimplementedFunc
),
426 /* 12 */ SyscallDesc("chdir", unimplementedFunc
),
427 /* 13 */ SyscallDesc("fchdir", unimplementedFunc
),
428 /* 14 */ SyscallDesc("mknod", unimplementedFunc
),
429 /* 15 */ SyscallDesc("chmod", unimplementedFunc
),
430 /* 16 */ SyscallDesc("chown", unimplementedFunc
),
431 /* 17 */ SyscallDesc("brk", obreakFunc
),
432 /* 18 */ SyscallDesc("osf_getfsstat", unimplementedFunc
),
433 /* 19 */ SyscallDesc("lseek", lseekFunc
),
434 /* 20 */ SyscallDesc("getxpid", getpidFunc
),
435 /* 21 */ SyscallDesc("osf_mount", unimplementedFunc
),
436 /* 22 */ SyscallDesc("umount", unimplementedFunc
),
437 /* 23 */ SyscallDesc("setuid", setuidFunc
),
438 /* 24 */ SyscallDesc("getxuid", getuidFunc
),
439 /* 25 */ SyscallDesc("exec_with_loader", unimplementedFunc
),
440 /* 26 */ SyscallDesc("osf_ptrace", unimplementedFunc
),
441 /* 27 */ SyscallDesc("osf_nrecvmsg", unimplementedFunc
),
442 /* 28 */ SyscallDesc("osf_nsendmsg", unimplementedFunc
),
443 /* 29 */ SyscallDesc("osf_nrecvfrom", unimplementedFunc
),
444 /* 30 */ SyscallDesc("osf_naccept", unimplementedFunc
),
445 /* 31 */ SyscallDesc("osf_ngetpeername", unimplementedFunc
),
446 /* 32 */ SyscallDesc("osf_ngetsockname", unimplementedFunc
),
447 /* 33 */ SyscallDesc("access", unimplementedFunc
),
448 /* 34 */ SyscallDesc("osf_chflags", unimplementedFunc
),
449 /* 35 */ SyscallDesc("osf_fchflags", unimplementedFunc
),
450 /* 36 */ SyscallDesc("sync", unimplementedFunc
),
451 /* 37 */ SyscallDesc("kill", unimplementedFunc
),
452 /* 38 */ SyscallDesc("osf_old_stat", unimplementedFunc
),
453 /* 39 */ SyscallDesc("setpgid", unimplementedFunc
),
454 /* 40 */ SyscallDesc("osf_old_lstat", unimplementedFunc
),
455 /* 41 */ SyscallDesc("dup", unimplementedFunc
),
456 /* 42 */ SyscallDesc("pipe", unimplementedFunc
),
457 /* 43 */ SyscallDesc("osf_set_program_attributes", unimplementedFunc
),
458 /* 44 */ SyscallDesc("osf_profil", unimplementedFunc
),
459 /* 45 */ SyscallDesc("open", openFunc
<Linux
>),
460 /* 46 */ SyscallDesc("osf_old_sigaction", unimplementedFunc
),
461 /* 47 */ SyscallDesc("getxgid", getgidFunc
),
462 /* 48 */ SyscallDesc("osf_sigprocmask", ignoreFunc
),
463 /* 49 */ SyscallDesc("osf_getlogin", unimplementedFunc
),
464 /* 50 */ SyscallDesc("osf_setlogin", unimplementedFunc
),
465 /* 51 */ SyscallDesc("acct", unimplementedFunc
),
466 /* 52 */ SyscallDesc("sigpending", unimplementedFunc
),
467 /* 53 */ SyscallDesc("osf_classcntl", unimplementedFunc
),
468 /* 54 */ SyscallDesc("ioctl", ioctlFunc
<Linux
>),
469 /* 55 */ SyscallDesc("osf_reboot", unimplementedFunc
),
470 /* 56 */ SyscallDesc("osf_revoke", unimplementedFunc
),
471 /* 57 */ SyscallDesc("symlink", unimplementedFunc
),
472 /* 58 */ SyscallDesc("readlink", unimplementedFunc
),
473 /* 59 */ SyscallDesc("execve", unimplementedFunc
),
474 /* 60 */ SyscallDesc("umask", unimplementedFunc
),
475 /* 61 */ SyscallDesc("chroot", unimplementedFunc
),
476 /* 62 */ SyscallDesc("osf_old_fstat", unimplementedFunc
),
477 /* 63 */ SyscallDesc("getpgrp", unimplementedFunc
),
478 /* 64 */ SyscallDesc("getpagesize", getpagesizeFunc
),
479 /* 65 */ SyscallDesc("osf_mremap", unimplementedFunc
),
480 /* 66 */ SyscallDesc("vfork", unimplementedFunc
),
481 /* 67 */ SyscallDesc("stat", statFunc
<Linux
>),
482 /* 68 */ SyscallDesc("lstat", lstatFunc
<Linux
>),
483 /* 69 */ SyscallDesc("osf_sbrk", unimplementedFunc
),
484 /* 70 */ SyscallDesc("osf_sstk", unimplementedFunc
),
485 /* 71 */ SyscallDesc("mmap", mmapFunc
<Linux
>),
486 /* 72 */ SyscallDesc("osf_old_vadvise", unimplementedFunc
),
487 /* 73 */ SyscallDesc("munmap", munmapFunc
),
488 /* 74 */ SyscallDesc("mprotect", ignoreFunc
),
489 /* 75 */ SyscallDesc("madvise", unimplementedFunc
),
490 /* 76 */ SyscallDesc("vhangup", unimplementedFunc
),
491 /* 77 */ SyscallDesc("osf_kmodcall", unimplementedFunc
),
492 /* 78 */ SyscallDesc("osf_mincore", unimplementedFunc
),
493 /* 79 */ SyscallDesc("getgroups", unimplementedFunc
),
494 /* 80 */ SyscallDesc("setgroups", unimplementedFunc
),
495 /* 81 */ SyscallDesc("osf_old_getpgrp", unimplementedFunc
),
496 /* 82 */ SyscallDesc("setpgrp", unimplementedFunc
),
497 /* 83 */ SyscallDesc("osf_setitimer", unimplementedFunc
),
498 /* 84 */ SyscallDesc("osf_old_wait", unimplementedFunc
),
499 /* 85 */ SyscallDesc("osf_table", unimplementedFunc
),
500 /* 86 */ SyscallDesc("osf_getitimer", unimplementedFunc
),
501 /* 87 */ SyscallDesc("gethostname", gethostnameFunc
),
502 /* 88 */ SyscallDesc("sethostname", unimplementedFunc
),
503 /* 89 */ SyscallDesc("getdtablesize", unimplementedFunc
),
504 /* 90 */ SyscallDesc("dup2", unimplementedFunc
),
505 /* 91 */ SyscallDesc("fstat", fstatFunc
<Linux
>),
506 /* 92 */ SyscallDesc("fcntl", fcntlFunc
),
507 /* 93 */ SyscallDesc("osf_select", unimplementedFunc
),
508 /* 94 */ SyscallDesc("poll", unimplementedFunc
),
509 /* 95 */ SyscallDesc("fsync", unimplementedFunc
),
510 /* 96 */ SyscallDesc("setpriority", unimplementedFunc
),
511 /* 97 */ SyscallDesc("socket", unimplementedFunc
),
512 /* 98 */ SyscallDesc("connect", unimplementedFunc
),
513 /* 99 */ SyscallDesc("accept", unimplementedFunc
),
514 /* 100 */ SyscallDesc("getpriority", unimplementedFunc
),
515 /* 101 */ SyscallDesc("send", unimplementedFunc
),
516 /* 102 */ SyscallDesc("recv", unimplementedFunc
),
517 /* 103 */ SyscallDesc("sigreturn", unimplementedFunc
),
518 /* 104 */ SyscallDesc("bind", unimplementedFunc
),
519 /* 105 */ SyscallDesc("setsockopt", unimplementedFunc
),
520 /* 106 */ SyscallDesc("listen", unimplementedFunc
),
521 /* 107 */ SyscallDesc("osf_plock", unimplementedFunc
),
522 /* 108 */ SyscallDesc("osf_old_sigvec", unimplementedFunc
),
523 /* 109 */ SyscallDesc("osf_old_sigblock", unimplementedFunc
),
524 /* 110 */ SyscallDesc("osf_old_sigsetmask", unimplementedFunc
),
525 /* 111 */ SyscallDesc("sigsuspend", unimplementedFunc
),
526 /* 112 */ SyscallDesc("osf_sigstack", ignoreFunc
),
527 /* 113 */ SyscallDesc("recvmsg", unimplementedFunc
),
528 /* 114 */ SyscallDesc("sendmsg", unimplementedFunc
),
529 /* 115 */ SyscallDesc("osf_old_vtrace", unimplementedFunc
),
530 /* 116 */ SyscallDesc("osf_gettimeofday", unimplementedFunc
),
531 /* 117 */ SyscallDesc("osf_getrusage", unimplementedFunc
),
532 /* 118 */ SyscallDesc("getsockopt", unimplementedFunc
),
533 /* 119 */ SyscallDesc("numa_syscalls", unimplementedFunc
),
534 /* 120 */ SyscallDesc("readv", unimplementedFunc
),
535 /* 121 */ SyscallDesc("writev", unimplementedFunc
),
536 /* 122 */ SyscallDesc("osf_settimeofday", unimplementedFunc
),
537 /* 123 */ SyscallDesc("fchown", unimplementedFunc
),
538 /* 124 */ SyscallDesc("fchmod", unimplementedFunc
),
539 /* 125 */ SyscallDesc("recvfrom", unimplementedFunc
),
540 /* 126 */ SyscallDesc("setreuid", unimplementedFunc
),
541 /* 127 */ SyscallDesc("setregid", unimplementedFunc
),
542 /* 128 */ SyscallDesc("rename", unimplementedFunc
),
543 /* 129 */ SyscallDesc("truncate", unimplementedFunc
),
544 /* 130 */ SyscallDesc("ftruncate", unimplementedFunc
),
545 /* 131 */ SyscallDesc("flock", unimplementedFunc
),
546 /* 132 */ SyscallDesc("setgid", unimplementedFunc
),
547 /* 133 */ SyscallDesc("sendto", unimplementedFunc
),
548 /* 134 */ SyscallDesc("shutdown", unimplementedFunc
),
549 /* 135 */ SyscallDesc("socketpair", unimplementedFunc
),
550 /* 136 */ SyscallDesc("mkdir", unimplementedFunc
),
551 /* 137 */ SyscallDesc("rmdir", unimplementedFunc
),
552 /* 138 */ SyscallDesc("osf_utimes", unimplementedFunc
),
553 /* 139 */ SyscallDesc("osf_old_sigreturn", unimplementedFunc
),
554 /* 140 */ SyscallDesc("osf_adjtime", unimplementedFunc
),
555 /* 141 */ SyscallDesc("getpeername", unimplementedFunc
),
556 /* 142 */ SyscallDesc("osf_gethostid", unimplementedFunc
),
557 /* 143 */ SyscallDesc("osf_sethostid", unimplementedFunc
),
558 /* 144 */ SyscallDesc("getrlimit", getrlimitFunc
<Linux
>),
559 /* 145 */ SyscallDesc("setrlimit", unimplementedFunc
),
560 /* 146 */ SyscallDesc("osf_old_killpg", unimplementedFunc
),
561 /* 147 */ SyscallDesc("setsid", unimplementedFunc
),
562 /* 148 */ SyscallDesc("quotactl", unimplementedFunc
),
563 /* 149 */ SyscallDesc("osf_oldquota", unimplementedFunc
),
564 /* 150 */ SyscallDesc("getsockname", unimplementedFunc
),
565 /* 151 */ SyscallDesc("osf_pread", unimplementedFunc
),
566 /* 152 */ SyscallDesc("osf_pwrite", unimplementedFunc
),
567 /* 153 */ SyscallDesc("osf_pid_block", unimplementedFunc
),
568 /* 154 */ SyscallDesc("osf_pid_unblock", unimplementedFunc
),
569 /* 155 */ SyscallDesc("osf_signal_urti", unimplementedFunc
),
570 /* 156 */ SyscallDesc("sigaction", ignoreFunc
),
571 /* 157 */ SyscallDesc("osf_sigwaitprim", unimplementedFunc
),
572 /* 158 */ SyscallDesc("osf_nfssvc", unimplementedFunc
),
573 /* 159 */ SyscallDesc("osf_getdirentries", unimplementedFunc
),
574 /* 160 */ SyscallDesc("osf_statfs", unimplementedFunc
),
575 /* 161 */ SyscallDesc("osf_fstatfs", unimplementedFunc
),
576 /* 162 */ SyscallDesc("unknown #162", unimplementedFunc
),
577 /* 163 */ SyscallDesc("osf_async_daemon", unimplementedFunc
),
578 /* 164 */ SyscallDesc("osf_getfh", unimplementedFunc
),
579 /* 165 */ SyscallDesc("osf_getdomainname", unimplementedFunc
),
580 /* 166 */ SyscallDesc("setdomainname", unimplementedFunc
),
581 /* 167 */ SyscallDesc("unknown #167", unimplementedFunc
),
582 /* 168 */ SyscallDesc("unknown #168", unimplementedFunc
),
583 /* 169 */ SyscallDesc("osf_exportfs", unimplementedFunc
),
584 /* 170 */ SyscallDesc("unknown #170", unimplementedFunc
),
585 /* 171 */ SyscallDesc("unknown #171", unimplementedFunc
),
586 /* 172 */ SyscallDesc("unknown #172", unimplementedFunc
),
587 /* 173 */ SyscallDesc("unknown #173", unimplementedFunc
),
588 /* 174 */ SyscallDesc("unknown #174", unimplementedFunc
),
589 /* 175 */ SyscallDesc("unknown #175", unimplementedFunc
),
590 /* 176 */ SyscallDesc("unknown #176", unimplementedFunc
),
591 /* 177 */ SyscallDesc("unknown #177", unimplementedFunc
),
592 /* 178 */ SyscallDesc("unknown #178", unimplementedFunc
),
593 /* 179 */ SyscallDesc("unknown #179", unimplementedFunc
),
594 /* 180 */ SyscallDesc("unknown #180", unimplementedFunc
),
595 /* 181 */ SyscallDesc("osf_alt_plock", unimplementedFunc
),
596 /* 182 */ SyscallDesc("unknown #182", unimplementedFunc
),
597 /* 183 */ SyscallDesc("unknown #183", unimplementedFunc
),
598 /* 184 */ SyscallDesc("osf_getmnt", unimplementedFunc
),
599 /* 185 */ SyscallDesc("unknown #185", unimplementedFunc
),
600 /* 186 */ SyscallDesc("unknown #186", unimplementedFunc
),
601 /* 187 */ SyscallDesc("osf_alt_sigpending", unimplementedFunc
),
602 /* 188 */ SyscallDesc("osf_alt_setsid", unimplementedFunc
),
603 /* 189 */ SyscallDesc("unknown #189", unimplementedFunc
),
604 /* 190 */ SyscallDesc("unknown #190", unimplementedFunc
),
605 /* 191 */ SyscallDesc("unknown #191", unimplementedFunc
),
606 /* 192 */ SyscallDesc("unknown #192", unimplementedFunc
),
607 /* 193 */ SyscallDesc("unknown #193", unimplementedFunc
),
608 /* 194 */ SyscallDesc("unknown #194", unimplementedFunc
),
609 /* 195 */ SyscallDesc("unknown #195", unimplementedFunc
),
610 /* 196 */ SyscallDesc("unknown #196", unimplementedFunc
),
611 /* 197 */ SyscallDesc("unknown #197", unimplementedFunc
),
612 /* 198 */ SyscallDesc("unknown #198", unimplementedFunc
),
613 /* 199 */ SyscallDesc("osf_swapon", unimplementedFunc
),
614 /* 200 */ SyscallDesc("msgctl", unimplementedFunc
),
615 /* 201 */ SyscallDesc("msgget", unimplementedFunc
),
616 /* 202 */ SyscallDesc("msgrcv", unimplementedFunc
),
617 /* 203 */ SyscallDesc("msgsnd", unimplementedFunc
),
618 /* 204 */ SyscallDesc("semctl", unimplementedFunc
),
619 /* 205 */ SyscallDesc("semget", unimplementedFunc
),
620 /* 206 */ SyscallDesc("semop", unimplementedFunc
),
621 /* 207 */ SyscallDesc("osf_utsname", unimplementedFunc
),
622 /* 208 */ SyscallDesc("lchown", unimplementedFunc
),
623 /* 209 */ SyscallDesc("osf_shmat", unimplementedFunc
),
624 /* 210 */ SyscallDesc("shmctl", unimplementedFunc
),
625 /* 211 */ SyscallDesc("shmdt", unimplementedFunc
),
626 /* 212 */ SyscallDesc("shmget", unimplementedFunc
),
627 /* 213 */ SyscallDesc("osf_mvalid", unimplementedFunc
),
628 /* 214 */ SyscallDesc("osf_getaddressconf", unimplementedFunc
),
629 /* 215 */ SyscallDesc("osf_msleep", unimplementedFunc
),
630 /* 216 */ SyscallDesc("osf_mwakeup", unimplementedFunc
),
631 /* 217 */ SyscallDesc("msync", unimplementedFunc
),
632 /* 218 */ SyscallDesc("osf_signal", unimplementedFunc
),
633 /* 219 */ SyscallDesc("osf_utc_gettime", unimplementedFunc
),
634 /* 220 */ SyscallDesc("osf_utc_adjtime", unimplementedFunc
),
635 /* 221 */ SyscallDesc("unknown #221", unimplementedFunc
),
636 /* 222 */ SyscallDesc("osf_security", unimplementedFunc
),
637 /* 223 */ SyscallDesc("osf_kloadcall", unimplementedFunc
),
638 /* 224 */ SyscallDesc("unknown #224", unimplementedFunc
),
639 /* 225 */ SyscallDesc("unknown #225", unimplementedFunc
),
640 /* 226 */ SyscallDesc("unknown #226", unimplementedFunc
),
641 /* 227 */ SyscallDesc("unknown #227", unimplementedFunc
),
642 /* 228 */ SyscallDesc("unknown #228", unimplementedFunc
),
643 /* 229 */ SyscallDesc("unknown #229", unimplementedFunc
),
644 /* 230 */ SyscallDesc("unknown #230", unimplementedFunc
),
645 /* 231 */ SyscallDesc("unknown #231", unimplementedFunc
),
646 /* 232 */ SyscallDesc("unknown #232", unimplementedFunc
),
647 /* 233 */ SyscallDesc("getpgid", unimplementedFunc
),
648 /* 234 */ SyscallDesc("getsid", unimplementedFunc
),
649 /* 235 */ SyscallDesc("sigaltstack", ignoreFunc
),
650 /* 236 */ SyscallDesc("osf_waitid", unimplementedFunc
),
651 /* 237 */ SyscallDesc("osf_priocntlset", unimplementedFunc
),
652 /* 238 */ SyscallDesc("osf_sigsendset", unimplementedFunc
),
653 /* 239 */ SyscallDesc("osf_set_speculative", unimplementedFunc
),
654 /* 240 */ SyscallDesc("osf_msfs_syscall", unimplementedFunc
),
655 /* 241 */ SyscallDesc("osf_sysinfo", unimplementedFunc
),
656 /* 242 */ SyscallDesc("osf_uadmin", unimplementedFunc
),
657 /* 243 */ SyscallDesc("osf_fuser", unimplementedFunc
),
658 /* 244 */ SyscallDesc("osf_proplist_syscall", unimplementedFunc
),
659 /* 245 */ SyscallDesc("osf_ntp_adjtime", unimplementedFunc
),
660 /* 246 */ SyscallDesc("osf_ntp_gettime", unimplementedFunc
),
661 /* 247 */ SyscallDesc("osf_pathconf", unimplementedFunc
),
662 /* 248 */ SyscallDesc("osf_fpathconf", unimplementedFunc
),
663 /* 249 */ SyscallDesc("unknown #249", unimplementedFunc
),
664 /* 250 */ SyscallDesc("osf_uswitch", unimplementedFunc
),
665 /* 251 */ SyscallDesc("osf_usleep_thread", unimplementedFunc
),
666 /* 252 */ SyscallDesc("osf_audcntl", unimplementedFunc
),
667 /* 253 */ SyscallDesc("osf_audgen", unimplementedFunc
),
668 /* 254 */ SyscallDesc("sysfs", unimplementedFunc
),
669 /* 255 */ SyscallDesc("osf_subsys_info", unimplementedFunc
),
670 /* 256 */ SyscallDesc("osf_getsysinfo", osf_getsysinfoFunc
),
671 /* 257 */ SyscallDesc("osf_setsysinfo", osf_setsysinfoFunc
),
672 /* 258 */ SyscallDesc("osf_afs_syscall", unimplementedFunc
),
673 /* 259 */ SyscallDesc("osf_swapctl", unimplementedFunc
),
674 /* 260 */ SyscallDesc("osf_memcntl", unimplementedFunc
),
675 /* 261 */ SyscallDesc("osf_fdatasync", unimplementedFunc
),
676 /* 262 */ SyscallDesc("unknown #262", unimplementedFunc
),
677 /* 263 */ SyscallDesc("unknown #263", unimplementedFunc
),
678 /* 264 */ SyscallDesc("unknown #264", unimplementedFunc
),
679 /* 265 */ SyscallDesc("unknown #265", unimplementedFunc
),
680 /* 266 */ SyscallDesc("unknown #266", unimplementedFunc
),
681 /* 267 */ SyscallDesc("unknown #267", unimplementedFunc
),
682 /* 268 */ SyscallDesc("unknown #268", unimplementedFunc
),
683 /* 269 */ SyscallDesc("unknown #269", unimplementedFunc
),
684 /* 270 */ SyscallDesc("unknown #270", unimplementedFunc
),
685 /* 271 */ SyscallDesc("unknown #271", unimplementedFunc
),
686 /* 272 */ SyscallDesc("unknown #272", unimplementedFunc
),
687 /* 273 */ SyscallDesc("unknown #273", unimplementedFunc
),
688 /* 274 */ SyscallDesc("unknown #274", unimplementedFunc
),
689 /* 275 */ SyscallDesc("unknown #275", unimplementedFunc
),
690 /* 276 */ SyscallDesc("unknown #276", unimplementedFunc
),
691 /* 277 */ SyscallDesc("unknown #277", unimplementedFunc
),
692 /* 278 */ SyscallDesc("unknown #278", unimplementedFunc
),
693 /* 279 */ SyscallDesc("unknown #279", unimplementedFunc
),
694 /* 280 */ SyscallDesc("unknown #280", unimplementedFunc
),
695 /* 281 */ SyscallDesc("unknown #281", unimplementedFunc
),
696 /* 282 */ SyscallDesc("unknown #282", unimplementedFunc
),
697 /* 283 */ SyscallDesc("unknown #283", unimplementedFunc
),
698 /* 284 */ SyscallDesc("unknown #284", unimplementedFunc
),
699 /* 285 */ SyscallDesc("unknown #285", unimplementedFunc
),
700 /* 286 */ SyscallDesc("unknown #286", unimplementedFunc
),
701 /* 287 */ SyscallDesc("unknown #287", unimplementedFunc
),
702 /* 288 */ SyscallDesc("unknown #288", unimplementedFunc
),
703 /* 289 */ SyscallDesc("unknown #289", unimplementedFunc
),
704 /* 290 */ SyscallDesc("unknown #290", unimplementedFunc
),
705 /* 291 */ SyscallDesc("unknown #291", unimplementedFunc
),
706 /* 292 */ SyscallDesc("unknown #292", unimplementedFunc
),
707 /* 293 */ SyscallDesc("unknown #293", unimplementedFunc
),
708 /* 294 */ SyscallDesc("unknown #294", unimplementedFunc
),
709 /* 295 */ SyscallDesc("unknown #295", unimplementedFunc
),
710 /* 296 */ SyscallDesc("unknown #296", unimplementedFunc
),
711 /* 297 */ SyscallDesc("unknown #297", unimplementedFunc
),
712 /* 298 */ SyscallDesc("unknown #298", unimplementedFunc
),
713 /* 299 */ SyscallDesc("unknown #299", unimplementedFunc
),
715 * Linux-specific system calls begin at 300
717 /* 300 */ SyscallDesc("bdflush", unimplementedFunc
),
718 /* 301 */ SyscallDesc("sethae", unimplementedFunc
),
719 /* 302 */ SyscallDesc("mount", unimplementedFunc
),
720 /* 303 */ SyscallDesc("old_adjtimex", unimplementedFunc
),
721 /* 304 */ SyscallDesc("swapoff", unimplementedFunc
),
722 /* 305 */ SyscallDesc("getdents", unimplementedFunc
),
723 /* 306 */ SyscallDesc("create_module", unimplementedFunc
),
724 /* 307 */ SyscallDesc("init_module", unimplementedFunc
),
725 /* 308 */ SyscallDesc("delete_module", unimplementedFunc
),
726 /* 309 */ SyscallDesc("get_kernel_syms", unimplementedFunc
),
727 /* 310 */ SyscallDesc("syslog", unimplementedFunc
),
728 /* 311 */ SyscallDesc("reboot", unimplementedFunc
),
729 /* 312 */ SyscallDesc("clone", unimplementedFunc
),
730 /* 313 */ SyscallDesc("uselib", unimplementedFunc
),
731 /* 314 */ SyscallDesc("mlock", unimplementedFunc
),
732 /* 315 */ SyscallDesc("munlock", unimplementedFunc
),
733 /* 316 */ SyscallDesc("mlockall", unimplementedFunc
),
734 /* 317 */ SyscallDesc("munlockall", unimplementedFunc
),
735 /* 318 */ SyscallDesc("sysinfo", unimplementedFunc
),
736 /* 319 */ SyscallDesc("_sysctl", unimplementedFunc
),
737 /* 320 */ SyscallDesc("was sys_idle", unimplementedFunc
),
738 /* 321 */ SyscallDesc("oldumount", unimplementedFunc
),
739 /* 322 */ SyscallDesc("swapon", unimplementedFunc
),
740 /* 323 */ SyscallDesc("times", unimplementedFunc
),
741 /* 324 */ SyscallDesc("personality", unimplementedFunc
),
742 /* 325 */ SyscallDesc("setfsuid", unimplementedFunc
),
743 /* 326 */ SyscallDesc("setfsgid", unimplementedFunc
),
744 /* 327 */ SyscallDesc("ustat", unimplementedFunc
),
745 /* 328 */ SyscallDesc("statfs", unimplementedFunc
),
746 /* 329 */ SyscallDesc("fstatfs", unimplementedFunc
),
747 /* 330 */ SyscallDesc("sched_setparam", unimplementedFunc
),
748 /* 331 */ SyscallDesc("sched_getparam", unimplementedFunc
),
749 /* 332 */ SyscallDesc("sched_setscheduler", unimplementedFunc
),
750 /* 333 */ SyscallDesc("sched_getscheduler", unimplementedFunc
),
751 /* 334 */ SyscallDesc("sched_yield", unimplementedFunc
),
752 /* 335 */ SyscallDesc("sched_get_priority_max", unimplementedFunc
),
753 /* 336 */ SyscallDesc("sched_get_priority_min", unimplementedFunc
),
754 /* 337 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc
),
755 /* 338 */ SyscallDesc("afs_syscall", unimplementedFunc
),
756 /* 339 */ SyscallDesc("uname", unameFunc
),
757 /* 340 */ SyscallDesc("nanosleep", unimplementedFunc
),
758 /* 341 */ SyscallDesc("mremap", unimplementedFunc
),
759 /* 342 */ SyscallDesc("nfsservctl", unimplementedFunc
),
760 /* 343 */ SyscallDesc("setresuid", unimplementedFunc
),
761 /* 344 */ SyscallDesc("getresuid", unimplementedFunc
),
762 /* 345 */ SyscallDesc("pciconfig_read", unimplementedFunc
),
763 /* 346 */ SyscallDesc("pciconfig_write", unimplementedFunc
),
764 /* 347 */ SyscallDesc("query_module", unimplementedFunc
),
765 /* 348 */ SyscallDesc("prctl", unimplementedFunc
),
766 /* 349 */ SyscallDesc("pread", unimplementedFunc
),
767 /* 350 */ SyscallDesc("pwrite", unimplementedFunc
),
768 /* 351 */ SyscallDesc("rt_sigreturn", unimplementedFunc
),
769 /* 352 */ SyscallDesc("rt_sigaction", unimplementedFunc
),
770 /* 353 */ SyscallDesc("rt_sigprocmask", unimplementedFunc
),
771 /* 354 */ SyscallDesc("rt_sigpending", unimplementedFunc
),
772 /* 355 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc
),
773 /* 356 */ SyscallDesc("rt_sigqueueinfo", unimplementedFunc
),
774 /* 357 */ SyscallDesc("rt_sigsuspend", unimplementedFunc
),
775 /* 358 */ SyscallDesc("select", unimplementedFunc
),
776 /* 359 */ SyscallDesc("gettimeofday", gettimeofdayFunc
<Linux
>),
777 /* 360 */ SyscallDesc("settimeofday", unimplementedFunc
),
778 /* 361 */ SyscallDesc("getitimer", unimplementedFunc
),
779 /* 362 */ SyscallDesc("setitimer", unimplementedFunc
),
780 /* 363 */ SyscallDesc("utimes", unimplementedFunc
),
781 /* 364 */ SyscallDesc("getrusage", getrusageFunc
<Linux
>),
782 /* 365 */ SyscallDesc("wait4", unimplementedFunc
),
783 /* 366 */ SyscallDesc("adjtimex", unimplementedFunc
),
784 /* 367 */ SyscallDesc("getcwd", unimplementedFunc
),
785 /* 368 */ SyscallDesc("capget", unimplementedFunc
),
786 /* 369 */ SyscallDesc("capset", unimplementedFunc
),
787 /* 370 */ SyscallDesc("sendfile", unimplementedFunc
),
788 /* 371 */ SyscallDesc("setresgid", unimplementedFunc
),
789 /* 372 */ SyscallDesc("getresgid", unimplementedFunc
),
790 /* 373 */ SyscallDesc("dipc", unimplementedFunc
),
791 /* 374 */ SyscallDesc("pivot_root", unimplementedFunc
),
792 /* 375 */ SyscallDesc("mincore", unimplementedFunc
),
793 /* 376 */ SyscallDesc("pciconfig_iobase", unimplementedFunc
),
794 /* 377 */ SyscallDesc("getdents64", unimplementedFunc
),
795 /* 378 */ SyscallDesc("gettid", unimplementedFunc
),
796 /* 379 */ SyscallDesc("readahead", unimplementedFunc
),
797 /* 380 */ SyscallDesc("security", unimplementedFunc
),
798 /* 381 */ SyscallDesc("tkill", unimplementedFunc
),
799 /* 382 */ SyscallDesc("setxattr", unimplementedFunc
),
800 /* 383 */ SyscallDesc("lsetxattr", unimplementedFunc
),
801 /* 384 */ SyscallDesc("fsetxattr", unimplementedFunc
),
802 /* 385 */ SyscallDesc("getxattr", unimplementedFunc
),
803 /* 386 */ SyscallDesc("lgetxattr", unimplementedFunc
),
804 /* 387 */ SyscallDesc("fgetxattr", unimplementedFunc
),
805 /* 388 */ SyscallDesc("listxattr", unimplementedFunc
),
806 /* 389 */ SyscallDesc("llistxattr", unimplementedFunc
),
807 /* 390 */ SyscallDesc("flistxattr", unimplementedFunc
),
808 /* 391 */ SyscallDesc("removexattr", unimplementedFunc
),
809 /* 392 */ SyscallDesc("lremovexattr", unimplementedFunc
),
810 /* 393 */ SyscallDesc("fremovexattr", unimplementedFunc
),
813 const int Linux::Num_Syscall_Descs
=
814 sizeof(Linux::syscallDescs
) / sizeof(SyscallDesc
);
816 const int Linux::Max_Syscall_Desc
= Linux::Num_Syscall_Descs
- 1;
820 AlphaLinuxProcess::syscall(ExecContext
*xc
)
824 int64_t callnum
= xc
->regs
.intRegFile
[ReturnValueReg
];
826 Linux::doSyscall(callnum
, this, xc
);
830 AlphaLinuxProcess::AlphaLinuxProcess(const std::string
&name
,
835 std::vector
<std::string
> &argv
,
836 std::vector
<std::string
> &envp
)
837 : LiveProcess(name
, objFile
, stdin_fd
, stdout_fd
, stderr_fd
, argv
, envp
)