1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * Copyright (c) 2007-2008 The Florida State University
4 * Copyright (c) 2009 The University of Edinburgh
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Authors: Korey Sewell
31 *          Stephen Hines
32 *          Timothy M. Jones
33 */
34
35#include "arch/power/linux/process.hh"
36
37#include "arch/power/isa_traits.hh"
38#include "arch/power/linux/linux.hh"
39#include "base/loader/object_file.hh"
40#include "base/trace.hh"
41#include "cpu/thread_context.hh"
42#include "kern/linux/linux.hh"
43#include "sim/process.hh"
44#include "sim/syscall_desc.hh"
45#include "sim/syscall_emul.hh"
46#include "sim/system.hh"
47
48using namespace std;
49using namespace PowerISA;
50
51namespace
52{
53
54class PowerLinuxObjectFileLoader : public ObjectFile::Loader
55{
56  public:
57    Process *
58    load(ProcessParams *params, ObjectFile *obj_file) override
59    {
60        if (obj_file->getArch() != ObjectFile::Power)
61            return nullptr;
62
63        auto opsys = obj_file->getOpSys();
64
65        if (opsys == ObjectFile::UnknownOpSys) {
66            warn("Unknown operating system; assuming Linux.");
67            opsys = ObjectFile::Linux;
68        }
69
70        if (opsys != ObjectFile::Linux)
71            return nullptr;
72
73        return new PowerLinuxProcess(params, obj_file);
74    }
75};
76
77PowerLinuxObjectFileLoader loader;
78
79} // anonymous namespace
80
81/// Target uname() handler.
82static SyscallReturn
83unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
84{
85    int index = 0;
86    auto process = tc->getProcessPtr();
87    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
88
89    strcpy(name->sysname, "Linux");
90    strcpy(name->nodename, "sim.gem5.org");
91    strcpy(name->release, process->release.c_str());
92    strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
93    strcpy(name->machine, "power");
94
95    name.copyOut(tc->getVirtProxy());
96    return 0;
97}
98
99SyscallDesc PowerLinuxProcess::syscallDescs[] = {
100    /*  0 */ SyscallDesc("syscall", unimplementedFunc),
101    /*  1 */ SyscallDesc("exit", exitFunc),
102    /*  2 */ SyscallDesc("fork", unimplementedFunc),
103    /*  3 */ SyscallDesc("read", readFunc<PowerLinux>),
104    /*  4 */ SyscallDesc("write", writeFunc<PowerLinux>),
105    /*  5 */ SyscallDesc("open", openFunc<PowerLinux>),
106    /*  6 */ SyscallDesc("close", closeFunc),
107    /*  7 */ SyscallDesc("waitpid", unimplementedFunc), //???
108    /*  8 */ SyscallDesc("creat", unimplementedFunc),
109    /*  9 */ SyscallDesc("link", unimplementedFunc),
110    /* 10 */ SyscallDesc("unlink", unlinkFunc),
111    /* 11 */ SyscallDesc("execve", unimplementedFunc),
112    /* 12 */ SyscallDesc("chdir", unimplementedFunc),
113    /* 13 */ SyscallDesc("time", timeFunc<PowerLinux>),
114    /* 14 */ SyscallDesc("mknod", unimplementedFunc),
115    /* 15 */ SyscallDesc("chmod", chmodFunc<PowerLinux>),
116    /* 16 */ SyscallDesc("lchown", chownFunc),
117    /* 17 */ SyscallDesc("break", brkFunc), //???
118    /* 18 */ SyscallDesc("unused#18", unimplementedFunc), //???
119    /* 19 */ SyscallDesc("lseek", lseekFunc),
120    /* 20 */ SyscallDesc("getpid", getpidFunc),
121    /* 21 */ SyscallDesc("mount", unimplementedFunc),
122    /* 22 */ SyscallDesc("umount", unimplementedFunc),
123    /* 23 */ SyscallDesc("setuid", setuidFunc),
124    /* 24 */ SyscallDesc("getuid", getuidFunc),
125    /* 25 */ SyscallDesc("stime", unimplementedFunc),
126    /* 26 */ SyscallDesc("ptrace", unimplementedFunc),
127    /* 27 */ SyscallDesc("alarm", unimplementedFunc),
128    /* 28 */ SyscallDesc("unused#28", unimplementedFunc),
129    /* 29 */ SyscallDesc("pause", unimplementedFunc),
130    /* 30 */ SyscallDesc("utime", unimplementedFunc),
131    /* 31 */ SyscallDesc("stty", unimplementedFunc),
132    /* 32 */ SyscallDesc("gtty", unimplementedFunc),
133    /* 33 */ SyscallDesc("access", unimplementedFunc),
134    /* 34 */ SyscallDesc("nice", unimplementedFunc),
135    /* 35 */ SyscallDesc("ftime", unimplementedFunc),
136    /* 36 */ SyscallDesc("sync", unimplementedFunc),
137    /* 37 */ SyscallDesc("kill", ignoreFunc),
138    /* 38 */ SyscallDesc("rename", renameFunc),
139    /* 39 */ SyscallDesc("mkdir", unimplementedFunc),
140    /* 40 */ SyscallDesc("rmdir", unimplementedFunc),
141    /* 41 */ SyscallDesc("dup", dupFunc),
142    /* 42 */ SyscallDesc("pipe", unimplementedFunc),
143    /* 43 */ SyscallDesc("times", timesFunc<PowerLinux>),
144    /* 44 */ SyscallDesc("prof", unimplementedFunc),
145    /* 45 */ SyscallDesc("brk", brkFunc),
146    /* 46 */ SyscallDesc("setgid", unimplementedFunc),
147    /* 47 */ SyscallDesc("getgid", getgidFunc),
148    /* 48 */ SyscallDesc("signal", ignoreFunc),
149    /* 49 */ SyscallDesc("geteuid", geteuidFunc),
150    /* 50 */ SyscallDesc("getegid", getegidFunc),
151    /* 51 */ SyscallDesc("acct", unimplementedFunc),
152    /* 52 */ SyscallDesc("umount2", unimplementedFunc),
153    /* 53 */ SyscallDesc("lock", unimplementedFunc),
154    /* 54 */ SyscallDesc("ioctl", ioctlFunc<PowerLinux>),
155    /* 55 */ SyscallDesc("fcntl", fcntlFunc),
156    /* 56 */ SyscallDesc("mpx", unimplementedFunc),
157    /* 57 */ SyscallDesc("setpgid", unimplementedFunc),
158    /* 58 */ SyscallDesc("ulimit", unimplementedFunc),
159    /* 59 */ SyscallDesc("unused#59", unimplementedFunc),
160    /* 60 */ SyscallDesc("umask", umaskFunc),
161    /* 61 */ SyscallDesc("chroot", unimplementedFunc),
162    /* 62 */ SyscallDesc("ustat", unimplementedFunc),
163    /* 63 */ SyscallDesc("dup2", unimplementedFunc),
164    /* 64 */ SyscallDesc("getppid", getpagesizeFunc),
165    /* 65 */ SyscallDesc("getpgrp", unimplementedFunc),
166    /* 66 */ SyscallDesc("setsid", unimplementedFunc),
167    /* 67 */ SyscallDesc("sigaction",unimplementedFunc),
168    /* 68 */ SyscallDesc("sgetmask", unimplementedFunc),
169    /* 69 */ SyscallDesc("ssetmask", unimplementedFunc),
170    /* 70 */ SyscallDesc("setreuid", unimplementedFunc),
171    /* 71 */ SyscallDesc("setregid", unimplementedFunc),
172    /* 72 */ SyscallDesc("sigsuspend", unimplementedFunc),
173    /* 73 */ SyscallDesc("sigpending", unimplementedFunc),
174    /* 74 */ SyscallDesc("sethostname", ignoreFunc),
175    /* 75 */ SyscallDesc("setrlimit", ignoreFunc),
176    /* 76 */ SyscallDesc("getrlimit", unimplementedFunc),
177    /* 77 */ SyscallDesc("getrusage", ignoreFunc),
178    /* 78 */ SyscallDesc("gettimeofday", unimplementedFunc),
179    /* 79 */ SyscallDesc("settimeofday", unimplementedFunc),
180    /* 80 */ SyscallDesc("getgroups", unimplementedFunc),
181    /* 81 */ SyscallDesc("setgroups", unimplementedFunc),
182    /* 82 */ SyscallDesc("reserved#82", unimplementedFunc),
183    /* 83 */ SyscallDesc("symlink", unimplementedFunc),
184    /* 84 */ SyscallDesc("unused#84", unimplementedFunc),
185    /* 85 */ SyscallDesc("readlink", unimplementedFunc),
186    /* 86 */ SyscallDesc("uselib", unimplementedFunc),
187    /* 87 */ SyscallDesc("swapon", gethostnameFunc),
188    /* 88 */ SyscallDesc("reboot", unimplementedFunc),
189    /* 89 */ SyscallDesc("readdir", unimplementedFunc),
190    /* 90 */ SyscallDesc("mmap", mmapFunc<PowerLinux>),
191    /* 91 */ SyscallDesc("munmap",munmapFunc),
192    /* 92 */ SyscallDesc("truncate", truncateFunc),
193    /* 93 */ SyscallDesc("ftruncate", ftruncateFunc),
194    /* 94 */ SyscallDesc("fchmod", unimplementedFunc),
195    /* 95 */ SyscallDesc("fchown", unimplementedFunc),
196    /* 96 */ SyscallDesc("getpriority", unimplementedFunc),
197    /* 97 */ SyscallDesc("setpriority", unimplementedFunc),
198    /* 98 */ SyscallDesc("profil", unimplementedFunc),
199    /* 99 */ SyscallDesc("statfs", unimplementedFunc),
200    /* 100 */ SyscallDesc("fstatfs", unimplementedFunc),
201    /* 101 */ SyscallDesc("ioperm", unimplementedFunc),
202    /* 102 */ SyscallDesc("socketcall", unimplementedFunc),
203    /* 103 */ SyscallDesc("syslog", unimplementedFunc),
204    /* 104 */ SyscallDesc("setitimer", unimplementedFunc),
205    /* 105 */ SyscallDesc("getitimer", unimplementedFunc),
206    /* 106 */ SyscallDesc("stat",  statFunc<PowerLinux>),
207    /* 107 */ SyscallDesc("lstat", unimplementedFunc),
208    /* 108 */ SyscallDesc("fstat", fstatFunc<PowerLinux>),
209    /* 109 */ SyscallDesc("unused#109", unimplementedFunc),
210    /* 110 */ SyscallDesc("iopl", unimplementedFunc),
211    /* 111 */ SyscallDesc("vhangup", unimplementedFunc),
212    /* 112 */ SyscallDesc("idle", ignoreFunc),
213    /* 113 */ SyscallDesc("vm86", unimplementedFunc),
214    /* 114 */ SyscallDesc("wait4", unimplementedFunc),
215    /* 115 */ SyscallDesc("swapoff", unimplementedFunc),
216    /* 116 */ SyscallDesc("sysinfo", unimplementedFunc),
217    /* 117 */ SyscallDesc("ipc", unimplementedFunc),
218    /* 118 */ SyscallDesc("fsync", unimplementedFunc),
219    /* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
220    /* 120 */ SyscallDesc("clone", unimplementedFunc),
221    /* 121 */ SyscallDesc("setdomainname", unimplementedFunc),
222    /* 122 */ SyscallDesc("uname", unameFunc),
223    /* 123 */ SyscallDesc("modify_ldt", unimplementedFunc),
224    /* 124 */ SyscallDesc("adjtimex", unimplementedFunc),
225    /* 125 */ SyscallDesc("mprotect", ignoreFunc),
226    /* 126 */ SyscallDesc("sigprocmask", unimplementedFunc),
227    /* 127 */ SyscallDesc("create_module", unimplementedFunc),
228    /* 128 */ SyscallDesc("init_module", unimplementedFunc),
229    /* 129 */ SyscallDesc("delete_module", unimplementedFunc),
230    /* 130 */ SyscallDesc("get_kernel_syms", unimplementedFunc),
231    /* 131 */ SyscallDesc("quotactl", unimplementedFunc),
232    /* 132 */ SyscallDesc("getpgid", unimplementedFunc),
233    /* 133 */ SyscallDesc("fchdir", unimplementedFunc),
234    /* 134 */ SyscallDesc("bdflush", unimplementedFunc),
235    /* 135 */ SyscallDesc("sysfs", unimplementedFunc),
236    /* 136 */ SyscallDesc("personality", unimplementedFunc),
237    /* 137 */ SyscallDesc("afs_syscall", unimplementedFunc),
238    /* 138 */ SyscallDesc("setfsuid", unimplementedFunc),
239    /* 139 */ SyscallDesc("setfsgid", unimplementedFunc),
240    /* 140 */ SyscallDesc("llseek", _llseekFunc),
241    /* 141 */ SyscallDesc("getdents", unimplementedFunc),
242    /* 142 */ SyscallDesc("newselect", unimplementedFunc),
243    /* 143 */ SyscallDesc("flock", unimplementedFunc),
244    /* 144 */ SyscallDesc("msync", unimplementedFunc),
245    /* 145 */ SyscallDesc("readv", unimplementedFunc),
246    /* 146 */ SyscallDesc("writev", writevFunc<PowerLinux>),
247    /* 147 */ SyscallDesc("getsid", unimplementedFunc),
248    /* 148 */ SyscallDesc("fdatasync", unimplementedFunc),
249    /* 149 */ SyscallDesc("sysctl", unimplementedFunc),
250    /* 150 */ SyscallDesc("mlock", unimplementedFunc),
251    /* 151 */ SyscallDesc("munlock", unimplementedFunc),
252    /* 152 */ SyscallDesc("mlockall", unimplementedFunc),
253    /* 153 */ SyscallDesc("munlockall", unimplementedFunc),
254    /* 154 */ SyscallDesc("sched_setparam", unimplementedFunc),
255    /* 155 */ SyscallDesc("sched_getparam", unimplementedFunc),
256    /* 156 */ SyscallDesc("sched_setscheduler", unimplementedFunc),
257    /* 157 */ SyscallDesc("sched_getscheduler", unimplementedFunc),
258    /* 158 */ SyscallDesc("sched_yield", unimplementedFunc),
259    /* 159 */ SyscallDesc("sched_get_priority_max", unimplementedFunc),
260    /* 160 */ SyscallDesc("sched_get_priority_min", unimplementedFunc),
261    /* 161 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc),
262    /* 162 */ SyscallDesc("nanosleep", unimplementedFunc),
263    /* 163 */ SyscallDesc("mremap", unimplementedFunc),
264    /* 164 */ SyscallDesc("setresuid", unimplementedFunc),
265    /* 165 */ SyscallDesc("getresuid", unimplementedFunc),
266    /* 166 */ SyscallDesc("vm862", unimplementedFunc),
267    /* 167 */ SyscallDesc("query_module", unimplementedFunc),
268    /* 168 */ SyscallDesc("poll", unimplementedFunc),
269    /* 169 */ SyscallDesc("nfsservctl", unimplementedFunc),
270    /* 170 */ SyscallDesc("setresgid", unimplementedFunc),
271    /* 171 */ SyscallDesc("getresgid", unimplementedFunc),
272    /* 172 */ SyscallDesc("prctl", unimplementedFunc),
273    /* 173 */ SyscallDesc("rt_sigaction", ignoreFunc),
274    /* 174 */ SyscallDesc("rt_sigprocmask", unimplementedFunc),
275    /* 175 */ SyscallDesc("unknown#175", unimplementedFunc),
276    /* 176 */ SyscallDesc("rt_sigpending", unimplementedFunc),
277    /* 177 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc),
278    /* 178 */ SyscallDesc("rt_sigqueueinfo", ignoreFunc),
279    /* 179 */ SyscallDesc("rt_sigsuspend", unimplementedFunc),
280    /* 180 */ SyscallDesc("pread64", unimplementedFunc),
281    /* 181 */ SyscallDesc("pwrite64", unimplementedFunc),
282    /* 182 */ SyscallDesc("chown", unimplementedFunc),
283    /* 183 */ SyscallDesc("getcwd", unimplementedFunc),
284    /* 184 */ SyscallDesc("capget", unimplementedFunc),
285    /* 185 */ SyscallDesc("capset", unimplementedFunc),
286    /* 186 */ SyscallDesc("sigaltstack", unimplementedFunc),
287    /* 187 */ SyscallDesc("sendfile", unimplementedFunc),
288    /* 188 */ SyscallDesc("getpmsg", unimplementedFunc),
289    /* 189 */ SyscallDesc("putpmsg", unimplementedFunc),
290    /* 190 */ SyscallDesc("ugetrlimit", ignoreFunc),
291    /* 191 */ SyscallDesc("getrlimit", unimplementedFunc),
292    /* 192 */ SyscallDesc("mmap2", mmapFunc<PowerLinux>),
293    /* 193 */ SyscallDesc("truncate64", unimplementedFunc),
294    /* 194 */ SyscallDesc("ftruncate64", ftruncate64Func),
295    /* 195 */ SyscallDesc("stat64", stat64Func<PowerLinux>),
296    /* 196 */ SyscallDesc("lstat64", lstat64Func<PowerLinux>),
297    /* 197 */ SyscallDesc("fstat64", fstat64Func<PowerLinux>),
298    /* 198 */ SyscallDesc("lchown", unimplementedFunc),
299    /* 199 */ SyscallDesc("getuid", getuidFunc),
300    /* 200 */ SyscallDesc("getgid", getgidFunc),
301    /* 201 */ SyscallDesc("geteuid", geteuidFunc),
302    /* 202 */ SyscallDesc("getegid", getegidFunc),
303    /* 203 */ SyscallDesc("setreuid", unimplementedFunc),
304    /* 204 */ SyscallDesc("fcntl64", fcntl64Func),
305    /* 205 */ SyscallDesc("getgroups", unimplementedFunc),
306    /* 206 */ SyscallDesc("setgroups", unimplementedFunc),
307    /* 207 */ SyscallDesc("fchown", unimplementedFunc),
308    /* 208 */ SyscallDesc("setresuid", unimplementedFunc),
309    /* 209 */ SyscallDesc("getresuid", unimplementedFunc),
310    /* 210 */ SyscallDesc("setresgid", unimplementedFunc),
311    /* 211 */ SyscallDesc("getresgid", unimplementedFunc),
312    /* 212 */ SyscallDesc("chown", unimplementedFunc),
313    /* 213 */ SyscallDesc("setuid", unimplementedFunc),
314    /* 214 */ SyscallDesc("setgid", unimplementedFunc),
315    /* 215 */ SyscallDesc("setfsuid", unimplementedFunc),
316    /* 216 */ SyscallDesc("setfsgid", unimplementedFunc),
317    /* 217 */ SyscallDesc("getdents64", unimplementedFunc),
318    /* 218 */ SyscallDesc("pivot_root", unimplementedFunc),
319    /* 219 */ SyscallDesc("mincore", unimplementedFunc),
320    /* 220 */ SyscallDesc("madvise", unimplementedFunc),
321    /* 221 */ SyscallDesc("unknown#221", unimplementedFunc),
322    /* 222 */ SyscallDesc("tux", unimplementedFunc),
323    /* 223 */ SyscallDesc("unknown#223", unimplementedFunc),
324    /* 224 */ SyscallDesc("gettid", unimplementedFunc),
325    /* 225 */ SyscallDesc("readahead", unimplementedFunc),
326    /* 226 */ SyscallDesc("setxattr", unimplementedFunc),
327    /* 227 */ SyscallDesc("lsetxattr", unimplementedFunc),
328    /* 228 */ SyscallDesc("fsetxattr", unimplementedFunc),
329    /* 229 */ SyscallDesc("getxattr", unimplementedFunc),
330    /* 230 */ SyscallDesc("lgetxattr", unimplementedFunc),
331    /* 231 */ SyscallDesc("fgetxattr", unimplementedFunc),
332    /* 232 */ SyscallDesc("listxattr", unimplementedFunc),
333    /* 233 */ SyscallDesc("llistxattr", unimplementedFunc),
334    /* 234 */ SyscallDesc("exit_group", exitGroupFunc),
335    /* 235 */ SyscallDesc("removexattr", unimplementedFunc),
336    /* 236 */ SyscallDesc("lremovexattr", unimplementedFunc),
337    /* 237 */ SyscallDesc("fremovexattr", unimplementedFunc),
338    /* 238 */ SyscallDesc("tkill", unimplementedFunc),
339    /* 239 */ SyscallDesc("sendfile64", unimplementedFunc),
340    /* 240 */ SyscallDesc("futex", unimplementedFunc),
341    /* 241 */ SyscallDesc("sched_setaffinity", unimplementedFunc),
342    /* 242 */ SyscallDesc("sched_getaffinity", unimplementedFunc),
343    /* 243 */ SyscallDesc("io_setup", unimplementedFunc),
344    /* 244 */ SyscallDesc("io_destory", unimplementedFunc),
345    /* 245 */ SyscallDesc("io_getevents", unimplementedFunc),
346    /* 246 */ SyscallDesc("io_submit", unimplementedFunc),
347    /* 247 */ SyscallDesc("io_cancel", unimplementedFunc),
348    /* 248 */ SyscallDesc("unknown#248", unimplementedFunc),
349    /* 249 */ SyscallDesc("lookup_dcookie", unimplementedFunc),
350    /* 250 */ SyscallDesc("epoll_create", unimplementedFunc),
351    /* 251 */ SyscallDesc("epoll_ctl", unimplementedFunc),
352    /* 252 */ SyscallDesc("epoll_wait", unimplementedFunc),
353    /* 253 */ SyscallDesc("remap_file_pages", unimplementedFunc),
354    /* 254 */ SyscallDesc("set_thread_area", unimplementedFunc),
355    /* 255 */ SyscallDesc("get_thread_area", unimplementedFunc),
356    /* 256 */ SyscallDesc("set_tid_address", unimplementedFunc),
357    /* 257 */ SyscallDesc("timer_create", unimplementedFunc),
358    /* 258 */ SyscallDesc("timer_settime", unimplementedFunc),
359    /* 259 */ SyscallDesc("timer_gettime", unimplementedFunc),
360    /* 260 */ SyscallDesc("timer_getoverrun", unimplementedFunc),
361    /* 261 */ SyscallDesc("timer_delete", unimplementedFunc),
362    /* 262 */ SyscallDesc("clock_settime", unimplementedFunc),
363    /* 263 */ SyscallDesc("clock_gettime", unimplementedFunc),
364    /* 264 */ SyscallDesc("clock_getres", unimplementedFunc),
365    /* 265 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
366    /* 266 */ SyscallDesc("statfs64", unimplementedFunc),
367    /* 267 */ SyscallDesc("fstatfs64", unimplementedFunc),
368    /* 268 */ SyscallDesc("tgkill", unimplementedFunc),
369    /* 269 */ SyscallDesc("utimes", unimplementedFunc),
370    /* 270 */ SyscallDesc("arm_fadvise64_64", unimplementedFunc),
371    /* 271 */ SyscallDesc("pciconfig_iobase", unimplementedFunc),
372    /* 272 */ SyscallDesc("pciconfig_read", unimplementedFunc),
373    /* 273 */ SyscallDesc("pciconfig_write", unimplementedFunc),
374    /* 274 */ SyscallDesc("mq_open", unimplementedFunc),
375    /* 275 */ SyscallDesc("mq_unlink", unimplementedFunc),
376    /* 276 */ SyscallDesc("mq_timedsend", unimplementedFunc),
377    /* 277 */ SyscallDesc("mq_timedreceive", unimplementedFunc),
378    /* 278 */ SyscallDesc("mq_notify", unimplementedFunc),
379    /* 279 */ SyscallDesc("mq_getsetattr", unimplementedFunc),
380    /* 280 */ SyscallDesc("waitid", unimplementedFunc),
381    /* 281 */ SyscallDesc("socket", unimplementedFunc),
382    /* 282 */ SyscallDesc("bind", unimplementedFunc),
383    /* 283 */ SyscallDesc("connect", unimplementedFunc),
384    /* 284 */ SyscallDesc("listen", unimplementedFunc),
385    /* 285 */ SyscallDesc("accept", unimplementedFunc),
386    /* 286 */ SyscallDesc("getsockname", unimplementedFunc),
387    /* 287 */ SyscallDesc("getpeername", unimplementedFunc),
388    /* 288 */ SyscallDesc("socketpair", unimplementedFunc),
389    /* 289 */ SyscallDesc("send", unimplementedFunc),
390    /* 290 */ SyscallDesc("sendto", unimplementedFunc),
391    /* 291 */ SyscallDesc("recv", unimplementedFunc),
392    /* 292 */ SyscallDesc("recvfrom", unimplementedFunc),
393    /* 293 */ SyscallDesc("shutdown", unimplementedFunc),
394    /* 294 */ SyscallDesc("setsockopt", unimplementedFunc),
395    /* 295 */ SyscallDesc("getsockopt", unimplementedFunc),
396    /* 296 */ SyscallDesc("sendmsg", unimplementedFunc),
397    /* 297 */ SyscallDesc("rcvmsg", unimplementedFunc),
398    /* 298 */ SyscallDesc("semop", unimplementedFunc),
399    /* 299 */ SyscallDesc("semget", unimplementedFunc),
400    /* 300 */ SyscallDesc("semctl", unimplementedFunc),
401    /* 301 */ SyscallDesc("msgsend", unimplementedFunc),
402    /* 302 */ SyscallDesc("msgrcv", unimplementedFunc),
403    /* 303 */ SyscallDesc("msgget", unimplementedFunc),
404    /* 304 */ SyscallDesc("msgctl", unimplementedFunc),
405    /* 305 */ SyscallDesc("shmat", unimplementedFunc),
406    /* 306 */ SyscallDesc("shmdt", unimplementedFunc),
407    /* 307 */ SyscallDesc("shmget", unimplementedFunc),
408    /* 308 */ SyscallDesc("shmctl", unimplementedFunc),
409    /* 309 */ SyscallDesc("add_key", unimplementedFunc),
410    /* 310 */ SyscallDesc("request_key", unimplementedFunc),
411    /* 311 */ SyscallDesc("keyctl", unimplementedFunc),
412    /* 312 */ SyscallDesc("semtimedop", unimplementedFunc),
413    /* 313 */ SyscallDesc("vserver", unimplementedFunc),
414    /* 314 */ SyscallDesc("ioprio_set", unimplementedFunc),
415    /* 315 */ SyscallDesc("ioprio_get", unimplementedFunc),
416    /* 316 */ SyscallDesc("inotify_init", unimplementedFunc),
417    /* 317 */ SyscallDesc("inotify_add_watch", unimplementedFunc),
418    /* 318 */ SyscallDesc("inotify_rm_watch", unimplementedFunc),
419    /* 319 */ SyscallDesc("mbind", unimplementedFunc),
420    /* 320 */ SyscallDesc("get_mempolicy", unimplementedFunc),
421    /* 321 */ SyscallDesc("set_mempolicy", unimplementedFunc),
422    /* 322 */ SyscallDesc("openat", unimplementedFunc),
423    /* 323 */ SyscallDesc("mkdirat", unimplementedFunc),
424    /* 324 */ SyscallDesc("mknodat", unimplementedFunc),
425    /* 325 */ SyscallDesc("fchownat", unimplementedFunc),
426    /* 326 */ SyscallDesc("futimesat", unimplementedFunc),
427    /* 327 */ SyscallDesc("fstatat64", unimplementedFunc),
428    /* 328 */ SyscallDesc("unlinkat", unimplementedFunc),
429    /* 329 */ SyscallDesc("renameat", unimplementedFunc),
430    /* 330 */ SyscallDesc("linkat", unimplementedFunc),
431    /* 331 */ SyscallDesc("symlinkat", unimplementedFunc),
432    /* 332 */ SyscallDesc("readlinkat", unimplementedFunc),
433    /* 333 */ SyscallDesc("fchmodat", unimplementedFunc),
434    /* 334 */ SyscallDesc("faccessat", unimplementedFunc),
435    /* 335 */ SyscallDesc("pselect6", unimplementedFunc),
436    /* 336 */ SyscallDesc("ppoll", unimplementedFunc),
437    /* 337 */ SyscallDesc("unshare", unimplementedFunc),
438    /* 338 */ SyscallDesc("set_robust_list", unimplementedFunc),
439    /* 339 */ SyscallDesc("get_robust_list", unimplementedFunc),
440    /* 340 */ SyscallDesc("splice", unimplementedFunc),
441    /* 341 */ SyscallDesc("arm_sync_file_range", unimplementedFunc),
442    /* 342 */ SyscallDesc("tee", unimplementedFunc),
443    /* 343 */ SyscallDesc("vmsplice", unimplementedFunc),
444    /* 344 */ SyscallDesc("move_pages", unimplementedFunc),
445    /* 345 */ SyscallDesc("getcpu", unimplementedFunc),
446    /* 346 */ SyscallDesc("epoll_pwait", unimplementedFunc),
447};
448
449PowerLinuxProcess::PowerLinuxProcess(ProcessParams * params,
450        ObjectFile *objFile)
451    : PowerProcess(params, objFile),
452      Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
453{
454}
455
456SyscallDesc*
457PowerLinuxProcess::getDesc(int callnum)
458{
459    if (callnum < 0 || callnum > Num_Syscall_Descs)
460        return NULL;
461
462    return &syscallDescs[callnum];
463}
464
465void
466PowerLinuxProcess::initState()
467{
468    PowerProcess::initState();
469}
470
471RegVal
472PowerLinuxProcess::getSyscallArg(ThreadContext *tc, int &i)
473{
474    // Linux apparently allows more parameter than the ABI says it should.
475    // This limit may need to be increased even further.
476    assert(i < 6);
477    return tc->readIntReg(ArgumentReg0 + i++);
478}
479
480void
481PowerLinuxProcess::setSyscallArg(ThreadContext *tc, int i, RegVal val)
482{
483    // Linux apparently allows more parameter than the ABI says it should.
484    // This limit may need to be increased even further.
485    assert(i < 6);
486    tc->setIntReg(ArgumentReg0 + i, val);
487}
488