summaryrefslogtreecommitdiff
path: root/src/arch/x86/linux
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2016-04-01 16:38:15 -0700
committerSteve Reinhardt <steve.reinhardt@amd.com>2016-04-01 16:38:15 -0700
commit0e214bdfd1dd2e963200875bc8f5ea31e5262503 (patch)
treefb1402ef189c8904cc9f62a65cc9bbcfef26412c /src/arch/x86/linux
parent41c358c411a0a1dd555c9da9b01c3ff39937b367 (diff)
downloadgem5-0e214bdfd1dd2e963200875bc8f5ea31e5262503.tar.xz
syscall_emul: factor out flag tables into common file
The openFlagTable and mmapFlagTables for emulated Linux platforms are basically identical, but are specified repetitively for every platform. Use a common file that gets included for each platform so that we only have one copy, making them more consistent and simplifying changes (like adding #ifdefs). In the process, made some minor fixes that slipped through due to previous inconsistencies, and added more #ifdefs to try to fix building on alternative hosts.
Diffstat (limited to 'src/arch/x86/linux')
-rw-r--r--src/arch/x86/linux/linux.cc198
1 files changed, 7 insertions, 191 deletions
diff --git a/src/arch/x86/linux/linux.cc b/src/arch/x86/linux/linux.cc
index f51bb16e7..a7bf77300 100644
--- a/src/arch/x86/linux/linux.cc
+++ b/src/arch/x86/linux/linux.cc
@@ -42,196 +42,12 @@
#include <fcntl.h>
#include <sys/mman.h>
-// open(2) flags translation table
-SyscallFlagTransTable X86Linux64::openFlagTable[] = {
-#ifdef _MSC_VER
- { X86Linux64::TGT_O_RDONLY, _O_RDONLY },
- { X86Linux64::TGT_O_WRONLY, _O_WRONLY },
- { X86Linux64::TGT_O_RDWR, _O_RDWR },
- { X86Linux64::TGT_O_CREAT, _O_CREAT },
- { X86Linux64::TGT_O_EXCL, _O_EXCL },
-#ifdef _O_NOCTTY
- { X86Linux64::TGT_O_NOCTTY, _O_NOCTTY },
-#endif
- { X86Linux64::TGT_O_TRUNC, _O_TRUNC },
- { X86Linux64::TGT_O_APPEND, _O_APPEND },
-#ifdef _O_NONBLOCK
- { X86Linux64::TGT_O_NONBLOCK, _O_NONBLOCK },
-#endif
-#ifdef _O_DSYNC
- { X86Linux64::TGT_O_DSYNC , _O_DSYNC },
-#endif
- { X86Linux64::TGT_FASYNC, _O_ASYNC },
- { X86Linux64::TGT_O_DIRECT, _O_DIRECT },
- { X86Linux64::TGT_O_LARGEFILE, _O_LARGEFILE },
- { X86Linux64::TGT_O_DIRECTORY, _O_DIRECTORY },
- { X86Linux64::TGT_O_NOFOLLOW, _O_NOFOLLOW },
- { X86Linux64::TGT_O_NOATIME, _O_NOATIME },
-#ifdef _O_CLOEXEC
- { X86Linux64::TGT_O_CLOEXEC, _O_CLOEXEC },
-#endif
-#ifdef _O_SYNC
- { X86Linux64::TGT_O_SYNC, _O_SYNC },
-#endif
-#ifdef _O_PATH
- { X86Linux64::TGT_O_PATH , _O_PATH },
-#endif
-#else /* !_MSC_VER */
- { X86Linux64::TGT_O_RDONLY, O_RDONLY },
- { X86Linux64::TGT_O_WRONLY, O_WRONLY },
- { X86Linux64::TGT_O_RDWR, O_RDWR },
- { X86Linux64::TGT_O_CREAT, O_CREAT },
- { X86Linux64::TGT_O_EXCL, O_EXCL },
- { X86Linux64::TGT_O_NOCTTY, O_NOCTTY },
- { X86Linux64::TGT_O_TRUNC, O_TRUNC },
- { X86Linux64::TGT_O_APPEND, O_APPEND },
- { X86Linux64::TGT_O_NONBLOCK, O_NONBLOCK },
-#ifdef O_DSYNC
- { X86Linux64::TGT_O_DSYNC, O_DSYNC },
-#endif
- { X86Linux64::TGT_FASYNC, O_ASYNC },
- { X86Linux64::TGT_O_DIRECT, O_DIRECT },
- { X86Linux64::TGT_O_LARGEFILE, O_LARGEFILE },
- { X86Linux64::TGT_O_DIRECTORY, O_DIRECTORY },
- { X86Linux64::TGT_O_NOFOLLOW, O_NOFOLLOW },
- { X86Linux64::TGT_O_NOATIME, O_NOATIME },
-#ifdef O_CLOEXEC
- { X86Linux64::TGT_O_CLOEXEC, O_CLOEXEC },
-#endif
-#ifdef O_SYNC
- { X86Linux64::TGT_O_SYNC, O_SYNC },
-#endif
-#ifdef O_PATH
- { X86Linux64::TGT_O_PATH, O_PATH },
-#endif
-#endif /* _MSC_VER */
-};
+// true for both X86Linux32 and X86Linux64
+#define TARGET_HAS_MAP_32BIT
-const int X86Linux64::NUM_OPEN_FLAGS =
- sizeof(X86Linux64::openFlagTable) /
- sizeof(X86Linux64::openFlagTable[0]);
+#define TARGET X86Linux32
+#include "kern/linux/flag_tables.hh"
-// mmap(2) flags translation table
-SyscallFlagTransTable X86Linux64::mmapFlagTable[] = {
- { X86Linux64::TGT_MAP_SHARED, MAP_SHARED },
- { X86Linux64::TGT_MAP_PRIVATE, MAP_PRIVATE },
- { X86Linux64::TGT_MAP_32BIT, MAP_32BIT},
- { X86Linux64::TGT_MAP_ANON, MAP_ANON },
- { X86Linux64::TGT_MAP_DENYWRITE, MAP_DENYWRITE },
- { X86Linux64::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE },
- { X86Linux64::TGT_MAP_FILE, MAP_FILE },
- { X86Linux64::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN },
-#ifdef MAP_HUGETLB
- { X86Linux64::TGT_MAP_HUGETLB, MAP_HUGETLB },
-#endif
- { X86Linux64::TGT_MAP_LOCKED, MAP_LOCKED },
- { X86Linux64::TGT_MAP_NONBLOCK, MAP_NONBLOCK },
- { X86Linux64::TGT_MAP_NORESERVE, MAP_NORESERVE },
- { X86Linux64::TGT_MAP_POPULATE, MAP_POPULATE },
-#ifdef MAP_STACK
- { X86Linux64::TGT_MAP_STACK, MAP_STACK },
-#endif
- { X86Linux64::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS },
- { X86Linux64::TGT_MAP_FIXED, MAP_FIXED },
-};
-
-const unsigned X86Linux64::NUM_MMAP_FLAGS =
- sizeof(X86Linux64::mmapFlagTable) /
- sizeof(X86Linux64::mmapFlagTable[0]);
-
-// open(2) flags translation table
-SyscallFlagTransTable X86Linux32::openFlagTable[] = {
-#ifdef _MSC_VER
- { X86Linux32::TGT_O_RDONLY, _O_RDONLY },
- { X86Linux32::TGT_O_WRONLY, _O_WRONLY },
- { X86Linux32::TGT_O_RDWR, _O_RDWR },
- { X86Linux32::TGT_O_CREAT, _O_CREAT },
- { X86Linux32::TGT_O_EXCL, _O_EXCL },
-#ifdef _O_NOCTTY
- { X86Linux32::TGT_O_NOCTTY, _O_NOCTTY },
-#endif
- { X86Linux32::TGT_O_TRUNC, _O_TRUNC },
- { X86Linux32::TGT_O_APPEND, _O_APPEND },
-#ifdef _O_NONBLOCK
- { X86Linux32::TGT_O_NONBLOCK, _O_NONBLOCK },
-#endif
-#ifdef O_DSYNC
- { X86Linux32::TGT_O_DSYNC, _O_DSYNC },
-#endif
- { X86Linux32::TGT_FASYNC, _O_ASYNC },
- { X86Linux32::TGT_O_DIRECT, _O_DIRECT },
- { X86Linux32::TGT_O_LARGEFILE, _O_LARGEFILE },
- { X86Linux32::TGT_O_DIRECTORY, _O_DIRECTORY },
- { X86Linux32::TGT_O_NOFOLLOW, _O_NOFOLLOW },
- { X86Linux32::TGT_O_NOATIME, _O_NOATIME },
-#ifdef _O_CLOEXEC
- { X86Linux32::TGT_O_CLOEXEC, _O_CLOEXEC },
-#endif
-#ifdef _O_SYNC
- { X86Linux32::TGT_O_SYNC, _O_SYNC },
-#endif
-#ifdef _O_PATH
- { X86Linux32::TGT_O_PATH, _O_PATH },
-#endif
-#else /* !_MSC_VER */
- { X86Linux32::TGT_O_RDONLY, O_RDONLY },
- { X86Linux32::TGT_O_WRONLY, O_WRONLY },
- { X86Linux32::TGT_O_RDWR, O_RDWR },
- { X86Linux32::TGT_O_CREAT, O_CREAT },
- { X86Linux32::TGT_O_EXCL, O_EXCL },
- { X86Linux32::TGT_O_NOCTTY, O_NOCTTY },
- { X86Linux32::TGT_O_TRUNC, O_TRUNC },
- { X86Linux32::TGT_O_APPEND, O_APPEND },
- { X86Linux32::TGT_O_NONBLOCK, O_NONBLOCK },
-#ifdef O_DSYNC
- { X86Linux32::TGT_O_DSYNC, O_DSYNC },
-#endif
- { X86Linux32::TGT_FASYNC, O_ASYNC },
- { X86Linux32::TGT_O_DIRECT, O_DIRECT },
- { X86Linux32::TGT_O_LARGEFILE, O_LARGEFILE },
- { X86Linux32::TGT_O_DIRECTORY, O_DIRECTORY },
- { X86Linux32::TGT_O_NOFOLLOW, O_NOFOLLOW },
- { X86Linux32::TGT_O_NOATIME, O_NOATIME },
-#ifdef O_CLOEXEC
- { X86Linux32::TGT_O_CLOEXEC, O_CLOEXEC },
-#endif
-#ifdef O_SYNC
- { X86Linux32::TGT_O_SYNC, O_SYNC },
-#endif
-#ifdef O_PATH
- { X86Linux32::TGT_O_PATH, O_PATH },
-#endif
-#endif /* _MSC_VER */
-};
-
-const int X86Linux32::NUM_OPEN_FLAGS =
- sizeof(X86Linux32::openFlagTable) /
- sizeof(X86Linux32::openFlagTable[0]);
-
-// mmap(2) flags translation table
-SyscallFlagTransTable X86Linux32::mmapFlagTable[] = {
- { X86Linux32::TGT_MAP_SHARED, MAP_SHARED },
- { X86Linux32::TGT_MAP_PRIVATE, MAP_PRIVATE },
- { X86Linux32::TGT_MAP_32BIT, MAP_32BIT},
- { X86Linux32::TGT_MAP_ANON, MAP_ANON },
- { X86Linux32::TGT_MAP_DENYWRITE, MAP_DENYWRITE },
- { X86Linux32::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE },
- { X86Linux32::TGT_MAP_FILE, MAP_FILE },
- { X86Linux32::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN },
-#ifdef MAP_HUGETLB
- { X86Linux32::TGT_MAP_HUGETLB, MAP_HUGETLB },
-#endif
- { X86Linux32::TGT_MAP_LOCKED, MAP_LOCKED },
- { X86Linux32::TGT_MAP_NONBLOCK, MAP_NONBLOCK },
- { X86Linux32::TGT_MAP_NORESERVE, MAP_NORESERVE },
- { X86Linux32::TGT_MAP_POPULATE, MAP_POPULATE },
-#ifdef MAP_STACK
- { X86Linux32::TGT_MAP_STACK, MAP_STACK },
-#endif
- { X86Linux32::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS },
- { X86Linux32::TGT_MAP_FIXED, MAP_FIXED },
-};
-
-const unsigned X86Linux32::NUM_MMAP_FLAGS =
- sizeof(X86Linux32::mmapFlagTable) /
- sizeof(X86Linux32::mmapFlagTable[0]);
+#undef TARGET
+#define TARGET X86Linux64
+#include "kern/linux/flag_tables.hh"