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