process.cc revision 2199
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 */
28
29#include "arch/alpha/common_syscall_emul.hh"
30#include "arch/alpha/linux_process.hh"
31#include "arch/alpha/isa_traits.hh"
32
33#include "base/trace.hh"
34#include "cpu/exec_context.hh"
35#include "kern/linux/linux.hh"
36#include "mem/functional/functional.hh"
37
38#include "sim/process.hh"
39#include "sim/syscall_emul.hh"
40
41using namespace std;
42using namespace AlphaISA;
43
44/// Target pipe() handler.  Even though this is a generic Posix call,
45/// the Alpha return convention is funky, so that makes it
46/// Alpha-specific.
47SyscallReturn
48pipeFunc(SyscallDesc *desc, int callnum, Process *process,
49         ExecContext *xc)
50{
51    int fds[2], sim_fds[2];
52    int pipe_retval = pipe(fds);
53
54    if (pipe_retval < 0) {
55        // error
56        return pipe_retval;
57    }
58
59    sim_fds[0] = process->alloc_fd(fds[0]);
60    sim_fds[1] = process->alloc_fd(fds[1]);
61
62    // Alpha Linux convention for pipe() is that fd[0] is returned as
63    // the return value of the function, and fd[1] is returned in r20.
64    xc->regs.intRegFile[20] = sim_fds[1];
65    return sim_fds[0];
66}
67
68
69/// Target uname() handler.
70static SyscallReturn
71unameFunc(SyscallDesc *desc, int callnum, Process *process,
72          ExecContext *xc)
73{
74    TypedBufferArg<Linux::utsname> name(xc->getSyscallArg(0));
75
76    strcpy(name->sysname, "Linux");
77    strcpy(name->nodename, "m5.eecs.umich.edu");
78    strcpy(name->release, "2.4.20");
79    strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
80    strcpy(name->machine, "alpha");
81
82    name.copyOut(xc->mem);
83    return 0;
84}
85
86/// Target osf_getsysyinfo() handler.  Even though this call is
87/// borrowed from Tru64, the subcases that get used appear to be
88/// different in practice from those used by Tru64 processes.
89static SyscallReturn
90osf_getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
91                   ExecContext *xc)
92{
93    unsigned op = xc->getSyscallArg(0);
94    // unsigned nbytes = xc->getSyscallArg(2);
95
96    switch (op) {
97
98      case 45: { // GSI_IEEE_FP_CONTROL
99          TypedBufferArg<uint64_t> fpcr(xc->getSyscallArg(1));
100          // I don't think this exactly matches the HW FPCR
101          *fpcr = 0;
102          fpcr.copyOut(xc->mem);
103          return 0;
104      }
105
106      default:
107        cerr << "osf_getsysinfo: unknown op " << op << endl;
108        abort();
109        break;
110    }
111
112    return 1;
113}
114
115/// Target osf_setsysinfo() handler.
116static SyscallReturn
117osf_setsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
118                   ExecContext *xc)
119{
120    unsigned op = xc->getSyscallArg(0);
121    // unsigned nbytes = xc->getSyscallArg(2);
122
123    switch (op) {
124
125      case 14: { // SSI_IEEE_FP_CONTROL
126          TypedBufferArg<uint64_t> fpcr(xc->getSyscallArg(1));
127          // I don't think this exactly matches the HW FPCR
128          fpcr.copyIn(xc->mem);
129          DPRINTFR(SyscallVerbose, "osf_setsysinfo(SSI_IEEE_FP_CONTROL): "
130                   " setting FPCR to 0x%x\n", gtoh(*(uint64_t*)fpcr));
131          return 0;
132      }
133
134      default:
135        cerr << "osf_setsysinfo: unknown op " << op << endl;
136        abort();
137        break;
138    }
139
140    return 1;
141}
142
143
144SyscallDesc AlphaLinuxProcess::syscallDescs[] = {
145    /*  0 */ SyscallDesc("osf_syscall", unimplementedFunc),
146    /*  1 */ SyscallDesc("exit", exitFunc),
147    /*  2 */ SyscallDesc("fork", unimplementedFunc),
148    /*  3 */ SyscallDesc("read", readFunc),
149    /*  4 */ SyscallDesc("write", writeFunc),
150    /*  5 */ SyscallDesc("osf_old_open", unimplementedFunc),
151    /*  6 */ SyscallDesc("close", closeFunc),
152    /*  7 */ SyscallDesc("osf_wait4", unimplementedFunc),
153    /*  8 */ SyscallDesc("osf_old_creat", unimplementedFunc),
154    /*  9 */ SyscallDesc("link", unimplementedFunc),
155    /* 10 */ SyscallDesc("unlink", unlinkFunc),
156    /* 11 */ SyscallDesc("osf_execve", unimplementedFunc),
157    /* 12 */ SyscallDesc("chdir", unimplementedFunc),
158    /* 13 */ SyscallDesc("fchdir", unimplementedFunc),
159    /* 14 */ SyscallDesc("mknod", unimplementedFunc),
160    /* 15 */ SyscallDesc("chmod", chmodFunc<Linux>),
161    /* 16 */ SyscallDesc("chown", chownFunc),
162    /* 17 */ SyscallDesc("brk", obreakFunc),
163    /* 18 */ SyscallDesc("osf_getfsstat", unimplementedFunc),
164    /* 19 */ SyscallDesc("lseek", lseekFunc),
165    /* 20 */ SyscallDesc("getxpid", getpidFunc),
166    /* 21 */ SyscallDesc("osf_mount", unimplementedFunc),
167    /* 22 */ SyscallDesc("umount", unimplementedFunc),
168    /* 23 */ SyscallDesc("setuid", setuidFunc),
169    /* 24 */ SyscallDesc("getxuid", getuidFunc),
170    /* 25 */ SyscallDesc("exec_with_loader", unimplementedFunc),
171    /* 26 */ SyscallDesc("osf_ptrace", unimplementedFunc),
172    /* 27 */ SyscallDesc("osf_nrecvmsg", unimplementedFunc),
173    /* 28 */ SyscallDesc("osf_nsendmsg", unimplementedFunc),
174    /* 29 */ SyscallDesc("osf_nrecvfrom", unimplementedFunc),
175    /* 30 */ SyscallDesc("osf_naccept", unimplementedFunc),
176    /* 31 */ SyscallDesc("osf_ngetpeername", unimplementedFunc),
177    /* 32 */ SyscallDesc("osf_ngetsockname", unimplementedFunc),
178    /* 33 */ SyscallDesc("access", unimplementedFunc),
179    /* 34 */ SyscallDesc("osf_chflags", unimplementedFunc),
180    /* 35 */ SyscallDesc("osf_fchflags", unimplementedFunc),
181    /* 36 */ SyscallDesc("sync", unimplementedFunc),
182    /* 37 */ SyscallDesc("kill", unimplementedFunc),
183    /* 38 */ SyscallDesc("osf_old_stat", unimplementedFunc),
184    /* 39 */ SyscallDesc("setpgid", unimplementedFunc),
185    /* 40 */ SyscallDesc("osf_old_lstat", unimplementedFunc),
186    /* 41 */ SyscallDesc("dup", unimplementedFunc),
187    /* 42 */ SyscallDesc("pipe", pipeFunc),
188    /* 43 */ SyscallDesc("osf_set_program_attributes", unimplementedFunc),
189    /* 44 */ SyscallDesc("osf_profil", unimplementedFunc),
190    /* 45 */ SyscallDesc("open", openFunc<Linux>),
191    /* 46 */ SyscallDesc("osf_old_sigaction", unimplementedFunc),
192    /* 47 */ SyscallDesc("getxgid", getgidFunc),
193    /* 48 */ SyscallDesc("osf_sigprocmask", ignoreFunc),
194    /* 49 */ SyscallDesc("osf_getlogin", unimplementedFunc),
195    /* 50 */ SyscallDesc("osf_setlogin", unimplementedFunc),
196    /* 51 */ SyscallDesc("acct", unimplementedFunc),
197    /* 52 */ SyscallDesc("sigpending", unimplementedFunc),
198    /* 53 */ SyscallDesc("osf_classcntl", unimplementedFunc),
199    /* 54 */ SyscallDesc("ioctl", ioctlFunc<Linux>),
200    /* 55 */ SyscallDesc("osf_reboot", unimplementedFunc),
201    /* 56 */ SyscallDesc("osf_revoke", unimplementedFunc),
202    /* 57 */ SyscallDesc("symlink", unimplementedFunc),
203    /* 58 */ SyscallDesc("readlink", unimplementedFunc),
204    /* 59 */ SyscallDesc("execve", unimplementedFunc),
205    /* 60 */ SyscallDesc("umask", unimplementedFunc),
206    /* 61 */ SyscallDesc("chroot", unimplementedFunc),
207    /* 62 */ SyscallDesc("osf_old_fstat", unimplementedFunc),
208    /* 63 */ SyscallDesc("getpgrp", unimplementedFunc),
209    /* 64 */ SyscallDesc("getpagesize", getpagesizeFunc),
210    /* 65 */ SyscallDesc("osf_mremap", unimplementedFunc),
211    /* 66 */ SyscallDesc("vfork", unimplementedFunc),
212    /* 67 */ SyscallDesc("stat", statFunc<Linux>),
213    /* 68 */ SyscallDesc("lstat", lstatFunc<Linux>),
214    /* 69 */ SyscallDesc("osf_sbrk", unimplementedFunc),
215    /* 70 */ SyscallDesc("osf_sstk", unimplementedFunc),
216    /* 71 */ SyscallDesc("mmap", mmapFunc<Linux>),
217    /* 72 */ SyscallDesc("osf_old_vadvise", unimplementedFunc),
218    /* 73 */ SyscallDesc("munmap", munmapFunc),
219    /* 74 */ SyscallDesc("mprotect", ignoreFunc),
220    /* 75 */ SyscallDesc("madvise", unimplementedFunc),
221    /* 76 */ SyscallDesc("vhangup", unimplementedFunc),
222    /* 77 */ SyscallDesc("osf_kmodcall", unimplementedFunc),
223    /* 78 */ SyscallDesc("osf_mincore", unimplementedFunc),
224    /* 79 */ SyscallDesc("getgroups", unimplementedFunc),
225    /* 80 */ SyscallDesc("setgroups", unimplementedFunc),
226    /* 81 */ SyscallDesc("osf_old_getpgrp", unimplementedFunc),
227    /* 82 */ SyscallDesc("setpgrp", unimplementedFunc),
228    /* 83 */ SyscallDesc("osf_setitimer", unimplementedFunc),
229    /* 84 */ SyscallDesc("osf_old_wait", unimplementedFunc),
230    /* 85 */ SyscallDesc("osf_table", unimplementedFunc),
231    /* 86 */ SyscallDesc("osf_getitimer", unimplementedFunc),
232    /* 87 */ SyscallDesc("gethostname", gethostnameFunc),
233    /* 88 */ SyscallDesc("sethostname", unimplementedFunc),
234    /* 89 */ SyscallDesc("getdtablesize", unimplementedFunc),
235    /* 90 */ SyscallDesc("dup2", unimplementedFunc),
236    /* 91 */ SyscallDesc("fstat", fstatFunc<Linux>),
237    /* 92 */ SyscallDesc("fcntl", fcntlFunc),
238    /* 93 */ SyscallDesc("osf_select", unimplementedFunc),
239    /* 94 */ SyscallDesc("poll", unimplementedFunc),
240    /* 95 */ SyscallDesc("fsync", unimplementedFunc),
241    /* 96 */ SyscallDesc("setpriority", unimplementedFunc),
242    /* 97 */ SyscallDesc("socket", unimplementedFunc),
243    /* 98 */ SyscallDesc("connect", unimplementedFunc),
244    /* 99 */ SyscallDesc("accept", unimplementedFunc),
245    /* 100 */ SyscallDesc("getpriority", unimplementedFunc),
246    /* 101 */ SyscallDesc("send", unimplementedFunc),
247    /* 102 */ SyscallDesc("recv", unimplementedFunc),
248    /* 103 */ SyscallDesc("sigreturn", unimplementedFunc),
249    /* 104 */ SyscallDesc("bind", unimplementedFunc),
250    /* 105 */ SyscallDesc("setsockopt", unimplementedFunc),
251    /* 106 */ SyscallDesc("listen", unimplementedFunc),
252    /* 107 */ SyscallDesc("osf_plock", unimplementedFunc),
253    /* 108 */ SyscallDesc("osf_old_sigvec", unimplementedFunc),
254    /* 109 */ SyscallDesc("osf_old_sigblock", unimplementedFunc),
255    /* 110 */ SyscallDesc("osf_old_sigsetmask", unimplementedFunc),
256    /* 111 */ SyscallDesc("sigsuspend", unimplementedFunc),
257    /* 112 */ SyscallDesc("osf_sigstack", ignoreFunc),
258    /* 113 */ SyscallDesc("recvmsg", unimplementedFunc),
259    /* 114 */ SyscallDesc("sendmsg", unimplementedFunc),
260    /* 115 */ SyscallDesc("osf_old_vtrace", unimplementedFunc),
261    /* 116 */ SyscallDesc("osf_gettimeofday", unimplementedFunc),
262    /* 117 */ SyscallDesc("osf_getrusage", unimplementedFunc),
263    /* 118 */ SyscallDesc("getsockopt", unimplementedFunc),
264    /* 119 */ SyscallDesc("numa_syscalls", unimplementedFunc),
265    /* 120 */ SyscallDesc("readv", unimplementedFunc),
266    /* 121 */ SyscallDesc("writev", writevFunc<Linux>),
267    /* 122 */ SyscallDesc("osf_settimeofday", unimplementedFunc),
268    /* 123 */ SyscallDesc("fchown", fchownFunc),
269    /* 124 */ SyscallDesc("fchmod", fchmodFunc<Linux>),
270    /* 125 */ SyscallDesc("recvfrom", unimplementedFunc),
271    /* 126 */ SyscallDesc("setreuid", unimplementedFunc),
272    /* 127 */ SyscallDesc("setregid", unimplementedFunc),
273    /* 128 */ SyscallDesc("rename", renameFunc),
274    /* 129 */ SyscallDesc("truncate", unimplementedFunc),
275    /* 130 */ SyscallDesc("ftruncate", unimplementedFunc),
276    /* 131 */ SyscallDesc("flock", unimplementedFunc),
277    /* 132 */ SyscallDesc("setgid", unimplementedFunc),
278    /* 133 */ SyscallDesc("sendto", unimplementedFunc),
279    /* 134 */ SyscallDesc("shutdown", unimplementedFunc),
280    /* 135 */ SyscallDesc("socketpair", unimplementedFunc),
281    /* 136 */ SyscallDesc("mkdir", unimplementedFunc),
282    /* 137 */ SyscallDesc("rmdir", unimplementedFunc),
283    /* 138 */ SyscallDesc("osf_utimes", unimplementedFunc),
284    /* 139 */ SyscallDesc("osf_old_sigreturn", unimplementedFunc),
285    /* 140 */ SyscallDesc("osf_adjtime", unimplementedFunc),
286    /* 141 */ SyscallDesc("getpeername", unimplementedFunc),
287    /* 142 */ SyscallDesc("osf_gethostid", unimplementedFunc),
288    /* 143 */ SyscallDesc("osf_sethostid", unimplementedFunc),
289    /* 144 */ SyscallDesc("getrlimit", getrlimitFunc<Linux>),
290    /* 145 */ SyscallDesc("setrlimit", ignoreFunc),
291    /* 146 */ SyscallDesc("osf_old_killpg", unimplementedFunc),
292    /* 147 */ SyscallDesc("setsid", unimplementedFunc),
293    /* 148 */ SyscallDesc("quotactl", unimplementedFunc),
294    /* 149 */ SyscallDesc("osf_oldquota", unimplementedFunc),
295    /* 150 */ SyscallDesc("getsockname", unimplementedFunc),
296    /* 151 */ SyscallDesc("osf_pread", unimplementedFunc),
297    /* 152 */ SyscallDesc("osf_pwrite", unimplementedFunc),
298    /* 153 */ SyscallDesc("osf_pid_block", unimplementedFunc),
299    /* 154 */ SyscallDesc("osf_pid_unblock", unimplementedFunc),
300    /* 155 */ SyscallDesc("osf_signal_urti", unimplementedFunc),
301    /* 156 */ SyscallDesc("sigaction", ignoreFunc),
302    /* 157 */ SyscallDesc("osf_sigwaitprim", unimplementedFunc),
303    /* 158 */ SyscallDesc("osf_nfssvc", unimplementedFunc),
304    /* 159 */ SyscallDesc("osf_getdirentries", unimplementedFunc),
305    /* 160 */ SyscallDesc("osf_statfs", unimplementedFunc),
306    /* 161 */ SyscallDesc("osf_fstatfs", unimplementedFunc),
307    /* 162 */ SyscallDesc("unknown #162", unimplementedFunc),
308    /* 163 */ SyscallDesc("osf_async_daemon", unimplementedFunc),
309    /* 164 */ SyscallDesc("osf_getfh", unimplementedFunc),
310    /* 165 */ SyscallDesc("osf_getdomainname", unimplementedFunc),
311    /* 166 */ SyscallDesc("setdomainname", unimplementedFunc),
312    /* 167 */ SyscallDesc("unknown #167", unimplementedFunc),
313    /* 168 */ SyscallDesc("unknown #168", unimplementedFunc),
314    /* 169 */ SyscallDesc("osf_exportfs", unimplementedFunc),
315    /* 170 */ SyscallDesc("unknown #170", unimplementedFunc),
316    /* 171 */ SyscallDesc("unknown #171", unimplementedFunc),
317    /* 172 */ SyscallDesc("unknown #172", unimplementedFunc),
318    /* 173 */ SyscallDesc("unknown #173", unimplementedFunc),
319    /* 174 */ SyscallDesc("unknown #174", unimplementedFunc),
320    /* 175 */ SyscallDesc("unknown #175", unimplementedFunc),
321    /* 176 */ SyscallDesc("unknown #176", unimplementedFunc),
322    /* 177 */ SyscallDesc("unknown #177", unimplementedFunc),
323    /* 178 */ SyscallDesc("unknown #178", unimplementedFunc),
324    /* 179 */ SyscallDesc("unknown #179", unimplementedFunc),
325    /* 180 */ SyscallDesc("unknown #180", unimplementedFunc),
326    /* 181 */ SyscallDesc("osf_alt_plock", unimplementedFunc),
327    /* 182 */ SyscallDesc("unknown #182", unimplementedFunc),
328    /* 183 */ SyscallDesc("unknown #183", unimplementedFunc),
329    /* 184 */ SyscallDesc("osf_getmnt", unimplementedFunc),
330    /* 185 */ SyscallDesc("unknown #185", unimplementedFunc),
331    /* 186 */ SyscallDesc("unknown #186", unimplementedFunc),
332    /* 187 */ SyscallDesc("osf_alt_sigpending", unimplementedFunc),
333    /* 188 */ SyscallDesc("osf_alt_setsid", unimplementedFunc),
334    /* 189 */ SyscallDesc("unknown #189", unimplementedFunc),
335    /* 190 */ SyscallDesc("unknown #190", unimplementedFunc),
336    /* 191 */ SyscallDesc("unknown #191", unimplementedFunc),
337    /* 192 */ SyscallDesc("unknown #192", unimplementedFunc),
338    /* 193 */ SyscallDesc("unknown #193", unimplementedFunc),
339    /* 194 */ SyscallDesc("unknown #194", unimplementedFunc),
340    /* 195 */ SyscallDesc("unknown #195", unimplementedFunc),
341    /* 196 */ SyscallDesc("unknown #196", unimplementedFunc),
342    /* 197 */ SyscallDesc("unknown #197", unimplementedFunc),
343    /* 198 */ SyscallDesc("unknown #198", unimplementedFunc),
344    /* 199 */ SyscallDesc("osf_swapon", unimplementedFunc),
345    /* 200 */ SyscallDesc("msgctl", unimplementedFunc),
346    /* 201 */ SyscallDesc("msgget", unimplementedFunc),
347    /* 202 */ SyscallDesc("msgrcv", unimplementedFunc),
348    /* 203 */ SyscallDesc("msgsnd", unimplementedFunc),
349    /* 204 */ SyscallDesc("semctl", unimplementedFunc),
350    /* 205 */ SyscallDesc("semget", unimplementedFunc),
351    /* 206 */ SyscallDesc("semop", unimplementedFunc),
352    /* 207 */ SyscallDesc("osf_utsname", unimplementedFunc),
353    /* 208 */ SyscallDesc("lchown", unimplementedFunc),
354    /* 209 */ SyscallDesc("osf_shmat", unimplementedFunc),
355    /* 210 */ SyscallDesc("shmctl", unimplementedFunc),
356    /* 211 */ SyscallDesc("shmdt", unimplementedFunc),
357    /* 212 */ SyscallDesc("shmget", unimplementedFunc),
358    /* 213 */ SyscallDesc("osf_mvalid", unimplementedFunc),
359    /* 214 */ SyscallDesc("osf_getaddressconf", unimplementedFunc),
360    /* 215 */ SyscallDesc("osf_msleep", unimplementedFunc),
361    /* 216 */ SyscallDesc("osf_mwakeup", unimplementedFunc),
362    /* 217 */ SyscallDesc("msync", unimplementedFunc),
363    /* 218 */ SyscallDesc("osf_signal", unimplementedFunc),
364    /* 219 */ SyscallDesc("osf_utc_gettime", unimplementedFunc),
365    /* 220 */ SyscallDesc("osf_utc_adjtime", unimplementedFunc),
366    /* 221 */ SyscallDesc("unknown #221", unimplementedFunc),
367    /* 222 */ SyscallDesc("osf_security", unimplementedFunc),
368    /* 223 */ SyscallDesc("osf_kloadcall", unimplementedFunc),
369    /* 224 */ SyscallDesc("unknown #224", unimplementedFunc),
370    /* 225 */ SyscallDesc("unknown #225", unimplementedFunc),
371    /* 226 */ SyscallDesc("unknown #226", unimplementedFunc),
372    /* 227 */ SyscallDesc("unknown #227", unimplementedFunc),
373    /* 228 */ SyscallDesc("unknown #228", unimplementedFunc),
374    /* 229 */ SyscallDesc("unknown #229", unimplementedFunc),
375    /* 230 */ SyscallDesc("unknown #230", unimplementedFunc),
376    /* 231 */ SyscallDesc("unknown #231", unimplementedFunc),
377    /* 232 */ SyscallDesc("unknown #232", unimplementedFunc),
378    /* 233 */ SyscallDesc("getpgid", unimplementedFunc),
379    /* 234 */ SyscallDesc("getsid", unimplementedFunc),
380    /* 235 */ SyscallDesc("sigaltstack", ignoreFunc),
381    /* 236 */ SyscallDesc("osf_waitid", unimplementedFunc),
382    /* 237 */ SyscallDesc("osf_priocntlset", unimplementedFunc),
383    /* 238 */ SyscallDesc("osf_sigsendset", unimplementedFunc),
384    /* 239 */ SyscallDesc("osf_set_speculative", unimplementedFunc),
385    /* 240 */ SyscallDesc("osf_msfs_syscall", unimplementedFunc),
386    /* 241 */ SyscallDesc("osf_sysinfo", unimplementedFunc),
387    /* 242 */ SyscallDesc("osf_uadmin", unimplementedFunc),
388    /* 243 */ SyscallDesc("osf_fuser", unimplementedFunc),
389    /* 244 */ SyscallDesc("osf_proplist_syscall", unimplementedFunc),
390    /* 245 */ SyscallDesc("osf_ntp_adjtime", unimplementedFunc),
391    /* 246 */ SyscallDesc("osf_ntp_gettime", unimplementedFunc),
392    /* 247 */ SyscallDesc("osf_pathconf", unimplementedFunc),
393    /* 248 */ SyscallDesc("osf_fpathconf", unimplementedFunc),
394    /* 249 */ SyscallDesc("unknown #249", unimplementedFunc),
395    /* 250 */ SyscallDesc("osf_uswitch", unimplementedFunc),
396    /* 251 */ SyscallDesc("osf_usleep_thread", unimplementedFunc),
397    /* 252 */ SyscallDesc("osf_audcntl", unimplementedFunc),
398    /* 253 */ SyscallDesc("osf_audgen", unimplementedFunc),
399    /* 254 */ SyscallDesc("sysfs", unimplementedFunc),
400    /* 255 */ SyscallDesc("osf_subsys_info", unimplementedFunc),
401    /* 256 */ SyscallDesc("osf_getsysinfo", osf_getsysinfoFunc),
402    /* 257 */ SyscallDesc("osf_setsysinfo", osf_setsysinfoFunc),
403    /* 258 */ SyscallDesc("osf_afs_syscall", unimplementedFunc),
404    /* 259 */ SyscallDesc("osf_swapctl", unimplementedFunc),
405    /* 260 */ SyscallDesc("osf_memcntl", unimplementedFunc),
406    /* 261 */ SyscallDesc("osf_fdatasync", unimplementedFunc),
407    /* 262 */ SyscallDesc("unknown #262", unimplementedFunc),
408    /* 263 */ SyscallDesc("unknown #263", unimplementedFunc),
409    /* 264 */ SyscallDesc("unknown #264", unimplementedFunc),
410    /* 265 */ SyscallDesc("unknown #265", unimplementedFunc),
411    /* 266 */ SyscallDesc("unknown #266", unimplementedFunc),
412    /* 267 */ SyscallDesc("unknown #267", unimplementedFunc),
413    /* 268 */ SyscallDesc("unknown #268", unimplementedFunc),
414    /* 269 */ SyscallDesc("unknown #269", unimplementedFunc),
415    /* 270 */ SyscallDesc("unknown #270", unimplementedFunc),
416    /* 271 */ SyscallDesc("unknown #271", unimplementedFunc),
417    /* 272 */ SyscallDesc("unknown #272", unimplementedFunc),
418    /* 273 */ SyscallDesc("unknown #273", unimplementedFunc),
419    /* 274 */ SyscallDesc("unknown #274", unimplementedFunc),
420    /* 275 */ SyscallDesc("unknown #275", unimplementedFunc),
421    /* 276 */ SyscallDesc("unknown #276", unimplementedFunc),
422    /* 277 */ SyscallDesc("unknown #277", unimplementedFunc),
423    /* 278 */ SyscallDesc("unknown #278", unimplementedFunc),
424    /* 279 */ SyscallDesc("unknown #279", unimplementedFunc),
425    /* 280 */ SyscallDesc("unknown #280", unimplementedFunc),
426    /* 281 */ SyscallDesc("unknown #281", unimplementedFunc),
427    /* 282 */ SyscallDesc("unknown #282", unimplementedFunc),
428    /* 283 */ SyscallDesc("unknown #283", unimplementedFunc),
429    /* 284 */ SyscallDesc("unknown #284", unimplementedFunc),
430    /* 285 */ SyscallDesc("unknown #285", unimplementedFunc),
431    /* 286 */ SyscallDesc("unknown #286", unimplementedFunc),
432    /* 287 */ SyscallDesc("unknown #287", unimplementedFunc),
433    /* 288 */ SyscallDesc("unknown #288", unimplementedFunc),
434    /* 289 */ SyscallDesc("unknown #289", unimplementedFunc),
435    /* 290 */ SyscallDesc("unknown #290", unimplementedFunc),
436    /* 291 */ SyscallDesc("unknown #291", unimplementedFunc),
437    /* 292 */ SyscallDesc("unknown #292", unimplementedFunc),
438    /* 293 */ SyscallDesc("unknown #293", unimplementedFunc),
439    /* 294 */ SyscallDesc("unknown #294", unimplementedFunc),
440    /* 295 */ SyscallDesc("unknown #295", unimplementedFunc),
441    /* 296 */ SyscallDesc("unknown #296", unimplementedFunc),
442    /* 297 */ SyscallDesc("unknown #297", unimplementedFunc),
443    /* 298 */ SyscallDesc("unknown #298", unimplementedFunc),
444    /* 299 */ SyscallDesc("unknown #299", unimplementedFunc),
445/*
446 * Linux-specific system calls begin at 300
447 */
448    /* 300 */ SyscallDesc("bdflush", unimplementedFunc),
449    /* 301 */ SyscallDesc("sethae", unimplementedFunc),
450    /* 302 */ SyscallDesc("mount", unimplementedFunc),
451    /* 303 */ SyscallDesc("old_adjtimex", unimplementedFunc),
452    /* 304 */ SyscallDesc("swapoff", unimplementedFunc),
453    /* 305 */ SyscallDesc("getdents", unimplementedFunc),
454    /* 306 */ SyscallDesc("create_module", unimplementedFunc),
455    /* 307 */ SyscallDesc("init_module", unimplementedFunc),
456    /* 308 */ SyscallDesc("delete_module", unimplementedFunc),
457    /* 309 */ SyscallDesc("get_kernel_syms", unimplementedFunc),
458    /* 310 */ SyscallDesc("syslog", unimplementedFunc),
459    /* 311 */ SyscallDesc("reboot", unimplementedFunc),
460    /* 312 */ SyscallDesc("clone", unimplementedFunc),
461    /* 313 */ SyscallDesc("uselib", unimplementedFunc),
462    /* 314 */ SyscallDesc("mlock", unimplementedFunc),
463    /* 315 */ SyscallDesc("munlock", unimplementedFunc),
464    /* 316 */ SyscallDesc("mlockall", unimplementedFunc),
465    /* 317 */ SyscallDesc("munlockall", unimplementedFunc),
466    /* 318 */ SyscallDesc("sysinfo", unimplementedFunc),
467    /* 319 */ SyscallDesc("_sysctl", unimplementedFunc),
468    /* 320 */ SyscallDesc("was sys_idle", unimplementedFunc),
469    /* 321 */ SyscallDesc("oldumount", unimplementedFunc),
470    /* 322 */ SyscallDesc("swapon", unimplementedFunc),
471    /* 323 */ SyscallDesc("times", ignoreFunc),
472    /* 324 */ SyscallDesc("personality", unimplementedFunc),
473    /* 325 */ SyscallDesc("setfsuid", unimplementedFunc),
474    /* 326 */ SyscallDesc("setfsgid", unimplementedFunc),
475    /* 327 */ SyscallDesc("ustat", unimplementedFunc),
476    /* 328 */ SyscallDesc("statfs", unimplementedFunc),
477    /* 329 */ SyscallDesc("fstatfs", unimplementedFunc),
478    /* 330 */ SyscallDesc("sched_setparam", unimplementedFunc),
479    /* 331 */ SyscallDesc("sched_getparam", unimplementedFunc),
480    /* 332 */ SyscallDesc("sched_setscheduler", unimplementedFunc),
481    /* 333 */ SyscallDesc("sched_getscheduler", unimplementedFunc),
482    /* 334 */ SyscallDesc("sched_yield", unimplementedFunc),
483    /* 335 */ SyscallDesc("sched_get_priority_max", unimplementedFunc),
484    /* 336 */ SyscallDesc("sched_get_priority_min", unimplementedFunc),
485    /* 337 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc),
486    /* 338 */ SyscallDesc("afs_syscall", unimplementedFunc),
487    /* 339 */ SyscallDesc("uname", unameFunc),
488    /* 340 */ SyscallDesc("nanosleep", unimplementedFunc),
489    /* 341 */ SyscallDesc("mremap", unimplementedFunc),
490    /* 342 */ SyscallDesc("nfsservctl", unimplementedFunc),
491    /* 343 */ SyscallDesc("setresuid", unimplementedFunc),
492    /* 344 */ SyscallDesc("getresuid", unimplementedFunc),
493    /* 345 */ SyscallDesc("pciconfig_read", unimplementedFunc),
494    /* 346 */ SyscallDesc("pciconfig_write", unimplementedFunc),
495    /* 347 */ SyscallDesc("query_module", unimplementedFunc),
496    /* 348 */ SyscallDesc("prctl", unimplementedFunc),
497    /* 349 */ SyscallDesc("pread", unimplementedFunc),
498    /* 350 */ SyscallDesc("pwrite", unimplementedFunc),
499    /* 351 */ SyscallDesc("rt_sigreturn", unimplementedFunc),
500    /* 352 */ SyscallDesc("rt_sigaction", ignoreFunc),
501    /* 353 */ SyscallDesc("rt_sigprocmask", unimplementedFunc),
502    /* 354 */ SyscallDesc("rt_sigpending", unimplementedFunc),
503    /* 355 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc),
504    /* 356 */ SyscallDesc("rt_sigqueueinfo", unimplementedFunc),
505    /* 357 */ SyscallDesc("rt_sigsuspend", unimplementedFunc),
506    /* 358 */ SyscallDesc("select", unimplementedFunc),
507    /* 359 */ SyscallDesc("gettimeofday", gettimeofdayFunc<Linux>),
508    /* 360 */ SyscallDesc("settimeofday", unimplementedFunc),
509    /* 361 */ SyscallDesc("getitimer", unimplementedFunc),
510    /* 362 */ SyscallDesc("setitimer", unimplementedFunc),
511    /* 363 */ SyscallDesc("utimes", utimesFunc<Linux>),
512    /* 364 */ SyscallDesc("getrusage", getrusageFunc<Linux>),
513    /* 365 */ SyscallDesc("wait4", unimplementedFunc),
514    /* 366 */ SyscallDesc("adjtimex", unimplementedFunc),
515    /* 367 */ SyscallDesc("getcwd", unimplementedFunc),
516    /* 368 */ SyscallDesc("capget", unimplementedFunc),
517    /* 369 */ SyscallDesc("capset", unimplementedFunc),
518    /* 370 */ SyscallDesc("sendfile", unimplementedFunc),
519    /* 371 */ SyscallDesc("setresgid", unimplementedFunc),
520    /* 372 */ SyscallDesc("getresgid", unimplementedFunc),
521    /* 373 */ SyscallDesc("dipc", unimplementedFunc),
522    /* 374 */ SyscallDesc("pivot_root", unimplementedFunc),
523    /* 375 */ SyscallDesc("mincore", unimplementedFunc),
524    /* 376 */ SyscallDesc("pciconfig_iobase", unimplementedFunc),
525    /* 377 */ SyscallDesc("getdents64", unimplementedFunc),
526    /* 378 */ SyscallDesc("gettid", unimplementedFunc),
527    /* 379 */ SyscallDesc("readahead", unimplementedFunc),
528    /* 380 */ SyscallDesc("security", unimplementedFunc),
529    /* 381 */ SyscallDesc("tkill", unimplementedFunc),
530    /* 382 */ SyscallDesc("setxattr", unimplementedFunc),
531    /* 383 */ SyscallDesc("lsetxattr", unimplementedFunc),
532    /* 384 */ SyscallDesc("fsetxattr", unimplementedFunc),
533    /* 385 */ SyscallDesc("getxattr", unimplementedFunc),
534    /* 386 */ SyscallDesc("lgetxattr", unimplementedFunc),
535    /* 387 */ SyscallDesc("fgetxattr", unimplementedFunc),
536    /* 388 */ SyscallDesc("listxattr", unimplementedFunc),
537    /* 389 */ SyscallDesc("llistxattr", unimplementedFunc),
538    /* 390 */ SyscallDesc("flistxattr", unimplementedFunc),
539    /* 391 */ SyscallDesc("removexattr", unimplementedFunc),
540    /* 392 */ SyscallDesc("lremovexattr", unimplementedFunc),
541    /* 393 */ SyscallDesc("fremovexattr", unimplementedFunc),
542    /* 394 */ SyscallDesc("futex", unimplementedFunc),
543    /* 395 */ SyscallDesc("sched_setaffinity", unimplementedFunc),
544    /* 396 */ SyscallDesc("sched_getaffinity", unimplementedFunc),
545    /* 397 */ SyscallDesc("tuxcall", unimplementedFunc),
546    /* 398 */ SyscallDesc("io_setup", unimplementedFunc),
547    /* 399 */ SyscallDesc("io_destroy", unimplementedFunc),
548    /* 400 */ SyscallDesc("io_getevents", unimplementedFunc),
549    /* 401 */ SyscallDesc("io_submit", unimplementedFunc),
550    /* 402 */ SyscallDesc("io_cancel", unimplementedFunc),
551    /* 403 */ SyscallDesc("unknown #403", unimplementedFunc),
552    /* 404 */ SyscallDesc("unknown #404", unimplementedFunc),
553    /* 405 */ SyscallDesc("exit_group", exitFunc), // exit all threads...
554    /* 406 */ SyscallDesc("lookup_dcookie", unimplementedFunc),
555    /* 407 */ SyscallDesc("sys_epoll_create", unimplementedFunc),
556    /* 408 */ SyscallDesc("sys_epoll_ctl", unimplementedFunc),
557    /* 409 */ SyscallDesc("sys_epoll_wait", unimplementedFunc),
558    /* 410 */ SyscallDesc("remap_file_pages", unimplementedFunc),
559    /* 411 */ SyscallDesc("set_tid_address", unimplementedFunc),
560    /* 412 */ SyscallDesc("restart_syscall", unimplementedFunc),
561    /* 413 */ SyscallDesc("fadvise64", unimplementedFunc),
562    /* 414 */ SyscallDesc("timer_create", unimplementedFunc),
563    /* 415 */ SyscallDesc("timer_settime", unimplementedFunc),
564    /* 416 */ SyscallDesc("timer_gettime", unimplementedFunc),
565    /* 417 */ SyscallDesc("timer_getoverrun", unimplementedFunc),
566    /* 418 */ SyscallDesc("timer_delete", unimplementedFunc),
567    /* 419 */ SyscallDesc("clock_settime", unimplementedFunc),
568    /* 420 */ SyscallDesc("clock_gettime", unimplementedFunc),
569    /* 421 */ SyscallDesc("clock_getres", unimplementedFunc),
570    /* 422 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
571    /* 423 */ SyscallDesc("semtimedop", unimplementedFunc),
572    /* 424 */ SyscallDesc("tgkill", unimplementedFunc),
573    /* 425 */ SyscallDesc("stat64", unimplementedFunc),
574    /* 426 */ SyscallDesc("lstat64", lstat64Func<Linux>),
575    /* 427 */ SyscallDesc("fstat64", fstat64Func<Linux>),
576    /* 428 */ SyscallDesc("vserver", unimplementedFunc),
577    /* 429 */ SyscallDesc("mbind", unimplementedFunc),
578    /* 430 */ SyscallDesc("get_mempolicy", unimplementedFunc),
579    /* 431 */ SyscallDesc("set_mempolicy", unimplementedFunc),
580    /* 432 */ SyscallDesc("mq_open", unimplementedFunc),
581    /* 433 */ SyscallDesc("mq_unlink", unimplementedFunc),
582    /* 434 */ SyscallDesc("mq_timedsend", unimplementedFunc),
583    /* 435 */ SyscallDesc("mq_timedreceive", unimplementedFunc),
584    /* 436 */ SyscallDesc("mq_notify", unimplementedFunc),
585    /* 437 */ SyscallDesc("mq_getsetattr", unimplementedFunc),
586    /* 438 */ SyscallDesc("waitid", unimplementedFunc),
587    /* 439 */ SyscallDesc("add_key", unimplementedFunc),
588    /* 440 */ SyscallDesc("request_key", unimplementedFunc),
589    /* 441 */ SyscallDesc("keyctl", unimplementedFunc)
590};
591
592AlphaLinuxProcess::AlphaLinuxProcess(const std::string &name,
593                                     ObjectFile *objFile,
594                                     int stdin_fd,
595                                     int stdout_fd,
596                                     int stderr_fd,
597                                     std::vector<std::string> &argv,
598                                     std::vector<std::string> &envp)
599    : LiveProcess(name, objFile, stdin_fd, stdout_fd, stderr_fd, argv, envp),
600     Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
601{
602    init_regs->intRegFile[0] = 0;
603}
604
605
606
607SyscallDesc*
608AlphaLinuxProcess::getDesc(int callnum)
609{
610    if (callnum < 0 || callnum > Num_Syscall_Descs)
611        return NULL;
612    return &syscallDescs[callnum];
613}
614