summaryrefslogtreecommitdiff
path: root/src/arch/x86/linux
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/linux')
-rw-r--r--src/arch/x86/linux/linux.cc39
-rw-r--r--src/arch/x86/linux/linux.hh81
-rw-r--r--src/arch/x86/linux/process.cc30
-rw-r--r--src/arch/x86/linux/process.hh22
-rw-r--r--src/arch/x86/linux/syscalls.cc444
-rw-r--r--src/arch/x86/linux/system.cc61
-rw-r--r--src/arch/x86/linux/system.hh4
7 files changed, 567 insertions, 114 deletions
diff --git a/src/arch/x86/linux/linux.cc b/src/arch/x86/linux/linux.cc
index 5e8d2de16..41855da59 100644
--- a/src/arch/x86/linux/linux.cc
+++ b/src/arch/x86/linux/linux.cc
@@ -97,3 +97,42 @@ const int X86Linux64::NUM_OPEN_FLAGS =
sizeof(X86Linux64::openFlagTable) /
sizeof(X86Linux64::openFlagTable[0]);
+// open(2) flags translation table
+OpenFlagTransTable X86Linux32::openFlagTable[] = {
+#ifdef _MSC_VER
+ { TGT_O_RDONLY, _O_RDONLY },
+ { TGT_O_WRONLY, _O_WRONLY },
+ { TGT_O_RDWR, _O_RDWR },
+ { TGT_O_APPEND, _O_APPEND },
+ { TGT_O_CREAT, _O_CREAT },
+ { TGT_O_TRUNC, _O_TRUNC },
+ { TGT_O_EXCL, _O_EXCL },
+#ifdef _O_NONBLOCK
+ { TGT_O_NONBLOCK, _O_NONBLOCK },
+#endif
+#ifdef _O_NOCTTY
+ { TGT_O_NOCTTY, _O_NOCTTY },
+#endif
+#ifdef _O_SYNC
+ { TGT_O_SYNC, _O_SYNC },
+#endif
+#else /* !_MSC_VER */
+ { TGT_O_RDONLY, O_RDONLY },
+ { TGT_O_WRONLY, O_WRONLY },
+ { TGT_O_RDWR, O_RDWR },
+ { TGT_O_APPEND, O_APPEND },
+ { TGT_O_CREAT, O_CREAT },
+ { TGT_O_TRUNC, O_TRUNC },
+ { TGT_O_EXCL, O_EXCL },
+ { TGT_O_NONBLOCK, O_NONBLOCK },
+ { TGT_O_NOCTTY, O_NOCTTY },
+#ifdef O_SYNC
+ { TGT_O_SYNC, O_SYNC },
+#endif
+#endif /* _MSC_VER */
+};
+
+const int X86Linux32::NUM_OPEN_FLAGS =
+ sizeof(X86Linux32::openFlagTable) /
+ sizeof(X86Linux32::openFlagTable[0]);
+
diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh
index 8a78d5320..c2941c769 100644
--- a/src/arch/x86/linux/linux.hh
+++ b/src/arch/x86/linux/linux.hh
@@ -82,26 +82,26 @@ class X86Linux64 : public Linux
uint64_t st_mtime_nsec;
uint64_t st_ctimeX;
uint64_t st_ctime_nsec;
- int64_t __unused[3];
+ int64_t unused0[3];
} tgt_stat64;
static OpenFlagTransTable openFlagTable[];
- static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
- static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
- static const int TGT_O_RDWR = 00000002; //!< O_RDWR
- static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
- static const int TGT_O_APPEND = 00002000; //!< O_APPEND
- static const int TGT_O_CREAT = 00000100; //!< O_CREAT
- static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
- static const int TGT_O_EXCL = 00000200; //!< O_EXCL
- static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
- static const int TGT_O_SYNC = 00010000; //!< O_SYNC
-// static const int TGT_O_DRD = 0x00010000; //!< O_DRD
-// static const int TGT_O_DIRECTIO = 0x00020000; //!< O_DIRECTIO
-// static const int TGT_O_CACHE = 0x00002000; //!< O_CACHE
-// static const int TGT_O_DSYNC = 0x00008000; //!< O_DSYNC
-// static const int TGT_O_RSYNC = 0x00040000; //!< O_RSYNC
+ static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
+ static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
+ static const int TGT_O_RDWR = 00000002; //!< O_RDWR
+ static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
+ static const int TGT_O_APPEND = 00002000; //!< O_APPEND
+ static const int TGT_O_CREAT = 00000100; //!< O_CREAT
+ static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
+ static const int TGT_O_EXCL = 00000200; //!< O_EXCL
+ static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
+ static const int TGT_O_SYNC = 00010000; //!< O_SYNC
+// static const int TGT_O_DRD = 0x00010000; //!< O_DRD
+// static const int TGT_O_DIRECTIO = 0x00020000; //!< O_DIRECTIO
+// static const int TGT_O_CACHE = 0x00002000; //!< O_CACHE
+// static const int TGT_O_DSYNC = 0x00008000; //!< O_DSYNC
+// static const int TGT_O_RSYNC = 0x00040000; //!< O_RSYNC
static const int NUM_OPEN_FLAGS;
@@ -113,4 +113,53 @@ class X86Linux64 : public Linux
} tgt_iovec;
};
+class X86Linux32 : public Linux
+{
+ public:
+
+ typedef struct {
+ uint64_t st_dev;
+ uint8_t __pad0[4];
+ uint32_t __st_ino;
+ uint32_t st_mode;
+ uint32_t st_nlink;
+ uint32_t st_uid;
+ uint32_t st_gid;
+ uint64_t st_rdev;
+ int64_t st_size;
+ uint8_t __pad3[4];
+ uint32_t st_blksize;
+ uint64_t st_blocks;
+ uint32_t st_atimeX;
+ uint32_t st_atime_nsec;
+ uint32_t st_mtimeX;
+ uint32_t st_mtime_nsec;
+ uint32_t st_ctimeX;
+ uint32_t st_ctime_nsec;
+ uint64_t st_ino;
+ } tgt_stat64;
+
+ static OpenFlagTransTable openFlagTable[];
+
+ static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
+ static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
+ static const int TGT_O_RDWR = 00000002; //!< O_RDWR
+ static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
+ static const int TGT_O_APPEND = 00002000; //!< O_APPEND
+ static const int TGT_O_CREAT = 00000100; //!< O_CREAT
+ static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
+ static const int TGT_O_EXCL = 00000200; //!< O_EXCL
+ static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
+ static const int TGT_O_SYNC = 00010000; //!< O_SYNC
+// static const int TGT_O_DRD = 0x00010000; //!< O_DRD
+// static const int TGT_O_DIRECTIO = 0x00020000; //!< O_DIRECTIO
+// static const int TGT_O_CACHE = 0x00002000; //!< O_CACHE
+// static const int TGT_O_DSYNC = 0x00008000; //!< O_DSYNC
+// static const int TGT_O_RSYNC = 0x00040000; //!< O_RSYNC
+
+ static const int NUM_OPEN_FLAGS;
+
+ static const unsigned TGT_MAP_ANONYMOUS = 0x20;
+};
+
#endif
diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc
index 8beaf150b..da22d9851 100644
--- a/src/arch/x86/linux/process.cc
+++ b/src/arch/x86/linux/process.cc
@@ -64,34 +64,16 @@
#include "kern/linux/linux.hh"
#include "sim/process.hh"
-#include "sim/syscall_emul.hh"
using namespace std;
using namespace X86ISA;
-SyscallDesc*
-X86LinuxProcess::getDesc(int callnum)
-{
- if (callnum < 0 || callnum > Num_Syscall_Descs)
- return NULL;
- return &syscallDescs[callnum];
-}
-
-X86LinuxProcess::X86LinuxProcess(LiveProcessParams * params,
+X86_64LinuxProcess::X86_64LinuxProcess(LiveProcessParams * params,
ObjectFile *objFile)
- : X86LiveProcess(params, objFile),
- Num_Syscall_Descs(273)
+ : X86_64LiveProcess(params, objFile, syscallDescs, 273)
{}
-void X86LinuxProcess::handleTrap(int trapNum, ThreadContext *tc)
-{
- switch(trapNum)
- {
- //This implementation is from SPARC
- case 0x10: //Linux 32 bit syscall trap
- tc->syscall(tc->readIntReg(1));
- break;
- default:
- X86LiveProcess::handleTrap(trapNum, tc);
- }
-}
+I386LinuxProcess::I386LinuxProcess(LiveProcessParams * params,
+ ObjectFile *objFile)
+ : I386LiveProcess(params, objFile, syscallDescs, 324)
+{}
diff --git a/src/arch/x86/linux/process.hh b/src/arch/x86/linux/process.hh
index e224374d4..ca3606ef0 100644
--- a/src/arch/x86/linux/process.hh
+++ b/src/arch/x86/linux/process.hh
@@ -60,26 +60,30 @@
#include "sim/process.hh"
#include "arch/x86/linux/linux.hh"
-#include "arch/x86/syscallreturn.hh"
#include "arch/x86/process.hh"
namespace X86ISA {
-/// A process with emulated x86/Linux syscalls.
-class X86LinuxProcess : public X86LiveProcess
+class X86_64LinuxProcess : public X86_64LiveProcess
{
+ protected:
+ /// Array of syscall descriptors, indexed by call number.
+ static SyscallDesc syscallDescs[];
+
public:
/// Constructor.
- X86LinuxProcess(LiveProcessParams * params, ObjectFile *objFile);
+ X86_64LinuxProcess(LiveProcessParams * params, ObjectFile *objFile);
+};
+class I386LinuxProcess : public I386LiveProcess
+{
+ protected:
/// Array of syscall descriptors, indexed by call number.
static SyscallDesc syscallDescs[];
- SyscallDesc* getDesc(int callnum);
-
- const int Num_Syscall_Descs;
-
- void handleTrap(int trapNum, ThreadContext *tc);
+ public:
+ /// Constructor.
+ I386LinuxProcess(LiveProcessParams * params, ObjectFile *objFile);
};
} // namespace X86ISA
diff --git a/src/arch/x86/linux/syscalls.cc b/src/arch/x86/linux/syscalls.cc
index ae2ac243b..09235ec94 100644
--- a/src/arch/x86/linux/syscalls.cc
+++ b/src/arch/x86/linux/syscalls.cc
@@ -68,7 +68,7 @@ static SyscallReturn
unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- TypedBufferArg<Linux::utsname> name(tc->getSyscallArg(0));
+ TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
strcpy(name->sysname, "Linux");
strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -94,8 +94,8 @@ archPrctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
};
//First argument is the code, second is the address
- int code = tc->getSyscallArg(0);
- uint64_t addr = tc->getSyscallArg(1);
+ int code = process->getSyscallArg(tc, 0);
+ uint64_t addr = process->getSyscallArg(tc, 1);
uint64_t fsBase, gsBase;
TranslatingPort *p = tc->getMemPort();
switch(code)
@@ -122,7 +122,112 @@ archPrctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
}
}
-SyscallDesc X86LinuxProcess::syscallDescs[] = {
+BitUnion32(UserDescFlags)
+ Bitfield<0> seg_32bit;
+ Bitfield<2, 1> contents;
+ Bitfield<3> read_exec_only;
+ Bitfield<4> limit_in_pages;
+ Bitfield<5> seg_not_present;
+ Bitfield<6> useable;
+EndBitUnion(UserDescFlags)
+
+struct UserDesc32 {
+ uint32_t entry_number;
+ uint32_t base_addr;
+ uint32_t limit;
+ uint32_t flags;
+};
+
+struct UserDesc64 {
+ uint32_t entry_number;
+ uint32_t __padding1;
+ uint64_t base_addr;
+ uint32_t limit;
+ uint32_t flags;
+};
+
+static SyscallReturn
+setThreadArea32Func(SyscallDesc *desc, int callnum,
+ LiveProcess *process, ThreadContext *tc)
+{
+ const int minTLSEntry = 6;
+ const int numTLSEntries = 3;
+ const int maxTLSEntry = minTLSEntry + numTLSEntries - 1;
+
+ X86LiveProcess *x86lp = dynamic_cast<X86LiveProcess *>(process);
+ assert(x86lp);
+
+ assert((maxTLSEntry + 1) * sizeof(uint64_t) <= x86lp->gdtSize());
+
+ TypedBufferArg<UserDesc32> userDesc(process->getSyscallArg(tc, 0));
+ TypedBufferArg<uint64_t>
+ gdt(x86lp->gdtStart() + minTLSEntry * sizeof(uint64_t),
+ numTLSEntries * sizeof(uint64_t));
+
+ if (!userDesc.copyIn(tc->getMemPort()))
+ return -EFAULT;
+
+ if (!gdt.copyIn(tc->getMemPort()))
+ panic("Failed to copy in GDT for %s.\n", desc->name);
+
+ if (userDesc->entry_number == (uint32_t)(-1)) {
+ // Find a free TLS entry.
+ for (int i = 0; i < numTLSEntries; i++) {
+ if (gdt[i] == 0) {
+ userDesc->entry_number = i + minTLSEntry;
+ break;
+ }
+ }
+ // We failed to find one.
+ if (userDesc->entry_number == (uint32_t)(-1))
+ return -ESRCH;
+ }
+
+ int index = userDesc->entry_number;
+
+ if (index < minTLSEntry || index > maxTLSEntry)
+ return -EINVAL;
+
+ index -= minTLSEntry;
+
+ // Build the entry we're going to add.
+ SegDescriptor segDesc = 0;
+ UserDescFlags flags = userDesc->flags;
+
+ segDesc.limitLow = bits(userDesc->limit, 15, 0);
+ segDesc.baseLow = bits(userDesc->base_addr, 23, 0);
+ segDesc.type.a = 1;
+ if (!flags.read_exec_only)
+ segDesc.type.w = 1;
+ if (bits((uint8_t)flags.contents, 0))
+ segDesc.type.e = 1;
+ if (bits((uint8_t)flags.contents, 1))
+ segDesc.type.codeOrData = 1;
+ segDesc.s = 1;
+ segDesc.dpl = 3;
+ if (!flags.seg_not_present)
+ segDesc.p = 1;
+ segDesc.limitHigh = bits(userDesc->limit, 19, 16);
+ if (flags.useable)
+ segDesc.avl = 1;
+ segDesc.l = 0;
+ if (flags.seg_32bit)
+ segDesc.d = 1;
+ if (flags.limit_in_pages)
+ segDesc.g = 1;
+ segDesc.baseHigh = bits(userDesc->base_addr, 31, 24);
+
+ gdt[index] = (uint64_t)segDesc;
+
+ if (!userDesc.copyOut(tc->getMemPort()))
+ return -EFAULT;
+ if (!gdt.copyOut(tc->getMemPort()))
+ panic("Failed to copy out GDT for %s.\n", desc->name);
+
+ return 0;
+}
+
+SyscallDesc X86_64LinuxProcess::syscallDescs[] = {
/* 0 */ SyscallDesc("read", readFunc),
/* 1 */ SyscallDesc("write", writeFunc),
/* 2 */ SyscallDesc("open", openFunc<X86Linux64>),
@@ -135,7 +240,7 @@ SyscallDesc X86LinuxProcess::syscallDescs[] = {
/* 9 */ SyscallDesc("mmap", mmapFunc<X86Linux64>),
/* 10 */ SyscallDesc("mprotect", unimplementedFunc),
/* 11 */ SyscallDesc("munmap", munmapFunc),
- /* 12 */ SyscallDesc("brk", obreakFunc),
+ /* 12 */ SyscallDesc("brk", brkFunc),
/* 13 */ SyscallDesc("rt_sigaction", unimplementedFunc),
/* 14 */ SyscallDesc("rt_sigprocmask", unimplementedFunc),
/* 15 */ SyscallDesc("rt_sigreturn", unimplementedFunc),
@@ -148,7 +253,7 @@ SyscallDesc X86LinuxProcess::syscallDescs[] = {
/* 22 */ SyscallDesc("pipe", unimplementedFunc),
/* 23 */ SyscallDesc("select", unimplementedFunc),
/* 24 */ SyscallDesc("sched_yield", unimplementedFunc),
- /* 25 */ SyscallDesc("mremap", unimplementedFunc),
+ /* 25 */ SyscallDesc("mremap", mremapFunc<X86Linux64>),
/* 26 */ SyscallDesc("msync", unimplementedFunc),
/* 27 */ SyscallDesc("mincore", unimplementedFunc),
/* 28 */ SyscallDesc("madvise", unimplementedFunc),
@@ -397,3 +502,330 @@ SyscallDesc X86LinuxProcess::syscallDescs[] = {
/* 271 */ SyscallDesc("ppoll", unimplementedFunc),
/* 272 */ SyscallDesc("unshare", unimplementedFunc)
};
+
+SyscallDesc I386LinuxProcess::syscallDescs[] = {
+ /* 0 */ SyscallDesc("restart_syscall", unimplementedFunc),
+ /* 1 */ SyscallDesc("exit", unimplementedFunc),
+ /* 2 */ SyscallDesc("fork", unimplementedFunc),
+ /* 3 */ SyscallDesc("read", unimplementedFunc),
+ /* 4 */ SyscallDesc("write", writeFunc),
+ /* 5 */ SyscallDesc("open", openFunc<X86Linux64>),
+ /* 6 */ SyscallDesc("close", unimplementedFunc),
+ /* 7 */ SyscallDesc("waitpid", unimplementedFunc),
+ /* 8 */ SyscallDesc("creat", unimplementedFunc),
+ /* 9 */ SyscallDesc("link", unimplementedFunc),
+ /* 10 */ SyscallDesc("unlink", unimplementedFunc),
+ /* 11 */ SyscallDesc("execve", unimplementedFunc),
+ /* 12 */ SyscallDesc("chdir", unimplementedFunc),
+ /* 13 */ SyscallDesc("time", unimplementedFunc),
+ /* 14 */ SyscallDesc("mknod", unimplementedFunc),
+ /* 15 */ SyscallDesc("chmod", unimplementedFunc),
+ /* 16 */ SyscallDesc("lchown", unimplementedFunc),
+ /* 17 */ SyscallDesc("break", unimplementedFunc),
+ /* 18 */ SyscallDesc("oldstat", unimplementedFunc),
+ /* 19 */ SyscallDesc("lseek", unimplementedFunc),
+ /* 20 */ SyscallDesc("getpid", unimplementedFunc),
+ /* 21 */ SyscallDesc("mount", unimplementedFunc),
+ /* 22 */ SyscallDesc("umount", unimplementedFunc),
+ /* 23 */ SyscallDesc("setuid", unimplementedFunc),
+ /* 24 */ SyscallDesc("getuid", unimplementedFunc),
+ /* 25 */ SyscallDesc("stime", unimplementedFunc),
+ /* 26 */ SyscallDesc("ptrace", unimplementedFunc),
+ /* 27 */ SyscallDesc("alarm", unimplementedFunc),
+ /* 28 */ SyscallDesc("oldfstat", unimplementedFunc),
+ /* 29 */ SyscallDesc("pause", unimplementedFunc),
+ /* 30 */ SyscallDesc("utime", unimplementedFunc),
+ /* 31 */ SyscallDesc("stty", unimplementedFunc),
+ /* 32 */ SyscallDesc("gtty", unimplementedFunc),
+ /* 33 */ SyscallDesc("access", unimplementedFunc),
+ /* 34 */ SyscallDesc("nice", unimplementedFunc),
+ /* 35 */ SyscallDesc("ftime", unimplementedFunc),
+ /* 36 */ SyscallDesc("sync", unimplementedFunc),
+ /* 37 */ SyscallDesc("kill", unimplementedFunc),
+ /* 38 */ SyscallDesc("rename", unimplementedFunc),
+ /* 39 */ SyscallDesc("mkdir", unimplementedFunc),
+ /* 40 */ SyscallDesc("rmdir", unimplementedFunc),
+ /* 41 */ SyscallDesc("dup", unimplementedFunc),
+ /* 42 */ SyscallDesc("pipe", unimplementedFunc),
+ /* 43 */ SyscallDesc("times", unimplementedFunc),
+ /* 44 */ SyscallDesc("prof", unimplementedFunc),
+ /* 45 */ SyscallDesc("brk", brkFunc),
+ /* 46 */ SyscallDesc("setgid", unimplementedFunc),
+ /* 47 */ SyscallDesc("getgid", unimplementedFunc),
+ /* 48 */ SyscallDesc("signal", unimplementedFunc),
+ /* 49 */ SyscallDesc("geteuid", unimplementedFunc),
+ /* 50 */ SyscallDesc("getegid", unimplementedFunc),
+ /* 51 */ SyscallDesc("acct", unimplementedFunc),
+ /* 52 */ SyscallDesc("umount2", unimplementedFunc),
+ /* 53 */ SyscallDesc("lock", unimplementedFunc),
+ /* 54 */ SyscallDesc("ioctl", unimplementedFunc),
+ /* 55 */ SyscallDesc("fcntl", unimplementedFunc),
+ /* 56 */ SyscallDesc("mpx", unimplementedFunc),
+ /* 57 */ SyscallDesc("setpgid", unimplementedFunc),
+ /* 58 */ SyscallDesc("ulimit", unimplementedFunc),
+ /* 59 */ SyscallDesc("oldolduname", unimplementedFunc),
+ /* 60 */ SyscallDesc("umask", unimplementedFunc),
+ /* 61 */ SyscallDesc("chroot", unimplementedFunc),
+ /* 62 */ SyscallDesc("ustat", unimplementedFunc),
+ /* 63 */ SyscallDesc("dup2", unimplementedFunc),
+ /* 64 */ SyscallDesc("getppid", unimplementedFunc),
+ /* 65 */ SyscallDesc("getpgrp", unimplementedFunc),
+ /* 66 */ SyscallDesc("setsid", unimplementedFunc),
+ /* 67 */ SyscallDesc("sigaction", unimplementedFunc),
+ /* 68 */ SyscallDesc("sgetmask", unimplementedFunc),
+ /* 69 */ SyscallDesc("ssetmask", unimplementedFunc),
+ /* 70 */ SyscallDesc("setreuid", unimplementedFunc),
+ /* 71 */ SyscallDesc("setregid", unimplementedFunc),
+ /* 72 */ SyscallDesc("sigsuspend", unimplementedFunc),
+ /* 73 */ SyscallDesc("sigpending", unimplementedFunc),
+ /* 74 */ SyscallDesc("sethostname", unimplementedFunc),
+ /* 75 */ SyscallDesc("setrlimit", unimplementedFunc),
+ /* 76 */ SyscallDesc("getrlimit", unimplementedFunc),
+ /* 77 */ SyscallDesc("getrusage", unimplementedFunc),
+ /* 78 */ SyscallDesc("gettimeofday", unimplementedFunc),
+ /* 79 */ SyscallDesc("settimeofday", unimplementedFunc),
+ /* 80 */ SyscallDesc("getgroups", unimplementedFunc),
+ /* 81 */ SyscallDesc("setgroups", unimplementedFunc),
+ /* 82 */ SyscallDesc("select", unimplementedFunc),
+ /* 83 */ SyscallDesc("symlink", unimplementedFunc),
+ /* 84 */ SyscallDesc("oldlstat", unimplementedFunc),
+ /* 85 */ SyscallDesc("readlink", unimplementedFunc),
+ /* 86 */ SyscallDesc("uselib", unimplementedFunc),
+ /* 87 */ SyscallDesc("swapon", unimplementedFunc),
+ /* 88 */ SyscallDesc("reboot", unimplementedFunc),
+ /* 89 */ SyscallDesc("readdir", unimplementedFunc),
+ /* 90 */ SyscallDesc("mmap", unimplementedFunc),
+ /* 91 */ SyscallDesc("munmap", unimplementedFunc),
+ /* 92 */ SyscallDesc("truncate", unimplementedFunc),
+ /* 93 */ SyscallDesc("ftruncate", unimplementedFunc),
+ /* 94 */ SyscallDesc("fchmod", unimplementedFunc),
+ /* 95 */ SyscallDesc("fchown", unimplementedFunc),
+ /* 96 */ SyscallDesc("getpriority", unimplementedFunc),
+ /* 97 */ SyscallDesc("setpriority", unimplementedFunc),
+ /* 98 */ SyscallDesc("profil", unimplementedFunc),
+ /* 99 */ SyscallDesc("statfs", unimplementedFunc),
+ /* 100 */ SyscallDesc("fstatfs", unimplementedFunc),
+ /* 101 */ SyscallDesc("ioperm", unimplementedFunc),
+ /* 102 */ SyscallDesc("socketcall", unimplementedFunc),
+ /* 103 */ SyscallDesc("syslog", unimplementedFunc),
+ /* 104 */ SyscallDesc("setitimer", unimplementedFunc),
+ /* 105 */ SyscallDesc("getitimer", unimplementedFunc),
+ /* 106 */ SyscallDesc("stat", unimplementedFunc),
+ /* 107 */ SyscallDesc("lstat", unimplementedFunc),
+ /* 108 */ SyscallDesc("fstat", unimplementedFunc),
+ /* 109 */ SyscallDesc("olduname", unimplementedFunc),
+ /* 110 */ SyscallDesc("iopl", unimplementedFunc),
+ /* 111 */ SyscallDesc("vhangup", unimplementedFunc),
+ /* 112 */ SyscallDesc("idle", unimplementedFunc),
+ /* 113 */ SyscallDesc("vm86old", unimplementedFunc),
+ /* 114 */ SyscallDesc("wait4", unimplementedFunc),
+ /* 115 */ SyscallDesc("swapoff", unimplementedFunc),
+ /* 116 */ SyscallDesc("sysinfo", unimplementedFunc),
+ /* 117 */ SyscallDesc("ipc", unimplementedFunc),
+ /* 118 */ SyscallDesc("fsync", unimplementedFunc),
+ /* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
+ /* 120 */ SyscallDesc("clone", unimplementedFunc),
+ /* 121 */ SyscallDesc("setdomainname", unimplementedFunc),
+ /* 122 */ SyscallDesc("uname", unameFunc),
+ /* 123 */ SyscallDesc("modify_ldt", unimplementedFunc),
+ /* 124 */ SyscallDesc("adjtimex", unimplementedFunc),
+ /* 125 */ SyscallDesc("mprotect", unimplementedFunc),
+ /* 126 */ SyscallDesc("sigprocmask", unimplementedFunc),
+ /* 127 */ SyscallDesc("create_module", unimplementedFunc),
+ /* 128 */ SyscallDesc("init_module", unimplementedFunc),
+ /* 129 */ SyscallDesc("delete_module", unimplementedFunc),
+ /* 130 */ SyscallDesc("get_kernel_syms", unimplementedFunc),
+ /* 131 */ SyscallDesc("quotactl", unimplementedFunc),
+ /* 132 */ SyscallDesc("getpgid", unimplementedFunc),
+ /* 133 */ SyscallDesc("fchdir", unimplementedFunc),
+ /* 134 */ SyscallDesc("bdflush", unimplementedFunc),
+ /* 135 */ SyscallDesc("sysfs", unimplementedFunc),
+ /* 136 */ SyscallDesc("personality", unimplementedFunc),
+ /* 137 */ SyscallDesc("afs_syscall", unimplementedFunc),
+ /* 138 */ SyscallDesc("setfsuid", unimplementedFunc),
+ /* 139 */ SyscallDesc("setfsgid", unimplementedFunc),
+ /* 140 */ SyscallDesc("_llseek", unimplementedFunc),
+ /* 141 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 142 */ SyscallDesc("_newselect", unimplementedFunc),
+ /* 143 */ SyscallDesc("flock", unimplementedFunc),
+ /* 144 */ SyscallDesc("msync", unimplementedFunc),
+ /* 145 */ SyscallDesc("readv", unimplementedFunc),
+ /* 146 */ SyscallDesc("writev", writevFunc<X86Linux32>),
+ /* 147 */ SyscallDesc("getsid", unimplementedFunc),
+ /* 148 */ SyscallDesc("fdatasync", unimplementedFunc),
+ /* 149 */ SyscallDesc("_sysctl", unimplementedFunc),
+ /* 150 */ SyscallDesc("mlock", unimplementedFunc),
+ /* 151 */ SyscallDesc("munlock", unimplementedFunc),
+ /* 152 */ SyscallDesc("mlockall", unimplementedFunc),
+ /* 153 */ SyscallDesc("munlockall", unimplementedFunc),
+ /* 154 */ SyscallDesc("sched_setparam", unimplementedFunc),
+ /* 155 */ SyscallDesc("sched_getparam", unimplementedFunc),
+ /* 156 */ SyscallDesc("sched_setscheduler", unimplementedFunc),
+ /* 157 */ SyscallDesc("sched_getscheduler", unimplementedFunc),
+ /* 158 */ SyscallDesc("sched_yield", unimplementedFunc),
+ /* 159 */ SyscallDesc("sched_get_priority_max", unimplementedFunc),
+ /* 160 */ SyscallDesc("sched_get_priority_min", unimplementedFunc),
+ /* 161 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc),
+ /* 162 */ SyscallDesc("nanosleep", unimplementedFunc),
+ /* 163 */ SyscallDesc("mremap", unimplementedFunc),
+ /* 164 */ SyscallDesc("setresuid", unimplementedFunc),
+ /* 165 */ SyscallDesc("getresuid", unimplementedFunc),
+ /* 166 */ SyscallDesc("vm86", unimplementedFunc),
+ /* 167 */ SyscallDesc("query_module", unimplementedFunc),
+ /* 168 */ SyscallDesc("poll", unimplementedFunc),
+ /* 169 */ SyscallDesc("nfsservctl", unimplementedFunc),
+ /* 170 */ SyscallDesc("setresgid", unimplementedFunc),
+ /* 171 */ SyscallDesc("getresgid", unimplementedFunc),
+ /* 172 */ SyscallDesc("prctl", unimplementedFunc),
+ /* 173 */ SyscallDesc("rt_sigreturn", unimplementedFunc),
+ /* 174 */ SyscallDesc("rt_sigaction", unimplementedFunc),
+ /* 175 */ SyscallDesc("rt_sigprocmask", unimplementedFunc),
+ /* 176 */ SyscallDesc("rt_sigpending", unimplementedFunc),
+ /* 177 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc),
+ /* 178 */ SyscallDesc("rt_sigqueueinfo", unimplementedFunc),
+ /* 179 */ SyscallDesc("rt_sigsuspend", unimplementedFunc),
+ /* 180 */ SyscallDesc("pread64", unimplementedFunc),
+ /* 181 */ SyscallDesc("pwrite64", unimplementedFunc),
+ /* 182 */ SyscallDesc("chown", unimplementedFunc),
+ /* 183 */ SyscallDesc("getcwd", unimplementedFunc),
+ /* 184 */ SyscallDesc("capget", unimplementedFunc),
+ /* 185 */ SyscallDesc("capset", unimplementedFunc),
+ /* 186 */ SyscallDesc("sigaltstack", unimplementedFunc),
+ /* 187 */ SyscallDesc("sendfile", unimplementedFunc),
+ /* 188 */ SyscallDesc("getpmsg", unimplementedFunc),
+ /* 189 */ SyscallDesc("putpmsg", unimplementedFunc),
+ /* 190 */ SyscallDesc("vfork", unimplementedFunc),
+ /* 191 */ SyscallDesc("ugetrlimit", unimplementedFunc),
+ /* 192 */ SyscallDesc("mmap2", mmapFunc<X86Linux32>),
+ /* 193 */ SyscallDesc("truncate64", unimplementedFunc),
+ /* 194 */ SyscallDesc("ftruncate64", unimplementedFunc),
+ /* 195 */ SyscallDesc("stat64", unimplementedFunc),
+ /* 196 */ SyscallDesc("lstat64", unimplementedFunc),
+ /* 197 */ SyscallDesc("fstat64", fstat64Func<X86Linux32>),
+ /* 198 */ SyscallDesc("lchown32", unimplementedFunc),
+ /* 199 */ SyscallDesc("getuid32", unimplementedFunc),
+ /* 200 */ SyscallDesc("getgid32", unimplementedFunc),
+ /* 201 */ SyscallDesc("geteuid32", unimplementedFunc),
+ /* 202 */ SyscallDesc("getegid32", unimplementedFunc),
+ /* 203 */ SyscallDesc("setreuid32", unimplementedFunc),
+ /* 204 */ SyscallDesc("setregid32", unimplementedFunc),
+ /* 205 */ SyscallDesc("getgroups32", unimplementedFunc),
+ /* 206 */ SyscallDesc("setgroups32", unimplementedFunc),
+ /* 207 */ SyscallDesc("fchown32", unimplementedFunc),
+ /* 208 */ SyscallDesc("setresuid32", unimplementedFunc),
+ /* 209 */ SyscallDesc("getresuid32", unimplementedFunc),
+ /* 210 */ SyscallDesc("setresgid32", unimplementedFunc),
+ /* 211 */ SyscallDesc("getresgid32", unimplementedFunc),
+ /* 212 */ SyscallDesc("chown32", unimplementedFunc),
+ /* 213 */ SyscallDesc("setuid32", unimplementedFunc),
+ /* 214 */ SyscallDesc("setgid32", unimplementedFunc),
+ /* 215 */ SyscallDesc("setfsuid32", unimplementedFunc),
+ /* 216 */ SyscallDesc("setfsgid32", unimplementedFunc),
+ /* 217 */ SyscallDesc("pivot_root", unimplementedFunc),
+ /* 218 */ SyscallDesc("mincore", unimplementedFunc),
+ /* 219 */ SyscallDesc("madvise", unimplementedFunc),
+ /* 220 */ SyscallDesc("madvise1", unimplementedFunc),
+ /* 221 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 222 */ SyscallDesc("fcntl64", unimplementedFunc),
+ /* 223 */ SyscallDesc("unused", unimplementedFunc),
+ /* 224 */ SyscallDesc("gettid", unimplementedFunc),
+ /* 225 */ SyscallDesc("readahead", unimplementedFunc),
+ /* 226 */ SyscallDesc("setxattr", unimplementedFunc),
+ /* 227 */ SyscallDesc("lsetxattr", unimplementedFunc),
+ /* 228 */ SyscallDesc("fsetxattr", unimplementedFunc),
+ /* 229 */ SyscallDesc("getxattr", unimplementedFunc),
+ /* 230 */ SyscallDesc("lgetxattr", unimplementedFunc),
+ /* 231 */ SyscallDesc("fgetxattr", unimplementedFunc),
+ /* 232 */ SyscallDesc("listxattr", unimplementedFunc),
+ /* 233 */ SyscallDesc("llistxattr", unimplementedFunc),
+ /* 234 */ SyscallDesc("flistxattr", unimplementedFunc),
+ /* 235 */ SyscallDesc("removexattr", unimplementedFunc),
+ /* 236 */ SyscallDesc("lremovexattr", unimplementedFunc),
+ /* 237 */ SyscallDesc("fremovexattr", unimplementedFunc),
+ /* 238 */ SyscallDesc("tkill", unimplementedFunc),
+ /* 239 */ SyscallDesc("sendfile64", unimplementedFunc),
+ /* 240 */ SyscallDesc("futex", unimplementedFunc),
+ /* 241 */ SyscallDesc("sched_setaffinity", unimplementedFunc),
+ /* 242 */ SyscallDesc("sched_getaffinity", unimplementedFunc),
+ /* 243 */ SyscallDesc("set_thread_area", setThreadArea32Func),
+ /* 244 */ SyscallDesc("get_thread_area", unimplementedFunc),
+ /* 245 */ SyscallDesc("io_setup", unimplementedFunc),
+ /* 246 */ SyscallDesc("io_destroy", unimplementedFunc),
+ /* 247 */ SyscallDesc("io_getevents", unimplementedFunc),
+ /* 248 */ SyscallDesc("io_submit", unimplementedFunc),
+ /* 249 */ SyscallDesc("io_cancel", unimplementedFunc),
+ /* 250 */ SyscallDesc("fadvise64", unimplementedFunc),
+ /* 251 */ SyscallDesc("unused", unimplementedFunc),
+ /* 252 */ SyscallDesc("exit_group", exitFunc),
+ /* 253 */ SyscallDesc("lookup_dcookie", unimplementedFunc),
+ /* 254 */ SyscallDesc("epoll_create", unimplementedFunc),
+ /* 255 */ SyscallDesc("epoll_ctl", unimplementedFunc),
+ /* 256 */ SyscallDesc("epoll_wait", unimplementedFunc),
+ /* 257 */ SyscallDesc("remap_file_pages", unimplementedFunc),
+ /* 258 */ SyscallDesc("set_tid_address", unimplementedFunc),
+ /* 259 */ SyscallDesc("timer_create", unimplementedFunc),
+ /* 260 */ SyscallDesc("timer_settime", unimplementedFunc),
+ /* 261 */ SyscallDesc("timer_gettime", unimplementedFunc),
+ /* 262 */ SyscallDesc("timer_getoverrun", unimplementedFunc),
+ /* 263 */ SyscallDesc("timer_delete", unimplementedFunc),
+ /* 264 */ SyscallDesc("clock_settime", unimplementedFunc),
+ /* 265 */ SyscallDesc("clock_gettime", unimplementedFunc),
+ /* 266 */ SyscallDesc("clock_getres", unimplementedFunc),
+ /* 267 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
+ /* 268 */ SyscallDesc("statfs64", unimplementedFunc),
+ /* 269 */ SyscallDesc("fstatfs64", unimplementedFunc),
+ /* 270 */ SyscallDesc("tgkill", unimplementedFunc),
+ /* 271 */ SyscallDesc("utimes", unimplementedFunc),
+ /* 272 */ SyscallDesc("fadvise64_64", unimplementedFunc),
+ /* 273 */ SyscallDesc("vserver", unimplementedFunc),
+ /* 274 */ SyscallDesc("mbind", unimplementedFunc),
+ /* 275 */ SyscallDesc("get_mempolicy", unimplementedFunc),
+ /* 276 */ SyscallDesc("set_mempolicy", unimplementedFunc),
+ /* 277 */ SyscallDesc("mq_open", unimplementedFunc),
+ /* 278 */ SyscallDesc("mq_unlink", unimplementedFunc),
+ /* 279 */ SyscallDesc("mq_timedsend", unimplementedFunc),
+ /* 280 */ SyscallDesc("mq_timedreceive", unimplementedFunc),
+ /* 281 */ SyscallDesc("mq_notify", unimplementedFunc),
+ /* 282 */ SyscallDesc("mq_getsetattr", unimplementedFunc),
+ /* 283 */ SyscallDesc("kexec_load", unimplementedFunc),
+ /* 284 */ SyscallDesc("waitid", unimplementedFunc),
+ /* 285 */ SyscallDesc("sys_setaltroot", unimplementedFunc),
+ /* 286 */ SyscallDesc("add_key", unimplementedFunc),
+ /* 287 */ SyscallDesc("request_key", unimplementedFunc),
+ /* 288 */ SyscallDesc("keyctl", unimplementedFunc),
+ /* 289 */ SyscallDesc("ioprio_set", unimplementedFunc),
+ /* 290 */ SyscallDesc("ioprio_get", unimplementedFunc),
+ /* 291 */ SyscallDesc("inotify_init", unimplementedFunc),
+ /* 292 */ SyscallDesc("inotify_add_watch", unimplementedFunc),
+ /* 293 */ SyscallDesc("inotify_rm_watch", unimplementedFunc),
+ /* 294 */ SyscallDesc("migrate_pages", unimplementedFunc),
+ /* 295 */ SyscallDesc("openat", unimplementedFunc),
+ /* 296 */ SyscallDesc("mkdirat", unimplementedFunc),
+ /* 297 */ SyscallDesc("mknodat", unimplementedFunc),
+ /* 298 */ SyscallDesc("fchownat", unimplementedFunc),
+ /* 299 */ SyscallDesc("futimesat", unimplementedFunc),
+ /* 300 */ SyscallDesc("fstatat64", unimplementedFunc),
+ /* 301 */ SyscallDesc("unlinkat", unimplementedFunc),
+ /* 302 */ SyscallDesc("renameat", unimplementedFunc),
+ /* 303 */ SyscallDesc("linkat", unimplementedFunc),
+ /* 304 */ SyscallDesc("symlinkat", unimplementedFunc),
+ /* 305 */ SyscallDesc("readlinkat", unimplementedFunc),
+ /* 306 */ SyscallDesc("fchmodat", unimplementedFunc),
+ /* 307 */ SyscallDesc("faccessat", unimplementedFunc),
+ /* 308 */ SyscallDesc("pselect6", unimplementedFunc),
+ /* 309 */ SyscallDesc("ppoll", unimplementedFunc),
+ /* 310 */ SyscallDesc("unshare", unimplementedFunc),
+ /* 311 */ SyscallDesc("set_robust_list", unimplementedFunc),
+ /* 312 */ SyscallDesc("get_robust_list", unimplementedFunc),
+ /* 313 */ SyscallDesc("splice", unimplementedFunc),
+ /* 314 */ SyscallDesc("sync_file_range", unimplementedFunc),
+ /* 315 */ SyscallDesc("tee", unimplementedFunc),
+ /* 316 */ SyscallDesc("vmsplice", unimplementedFunc),
+ /* 317 */ SyscallDesc("move_pages", unimplementedFunc),
+ /* 318 */ SyscallDesc("getcpu", unimplementedFunc),
+ /* 319 */ SyscallDesc("epoll_pwait", unimplementedFunc),
+ /* 320 */ SyscallDesc("utimensat", unimplementedFunc),
+ /* 321 */ SyscallDesc("signalfd", unimplementedFunc),
+ /* 322 */ SyscallDesc("timerfd", unimplementedFunc),
+ /* 323 */ SyscallDesc("eventfd", unimplementedFunc)
+};
diff --git a/src/arch/x86/linux/system.cc b/src/arch/x86/linux/system.cc
index 944bb2930..c2d9cb35c 100644
--- a/src/arch/x86/linux/system.cc
+++ b/src/arch/x86/linux/system.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 The Hewlett-Packard Development Company
+ * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
* All rights reserved.
*
* Redistribution and use of this software in source and binary forms,
@@ -68,7 +68,7 @@ using namespace LittleEndianGuest;
using namespace X86ISA;
LinuxX86System::LinuxX86System(Params *p)
- : X86System(p), commandLine(p->boot_osflags)
+ : X86System(p), commandLine(p->boot_osflags), e820Table(p->e820_table)
{
}
@@ -144,62 +144,7 @@ LinuxX86System::startup()
// A pointer to the buffer for E820 entries.
const Addr e820MapPointer = realModeData + 0x2d0;
- struct e820Entry
- {
- Addr addr;
- Addr size;
- uint32_t type;
- };
-
- // The size is computed this way to ensure no padding sneaks in.
- int e820EntrySize =
- sizeof(e820Entry().addr) +
- sizeof(e820Entry().size) +
- sizeof(e820Entry().type);
-
- // I'm not sure what these should actually be. On a real machine they
- // would be generated by the BIOS, and they need to reflect the regions
- // which are actually available/reserved. These values are copied from
- // my development machine.
- e820Entry e820Map[] = {
- {ULL(0x0), ULL(0x9d400), 1},
- {ULL(0x9d400), ULL(0xa0000) - ULL(0x9d400), 2},
- {ULL(0xe8000), ULL(0x100000) - ULL(0xe8000), 2},
- {ULL(0x100000), ULL(0xcfff9300) - ULL(0x100000), 1},
- {ULL(0xcfff9300), ULL(0xd0000000) - ULL(0xcfff9300), 2},
- {ULL(0xfec00000), ULL(0x100000000) - ULL(0xfec00000), 2}
- };
-
- uint8_t e820Nr = sizeof(e820Map) / sizeof(e820Entry);
-
- // Make sure the number of entries isn't bigger than what the kernel
- // would be capable of providing.
- assert(e820Nr <= 128);
-
- uint8_t guestE820Nr = X86ISA::htog(e820Nr);
- physPort->writeBlob(e820MapNrPointer,
- (uint8_t *)&guestE820Nr, sizeof(guestE820Nr));
-
- for (int i = 0; i < e820Nr; i++) {
- e820Entry guestE820Entry;
- guestE820Entry.addr = X86ISA::htog(e820Map[i].addr);
- guestE820Entry.size = X86ISA::htog(e820Map[i].size);
- guestE820Entry.type = X86ISA::htog(e820Map[i].type);
- physPort->writeBlob(e820MapPointer + e820EntrySize * i,
- (uint8_t *)&guestE820Entry.addr,
- sizeof(guestE820Entry.addr));
- physPort->writeBlob(
- e820MapPointer + e820EntrySize * i +
- sizeof(guestE820Entry.addr),
- (uint8_t *)&guestE820Entry.size,
- sizeof(guestE820Entry.size));
- physPort->writeBlob(
- e820MapPointer + e820EntrySize * i +
- sizeof(guestE820Entry.addr) +
- sizeof(guestE820Entry.size),
- (uint8_t *)&guestE820Entry.type,
- sizeof(guestE820Entry.type));
- }
+ e820Table->writeTo(physPort, e820MapNrPointer, e820MapPointer);
/*
* Pass the location of the real mode data structure to the kernel
diff --git a/src/arch/x86/linux/system.hh b/src/arch/x86/linux/system.hh
index fc725ad45..a9c5f4ca9 100644
--- a/src/arch/x86/linux/system.hh
+++ b/src/arch/x86/linux/system.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 The Hewlett-Packard Development Company
+ * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
* All rights reserved.
*
* Redistribution and use of this software in source and binary forms,
@@ -62,12 +62,14 @@
#include <vector>
#include "params/LinuxX86System.hh"
+#include "arch/x86/bios/e820.hh"
#include "arch/x86/system.hh"
class LinuxX86System : public X86System
{
protected:
std::string commandLine;
+ X86ISA::E820Table * e820Table;
public:
typedef LinuxX86SystemParams Params;