process.cc revision 5958
12155SN/A/*
22155SN/A * Copyright (c) 2005 The Regents of The University of Michigan
32155SN/A * Copyright (c) 2007 MIPS Technologies, Inc.
42155SN/A * All rights reserved.
52155SN/A *
62155SN/A * Redistribution and use in source and binary forms, with or without
72155SN/A * modification, are permitted provided that the following conditions are
82155SN/A * met: redistributions of source code must retain the above copyright
92155SN/A * notice, this list of conditions and the following disclaimer;
102155SN/A * redistributions in binary form must reproduce the above copyright
112155SN/A * notice, this list of conditions and the following disclaimer in the
122155SN/A * documentation and/or other materials provided with the distribution;
132155SN/A * neither the name of the copyright holders nor the names of its
142155SN/A * contributors may be used to endorse or promote products derived from
152155SN/A * this software without specific prior written permission.
162155SN/A *
172155SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182155SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192155SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202155SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212155SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222155SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232155SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242155SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252155SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262155SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272155SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu *
292665Ssaidi@eecs.umich.edu * Authors: Gabe Black
302155SN/A *          Korey Sewell
312155SN/A */
322155SN/A
332155SN/A#include "arch/mips/linux/linux.hh"
342155SN/A#include "arch/mips/linux/process.hh"
352155SN/A#include "arch/mips/isa_traits.hh"
362155SN/A
372178SN/A#include "base/trace.hh"
382178SN/A#include "cpu/thread_context.hh"
392178SN/A#include "kern/linux/linux.hh"
402178SN/A
412178SN/A#include "sim/process.hh"
422178SN/A#include "sim/system.hh"
432178SN/A#include "sim/syscall_emul.hh"
442178SN/A#include "sim/eventq.hh"
452178SN/A
462178SN/Ausing namespace std;
472178SN/Ausing namespace MipsISA;
482178SN/A
492155SN/A/// Target uname() handler.
502178SN/Astatic SyscallReturn
512155SN/AunameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
522155SN/A          ThreadContext *tc)
532178SN/A{
542155SN/A    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
552155SN/A
562623SN/A    strcpy(name->sysname, "Linux");
572623SN/A    strcpy(name->nodename,"m5.eecs.umich.edu");
582623SN/A    strcpy(name->release, "2.4.20");
592623SN/A    strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
602623SN/A    strcpy(name->machine, "mips");
612155SN/A
622155SN/A    name.copyOut(tc->getMemPort());
632292SN/A    return 0;
642292SN/A}
652292SN/A
662292SN/A/// Target sys_getsysyinfo() handler.  Even though this call is
672292SN/A/// borrowed from Tru64, the subcases that get used appear to be
682292SN/A/// different in practice from those used by Tru64 processes.
692292SN/Astatic SyscallReturn
702292SN/Asys_getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
712766Sktlim@umich.edu                   ThreadContext *tc)
722766Sktlim@umich.edu{
732766Sktlim@umich.edu    unsigned op = process->getSyscallArg(tc, 0);
742766Sktlim@umich.edu    // unsigned nbytes = process->getSyscallArg(tc, 2);
752766Sktlim@umich.edu
762766Sktlim@umich.edu    switch (op) {
772766Sktlim@umich.edu
782178SN/A      case 45: { // GSI_IEEE_FP_CONTROL
792155SN/A          TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
802155SN/A          // I don't think this exactly matches the HW FPCR
812155SN/A          *fpcr = 0;
822155SN/A          fpcr.copyOut(tc->getMemPort());
832155SN/A          return 0;
842155SN/A      }
852766Sktlim@umich.edu
862155SN/A      default:
872623SN/A        cerr << "sys_getsysinfo: unknown op " << op << endl;
882155SN/A        abort();
892155SN/A        break;
902155SN/A    }
912155SN/A
922178SN/A    return 1;
932178SN/A}
942178SN/A
952766Sktlim@umich.edu/// Target sys_setsysinfo() handler.
962178SN/Astatic SyscallReturn
972178SN/Asys_setsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
982178SN/A                   ThreadContext *tc)
992178SN/A{
1002766Sktlim@umich.edu    unsigned op = process->getSyscallArg(tc, 0);
1012766Sktlim@umich.edu    // unsigned nbytes = process->getSyscallArg(tc, 2);
1022766Sktlim@umich.edu
1032788Sktlim@umich.edu    switch (op) {
1042178SN/A
1052733Sktlim@umich.edu      case 14: { // SSI_IEEE_FP_CONTROL
1062733Sktlim@umich.edu          TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
1072733Sktlim@umich.edu          // I don't think this exactly matches the HW FPCR
1082733Sktlim@umich.edu          fpcr.copyIn(tc->getMemPort());
1092178SN/A          DPRINTFR(SyscallVerbose, "sys_setsysinfo(SSI_IEEE_FP_CONTROL): "
1102178SN/A                   " setting FPCR to 0x%x\n", gtoh(*(uint64_t*)fpcr));
1112178SN/A          return 0;
1122178SN/A      }
1132178SN/A
1142178SN/A      default:
1152155SN/A        cerr << "sys_setsysinfo: unknown op " << op << endl;
1162155SN/A        abort();
1172155SN/A        break;
1182623SN/A    }
1192623SN/A
1202623SN/A    return 1;
1212623SN/A}
1222623SN/A
1232623SN/ASyscallDesc MipsLinuxProcess::syscallDescs[] = {
1242623SN/A    /*  0 */ SyscallDesc("syscall", unimplementedFunc),
1252623SN/A    /*  1 */ SyscallDesc("exit", exitFunc),
1262623SN/A    /*  2 */ SyscallDesc("fork", unimplementedFunc),
1272623SN/A    /*  3 */ SyscallDesc("read", readFunc),
1282623SN/A    /*  4 */ SyscallDesc("write", writeFunc),
1292155SN/A    /*  5 */ SyscallDesc("open", openFunc<MipsLinux>),
1302155SN/A    /*  6 */ SyscallDesc("close", closeFunc),
1312155SN/A    /*  7 */ SyscallDesc("waitpid", unimplementedFunc),
1322155SN/A    /*  8 */ SyscallDesc("creat", unimplementedFunc),
1332733Sktlim@umich.edu    /*  9 */ SyscallDesc("link", unimplementedFunc),
1342155SN/A    /* 10 */ SyscallDesc("unlink", unlinkFunc),
1352155SN/A    /* 11 */ SyscallDesc("execve", unimplementedFunc),
1362155SN/A    /* 12 */ SyscallDesc("chdir", unimplementedFunc),
1372155SN/A    /* 13 */ SyscallDesc("time", unimplementedFunc),
1382155SN/A    /* 14 */ SyscallDesc("mknod", unimplementedFunc),
1392765Sktlim@umich.edu    /* 15 */ SyscallDesc("chmod", chmodFunc<MipsLinux>),
1402155SN/A    /* 16 */ SyscallDesc("lchown", chownFunc),
1412155SN/A    /* 17 */ SyscallDesc("break", brkFunc),
1422155SN/A    /* 18 */ SyscallDesc("unused#18", unimplementedFunc),
1432155SN/A    /* 19 */ SyscallDesc("lseek", lseekFunc),
1442155SN/A    /* 20 */ SyscallDesc("getpid", getpidFunc),
1452155SN/A    /* 21 */ SyscallDesc("mount", unimplementedFunc),
1462292SN/A    /* 22 */ SyscallDesc("umount", unimplementedFunc),
1472155SN/A    /* 23 */ SyscallDesc("setuid", setuidFunc),
1482155SN/A    /* 24 */ SyscallDesc("getuid", getuidFunc),
1492155SN/A    /* 25 */ SyscallDesc("stime", unimplementedFunc),
1502292SN/A    /* 26 */ SyscallDesc("ptrace", unimplementedFunc),
1512292SN/A    /* 27 */ SyscallDesc("alarm", unimplementedFunc),
1522155SN/A    /* 28 */ SyscallDesc("unused#28", unimplementedFunc),
1532155SN/A    /* 29 */ SyscallDesc("pause", unimplementedFunc),
1542155SN/A    /* 30 */ SyscallDesc("utime", unimplementedFunc),
1552155SN/A    /* 31 */ SyscallDesc("stty", unimplementedFunc),
1562155SN/A    /* 32 */ SyscallDesc("gtty", unimplementedFunc),
1572292SN/A    /* 33 */ SyscallDesc("access", unimplementedFunc),
1582155SN/A    /* 34 */ SyscallDesc("nice", unimplementedFunc),
1592155SN/A    /* 35 */ SyscallDesc("ftime", unimplementedFunc),
1602155SN/A    /* 36 */ SyscallDesc("sync", unimplementedFunc),
1612766Sktlim@umich.edu    /* 37 */ SyscallDesc("kill", unimplementedFunc),
1622765Sktlim@umich.edu    /* 38 */ SyscallDesc("rename", unimplementedFunc),
1632155SN/A    /* 39 */ SyscallDesc("mkdir", mkdirFunc),
1642292SN/A    /* 40 */ SyscallDesc("rmdir", unimplementedFunc),
1652292SN/A    /* 41 */ SyscallDesc("dup", unimplementedFunc),
1662292SN/A    /* 42 */ SyscallDesc("pipe", pipePseudoFunc),
1672292SN/A    /* 43 */ SyscallDesc("times", unimplementedFunc),
1682292SN/A    /* 44 */ SyscallDesc("prof", unimplementedFunc),
1692292SN/A    /* 45 */ SyscallDesc("brk", brkFunc),
1702292SN/A    /* 46 */ SyscallDesc("setgid", unimplementedFunc),
1712292SN/A    /* 47 */ SyscallDesc("getgid", getgidFunc),
1722292SN/A    /* 48 */ SyscallDesc("signal", ignoreFunc),
1732292SN/A    /* 49 */ SyscallDesc("geteuid", geteuidFunc),
1742292SN/A    /* 50 */ SyscallDesc("getegid", getegidFunc),
1752292SN/A    /* 51 */ SyscallDesc("acct", unimplementedFunc),
1762292SN/A    /* 52 */ SyscallDesc("umount2", unimplementedFunc),
1772765Sktlim@umich.edu    /* 53 */ SyscallDesc("lock", unimplementedFunc),
1782765Sktlim@umich.edu    /* 54 */ SyscallDesc("ioctl", ioctlFunc<MipsLinux>),
1792292SN/A    /* 55 */ SyscallDesc("fcntl", fcntlFunc),
1802297SN/A    /* 56 */ SyscallDesc("mpx", unimplementedFunc),
1812297SN/A    /* 57 */ SyscallDesc("setpgid", unimplementedFunc),
1822292SN/A    /* 58 */ SyscallDesc("ulimit", unimplementedFunc),
1832766Sktlim@umich.edu    /* 59 */ SyscallDesc("unused#59", unimplementedFunc),
1842765Sktlim@umich.edu    /* 60 */ SyscallDesc("umask", umaskFunc),
1852292SN/A    /* 61 */ SyscallDesc("chroot", unimplementedFunc),
1862766Sktlim@umich.edu    /* 62 */ SyscallDesc("ustat", unimplementedFunc),
1872789Sktlim@umich.edu    /* 63 */ SyscallDesc("dup2", unimplementedFunc),
1882733Sktlim@umich.edu    /* 64 */ SyscallDesc("getppid", getpagesizeFunc),
1892733Sktlim@umich.edu    /* 65 */ SyscallDesc("getpgrp", unimplementedFunc),
1902733Sktlim@umich.edu    /* 66 */ SyscallDesc("setsid", unimplementedFunc),
1912733Sktlim@umich.edu    /* 67 */ SyscallDesc("sigaction",unimplementedFunc),
1922733Sktlim@umich.edu    /* 68 */ SyscallDesc("sgetmask", unimplementedFunc),
1932733Sktlim@umich.edu    /* 69 */ SyscallDesc("ssetmask", unimplementedFunc),
1942733Sktlim@umich.edu    /* 70 */ SyscallDesc("setreuid", unimplementedFunc),
1952733Sktlim@umich.edu    /* 71 */ SyscallDesc("setregid", unimplementedFunc),
1962733Sktlim@umich.edu    /* 72 */ SyscallDesc("sigsuspend", unimplementedFunc),
1972733Sktlim@umich.edu    /* 73 */ SyscallDesc("sigpending", unimplementedFunc),
1982315SN/A    /* 74 */ SyscallDesc("sethostname", ignoreFunc),
1992761Sstever@eecs.umich.edu    /* 75 */ SyscallDesc("setrlimit", unimplementedFunc/*setrlimitFunc<MipsLinux>*/),
2002155SN/A    /* 76 */ SyscallDesc("getrlimit", unimplementedFunc/*getrlimitFunc<MipsLinux>*/),
2012155SN/A    /* 77 */ SyscallDesc("getrusage", getrusageFunc<MipsLinux>),
2022155SN/A    /* 78 */ SyscallDesc("gettimeofday", unimplementedFunc),
2032155SN/A    /* 79 */ SyscallDesc("settimeofday", unimplementedFunc),
2042155SN/A    /* 80 */ SyscallDesc("getgroups", unimplementedFunc),
2052155SN/A    /* 81 */ SyscallDesc("setgroups", unimplementedFunc),
2062155SN/A    /* 82 */ SyscallDesc("reserved#82", unimplementedFunc),
2072155SN/A    /* 83 */ SyscallDesc("symlink", unimplementedFunc),
208    /* 84 */ SyscallDesc("unused#84", unimplementedFunc),
209    /* 85 */ SyscallDesc("readlink", readlinkFunc),
210    /* 86 */ SyscallDesc("uselib", unimplementedFunc),
211    /* 87 */ SyscallDesc("swapon", gethostnameFunc),
212    /* 88 */ SyscallDesc("reboot", unimplementedFunc),
213    /* 89 */ SyscallDesc("readdir", unimplementedFunc),
214    /* 90 */ SyscallDesc("mmap", mmapFunc<MipsLinux>),
215    /* 91 */ SyscallDesc("munmap",munmapFunc),
216    /* 92 */ SyscallDesc("truncate", truncateFunc),
217    /* 93 */ SyscallDesc("ftruncate", ftruncateFunc),
218    /* 94 */ SyscallDesc("fchmod", fchmodFunc<MipsLinux>),
219    /* 95 */ SyscallDesc("fchown", fchownFunc),
220    /* 96 */ SyscallDesc("getpriority", unimplementedFunc),
221    /* 97 */ SyscallDesc("setpriority", unimplementedFunc),
222    /* 98 */ SyscallDesc("profil", unimplementedFunc),
223    /* 99 */ SyscallDesc("statfs", unimplementedFunc),
224    /* 100 */ SyscallDesc("fstatfs", unimplementedFunc),
225    /* 101 */ SyscallDesc("ioperm", unimplementedFunc),
226    /* 102 */ SyscallDesc("socketcall", unimplementedFunc),
227    /* 103 */ SyscallDesc("syslog", unimplementedFunc),
228    /* 104 */ SyscallDesc("setitimer", unimplementedFunc),
229    /* 105 */ SyscallDesc("getitimer", unimplementedFunc),
230    /* 106 */ SyscallDesc("stat",  statFunc<MipsLinux>),
231    /* 107 */ SyscallDesc("lstat", unimplementedFunc),
232    /* 108 */ SyscallDesc("fstat", fstatFunc<MipsLinux>),
233    /* 109 */ SyscallDesc("unused#109", unimplementedFunc),
234    /* 110 */ SyscallDesc("iopl", unimplementedFunc),
235    /* 111 */ SyscallDesc("vhangup", unimplementedFunc),
236    /* 112 */ SyscallDesc("idle", ignoreFunc),
237    /* 113 */ SyscallDesc("vm86", unimplementedFunc),
238    /* 114 */ SyscallDesc("wait4", unimplementedFunc),
239    /* 115 */ SyscallDesc("swapoff", unimplementedFunc),
240    /* 116 */ SyscallDesc("sysinfo", unimplementedFunc),
241    /* 117 */ SyscallDesc("ipc", unimplementedFunc),
242    /* 118 */ SyscallDesc("fsync", unimplementedFunc),
243    /* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
244    /* 120 */ SyscallDesc("clone", unimplementedFunc/*cloneFunc<MipsLinux>*/),
245    /* 121 */ SyscallDesc("setdomainname", unimplementedFunc),
246    /* 122 */ SyscallDesc("uname", unameFunc),
247    /* 123 */ SyscallDesc("modify_ldt", unimplementedFunc),
248    /* 124 */ SyscallDesc("adjtimex", unimplementedFunc),
249    /* 125 */ SyscallDesc("mprotect", ignoreFunc),
250    /* 126 */ SyscallDesc("sigprocmask", unimplementedFunc),
251    /* 127 */ SyscallDesc("create_module", unimplementedFunc),
252    /* 128 */ SyscallDesc("init_module", unimplementedFunc),
253    /* 129 */ SyscallDesc("delete_module", unimplementedFunc),
254    /* 130 */ SyscallDesc("get_kernel_syms", unimplementedFunc),
255    /* 131 */ SyscallDesc("quotactl", unimplementedFunc),
256    /* 132 */ SyscallDesc("getpgid", unimplementedFunc),
257    /* 133 */ SyscallDesc("fchdir", unimplementedFunc),
258    /* 134 */ SyscallDesc("bdflush", unimplementedFunc),
259    /* 135 */ SyscallDesc("sysfs", unimplementedFunc),
260    /* 136 */ SyscallDesc("personality", unimplementedFunc),
261    /* 137 */ SyscallDesc("afs_syscall", unimplementedFunc),
262    /* 138 */ SyscallDesc("setfsuid", unimplementedFunc),
263    /* 139 */ SyscallDesc("setfsgid", unimplementedFunc),
264    /* 140 */ SyscallDesc("llseek", unimplementedFunc),
265    /* 141 */ SyscallDesc("getdents", unimplementedFunc),
266    /* 142 */ SyscallDesc("newselect", unimplementedFunc),
267    /* 143 */ SyscallDesc("flock", unimplementedFunc),
268    /* 144 */ SyscallDesc("msync", unimplementedFunc),
269    /* 145 */ SyscallDesc("readv", unimplementedFunc),
270    /* 146 */ SyscallDesc("writev", writevFunc<MipsLinux>),
271    /* 147 */ SyscallDesc("cacheflush", unimplementedFunc),
272    /* 148 */ SyscallDesc("cachectl", unimplementedFunc),
273    /* 149 */ SyscallDesc("sysmips", unimplementedFunc),
274    /* 150 */ SyscallDesc("unused#150", unimplementedFunc),
275    /* 151 */ SyscallDesc("getsid", unimplementedFunc),
276    /* 152 */ SyscallDesc("fdatasync", unimplementedFunc),
277    /* 153 */ SyscallDesc("sysctl", ignoreFunc),
278    /* 154 */ SyscallDesc("mlock", unimplementedFunc),
279    /* 155 */ SyscallDesc("munlock", unimplementedFunc),
280    /* 156 */ SyscallDesc("mlockall", unimplementedFunc),
281    /* 157 */ SyscallDesc("munlockall", unimplementedFunc),
282    /* 158 */ SyscallDesc("sched_setparam", unimplementedFunc),
283    /* 159 */ SyscallDesc("sched_getparam", unimplementedFunc),
284    /* 160 */ SyscallDesc("sched_setscheduler", unimplementedFunc),
285    /* 161 */ SyscallDesc("sched_getscheduler", unimplementedFunc),
286    /* 162 */ SyscallDesc("sched_yield", unimplementedFunc),
287    /* 163 */ SyscallDesc("sched_get_prioritymax", unimplementedFunc),
288    /* 164 */ SyscallDesc("sched_get_priority_min", unimplementedFunc),
289    /* 165 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc),
290    /* 166 */ SyscallDesc("nanosleep", unimplementedFunc),
291    /* 167 */ SyscallDesc("mremap", mremapFunc<MipsLinux>),
292    /* 168 */ SyscallDesc("accept", unimplementedFunc),
293    /* 169 */ SyscallDesc("bind", unimplementedFunc),
294    /* 170 */ SyscallDesc("connect", unimplementedFunc),
295    /* 171 */ SyscallDesc("getpeername", unimplementedFunc),
296    /* 172 */ SyscallDesc("getsockname", unimplementedFunc),
297    /* 173 */ SyscallDesc("getsockopt", unimplementedFunc),
298    /* 174 */ SyscallDesc("listen", unimplementedFunc),
299    /* 175 */ SyscallDesc("recv", unimplementedFunc),
300    /* 176 */ SyscallDesc("recvmsg", unimplementedFunc),
301    /* 177 */ SyscallDesc("send", unimplementedFunc),
302    /* 178 */ SyscallDesc("sendmsg", ignoreFunc),
303    /* 179 */ SyscallDesc("sendto", unimplementedFunc),
304    /* 180 */ SyscallDesc("setsockopt", unimplementedFunc),
305    /* 181 */ SyscallDesc("shutdown", unimplementedFunc),
306    /* 182 */ SyscallDesc("unknown #182", unimplementedFunc),
307    /* 183 */ SyscallDesc("socket", ignoreFunc),
308    /* 184 */ SyscallDesc("socketpair", unimplementedFunc),
309    /* 185 */ SyscallDesc("setresuid", unimplementedFunc),
310    /* 186 */ SyscallDesc("getresuid", unimplementedFunc),
311    /* 187 */ SyscallDesc("query_module", unimplementedFunc),
312    /* 188 */ SyscallDesc("poll", unimplementedFunc),
313    /* 189 */ SyscallDesc("nfsservctl", unimplementedFunc),
314    /* 190 */ SyscallDesc("setresgid", unimplementedFunc),
315    /* 191 */ SyscallDesc("getresgid", unimplementedFunc),
316    /* 192 */ SyscallDesc("prctl", unimplementedFunc),
317    /* 193 */ SyscallDesc("rt_sigreturn", unimplementedFunc),
318    /* 194 */ SyscallDesc("rt_sigaction", unimplementedFunc/*rt_sigactionFunc<MipsLinux>*/),
319    /* 195 */ SyscallDesc("rt_sigprocmask", unimplementedFunc/*rt_sigprocmaskFunc<MipsLinux>*/),
320    /* 196 */ SyscallDesc("rt_sigpending", unimplementedFunc),
321    /* 197 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc),
322    /* 198 */ SyscallDesc("rt_sigqueueinfo", ignoreFunc),
323    /* 199 */ SyscallDesc("rt_sigsuspend", unimplementedFunc/*rt_sigsuspendFunc<MipsLinux>*/),
324    /* 200 */ SyscallDesc("pread64", unimplementedFunc),
325    /* 201 */ SyscallDesc("pwrite64", unimplementedFunc),
326    /* 202 */ SyscallDesc("chown", unimplementedFunc),
327    /* 203 */ SyscallDesc("getcwd", getcwdFunc),
328    /* 204 */ SyscallDesc("capget", unimplementedFunc),
329    /* 205 */ SyscallDesc("capset", unimplementedFunc),
330    /* 206 */ SyscallDesc("sigalstack", unimplementedFunc),
331    /* 207 */ SyscallDesc("sendfile", unimplementedFunc),
332    /* 208 */ SyscallDesc("getpmsg", unimplementedFunc),
333    /* 209 */ SyscallDesc("putpmsg", unimplementedFunc),
334    /* 210 */ SyscallDesc("mmap2", unimplementedFunc),
335    /* 211 */ SyscallDesc("truncate64", unimplementedFunc),
336    /* 212 */ SyscallDesc("ftruncate64", unimplementedFunc),
337    /* 213 */ SyscallDesc("stat64", unimplementedFunc),
338    /* 214 */ SyscallDesc("lstat64", lstat64Func<MipsLinux>),
339    /* 215 */ SyscallDesc("fstat64", fstat64Func<MipsLinux>),
340    /* 216 */ SyscallDesc("pivot_root", unimplementedFunc),
341    /* 217 */ SyscallDesc("mincore", unimplementedFunc),
342    /* 218 */ SyscallDesc("madvise", unimplementedFunc),
343    /* 219 */ SyscallDesc("getdents64", unimplementedFunc),
344    /* 220 */ SyscallDesc("fcntl64", fcntl64Func),
345    /* 221 */ SyscallDesc("reserved#221", unimplementedFunc),
346    /* 222 */ SyscallDesc("gettid", unimplementedFunc),
347    /* 223 */ SyscallDesc("readahead", unimplementedFunc),
348    /* 224 */ SyscallDesc("setxattr", unimplementedFunc),
349    /* 225 */ SyscallDesc("lsetxattr", unimplementedFunc),
350    /* 226 */ SyscallDesc("fsetxattr", unimplementedFunc),
351    /* 227 */ SyscallDesc("getxattr", unimplementedFunc),
352    /* 228 */ SyscallDesc("lgetxattr", unimplementedFunc),
353    /* 229 */ SyscallDesc("fgetxattr", unimplementedFunc),
354    /* 230 */ SyscallDesc("listxattr", unimplementedFunc),
355    /* 231 */ SyscallDesc("llistxattr", unimplementedFunc),
356    /* 232 */ SyscallDesc("flistxattr", unimplementedFunc),
357    /* 233 */ SyscallDesc("removexattr", unimplementedFunc),
358    /* 234 */ SyscallDesc("lremovexattr", unimplementedFunc),
359    /* 235 */ SyscallDesc("fremovexattr", ignoreFunc),
360    /* 236 */ SyscallDesc("tkill", unimplementedFunc),
361    /* 237 */ SyscallDesc("sendfile64", unimplementedFunc),
362    /* 238 */ SyscallDesc("futex", unimplementedFunc),
363    /* 239 */ SyscallDesc("sched_setaffinity", unimplementedFunc),
364    /* 240 */ SyscallDesc("sched_getaffinity", unimplementedFunc),
365    /* 241 */ SyscallDesc("io_setup", unimplementedFunc),
366    /* 242 */ SyscallDesc("io_destroy", unimplementedFunc),
367    /* 243 */ SyscallDesc("io_getevents", unimplementedFunc),
368    /* 244 */ SyscallDesc("io_submit", unimplementedFunc),
369    /* 245 */ SyscallDesc("io_cancel", unimplementedFunc),
370    /* 246 */ SyscallDesc("exit_group", exitFunc),
371    /* 247 */ SyscallDesc("lookup_dcookie", unimplementedFunc),
372    /* 248 */ SyscallDesc("epoll_create", unimplementedFunc),
373    /* 249 */ SyscallDesc("epoll_ctl", unimplementedFunc),
374    /* 250 */ SyscallDesc("epoll_wait", unimplementedFunc),
375    /* 251 */ SyscallDesc("remap_file_pages", unimplementedFunc),
376    /* 252 */ SyscallDesc("set_tid_address", unimplementedFunc),
377    /* 253 */ SyscallDesc("restart_syscall", unimplementedFunc),
378    /* 254 */ SyscallDesc("fadvise64", unimplementedFunc),
379    /* 255 */ SyscallDesc("statfs64", unimplementedFunc),
380    /* 256 */ SyscallDesc("fstafs64", unimplementedFunc),
381    /* 257 */ SyscallDesc("timer_create", sys_getsysinfoFunc),
382    /* 258 */ SyscallDesc("timer_settime", sys_setsysinfoFunc),
383    /* 259 */ SyscallDesc("timer_gettime", unimplementedFunc),
384    /* 260 */ SyscallDesc("timer_getoverrun", unimplementedFunc),
385    /* 261 */ SyscallDesc("timer_delete", unimplementedFunc),
386    /* 262 */ SyscallDesc("clock_settime", unimplementedFunc),
387    /* 263 */ SyscallDesc("clock_gettime", unimplementedFunc),
388    /* 264 */ SyscallDesc("clock_getres", unimplementedFunc),
389    /* 265 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
390    /* 266 */ SyscallDesc("tgkill", unimplementedFunc),
391    /* 267 */ SyscallDesc("utimes", unimplementedFunc),
392    /* 268 */ SyscallDesc("mbind", unimplementedFunc),
393    /* 269 */ SyscallDesc("get_mempolicy", unimplementedFunc),
394    /* 270 */ SyscallDesc("set_mempolicy", unimplementedFunc),
395    /* 271 */ SyscallDesc("mq_open", unimplementedFunc),
396    /* 272 */ SyscallDesc("mq_unlink", unimplementedFunc),
397    /* 273 */ SyscallDesc("mq_timedsend", unimplementedFunc),
398    /* 274 */ SyscallDesc("mq_timedreceive", unimplementedFunc),
399    /* 275 */ SyscallDesc("mq_notify", unimplementedFunc),
400    /* 276 */ SyscallDesc("mq_getsetattr", unimplementedFunc),
401    /* 277 */ SyscallDesc("vserver", unimplementedFunc),
402    /* 278 */ SyscallDesc("waitid", unimplementedFunc),
403    /* 279 */ SyscallDesc("unknown #279", unimplementedFunc),
404    /* 280 */ SyscallDesc("add_key", unimplementedFunc),
405    /* 281 */ SyscallDesc("request_key", unimplementedFunc),
406    /* 282 */ SyscallDesc("keyctl", unimplementedFunc)
407};
408
409
410MipsLinuxProcess::MipsLinuxProcess(LiveProcessParams * params,
411                                     ObjectFile *objFile)
412    : MipsLiveProcess(params, objFile),
413     Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
414{  }
415
416void
417MipsLinuxProcess::startup()
418{
419    MipsLiveProcess::argsInit(MachineBytes, VMPageSize);
420}
421
422SyscallDesc*
423MipsLinuxProcess::getDesc(int callnum)
424{
425    //MIPS32 syscalls are in the range of 4000 - 4999
426    int m5_sys_idx = callnum - 4000;
427
428    if (m5_sys_idx < 0 || m5_sys_idx > Num_Syscall_Descs)
429        return NULL;
430
431    return &syscallDescs[m5_sys_idx];
432}
433
434
435
436
437
438