diff options
author | Ali Saidi <saidi@eecs.umich.edu> | 2006-02-18 23:44:22 -0500 |
---|---|---|
committer | Ali Saidi <saidi@eecs.umich.edu> | 2006-02-18 23:44:22 -0500 |
commit | 53d2c9398e8c1631ae3fd5469b187b006d317f88 (patch) | |
tree | a55a2a385aab16a2e6f42858fe5464067f6ad7fe /sim | |
parent | 7b42d61f13e16afb3b9191f7c7510ebf4c72fd08 (diff) | |
download | gem5-53d2c9398e8c1631ae3fd5469b187b006d317f88.tar.xz |
Move Linux/Tru64 architecture independent code into kern/*
leaving dependent code making way for solaris linux syscall emu.
SConscript:
Add two new files for syscall emulation
Add getDesc() function
arch/alpha/alpha_linux_process.cc:
arch/alpha/alpha_tru64_process.cc:
move architecture independent code into kern/linux/linux.(hh|cc)
arch/alpha/alpha_linux_process.hh:
arch/alpha/alpha_tru64_process.hh:
Add getDesc function
kern/linux/linux.hh:
move generi linux syscall emulation code into kern/linux
kern/tru64/tru64.hh:
move generi tru64 syscall emulation code into kern/tru64
sim/process.cc:
sim/process.hh:
Push the function determination and calling stuff down to LiveProcess
and out of the Linux/Tru64 classes respectively
sim/syscall_emul.cc:
sim/syscall_emul.hh:
fnctl implementation was identical in tru64 and linux so moved to generic
--HG--
extra : convert_revision : 103293dbe6fe2f7892de4929d17dc085def77026
Diffstat (limited to 'sim')
-rw-r--r-- | sim/process.cc | 15 | ||||
-rw-r--r-- | sim/process.hh | 6 | ||||
-rw-r--r-- | sim/syscall_emul.cc | 46 | ||||
-rw-r--r-- | sim/syscall_emul.hh | 4 |
4 files changed, 71 insertions, 0 deletions
diff --git a/sim/process.cc b/sim/process.cc index 59d122b48..3ae3abb52 100644 --- a/sim/process.cc +++ b/sim/process.cc @@ -46,6 +46,7 @@ #include "sim/fake_syscall.hh" #include "sim/process.hh" #include "sim/stats.hh" +#include "sim/syscall_emul.hh" #ifdef TARGET_ALPHA #include "arch/alpha/alpha_tru64_process.hh" @@ -350,6 +351,19 @@ LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile, init_regs->npc = prog_entry + sizeof(MachInst); } +void +LiveProcess::syscall(ExecContext *xc) +{ + num_syscalls++; + + int64_t callnum = xc->regs.intRegFile[ReturnValueReg]; + + SyscallDesc *desc = getDesc(callnum); + if (desc == NULL) + fatal("Syscall %d out of range", callnum); + + desc->doSyscall(callnum, this, xc); +} LiveProcess * LiveProcess::create(const string &nm, @@ -394,6 +408,7 @@ LiveProcess::create(const string &nm, } + BEGIN_DECLARE_SIM_OBJECT_PARAMS(LiveProcess) VectorParam<string> cmd; diff --git a/sim/process.hh b/sim/process.hh index 43fafd9d7..40143ea04 100644 --- a/sim/process.hh +++ b/sim/process.hh @@ -48,6 +48,7 @@ class ExecContext; class FunctionalMemory; +class SyscallDesc; class Process : public SimObject { public: @@ -200,6 +201,11 @@ class LiveProcess : public Process std::string executable, std::vector<std::string> &argv, std::vector<std::string> &envp); + + virtual void syscall(ExecContext *xc); + + virtual SyscallDesc* getDesc(int callnum) { panic("Must be implemented."); } + }; diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc index 4b6388a41..a46e991b9 100644 --- a/sim/syscall_emul.cc +++ b/sim/syscall_emul.cc @@ -26,6 +26,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <fcntl.h> #include <unistd.h> #include <string> @@ -278,3 +279,48 @@ fchownFunc(SyscallDesc *desc, int num, Process *process, ExecContext *xc) int result = fchown(fd, hostOwner, hostGroup); return (result == -1) ? -errno : result; } + + +SyscallReturn +fcntlFunc(SyscallDesc *desc, int num, Process *process, + ExecContext *xc) +{ + int fd = xc->getSyscallArg(0); + + if (fd < 0 || process->sim_fd(fd) < 0) + return -EBADF; + + int cmd = xc->getSyscallArg(1); + switch (cmd) { + case 0: // F_DUPFD + // if we really wanted to support this, we'd need to do it + // in the target fd space. + warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd); + return -EMFILE; + + case 1: // F_GETFD (get close-on-exec flag) + case 2: // F_SETFD (set close-on-exec flag) + return 0; + + case 3: // F_GETFL (get file flags) + case 4: // F_SETFL (set file flags) + // not sure if this is totally valid, but we'll pass it through + // to the underlying OS + warn("fcntl(%d, %d) passed through to host\n", fd, cmd); + return fcntl(process->sim_fd(fd), cmd); + // return 0; + + case 7: // F_GETLK (get lock) + case 8: // F_SETLK (set lock) + case 9: // F_SETLKW (set lock and wait) + // don't mess with file locking... just act like it's OK + warn("File lock call (fcntl(%d, %d)) ignored.\n", fd, cmd); + return 0; + + default: + warn("Unknown fcntl command %d\n", cmd); + return 0; + } +} + + diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh index d8029ddb0..fd5c7b6e6 100644 --- a/sim/syscall_emul.hh +++ b/sim/syscall_emul.hh @@ -239,6 +239,10 @@ SyscallReturn chownFunc(SyscallDesc *desc, int num, SyscallReturn fchownFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +/// Target fnctl() handler. +SyscallReturn fcntlFunc(SyscallDesc *desc, int num, + Process *process, ExecContext *xc); + /// This struct is used to build an target-OS-dependent table that /// maps the target's open() flags to the host open() flags. struct OpenFlagTransTable { |