From 44ec1d212499246be3cef40ce7c96a3f65286153 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Wed, 22 Oct 2014 15:53:34 -0700 Subject: syscall_emul: add EmulatedDriver object Fake SE-mode device drivers can now be added by deriving from this abstract object. --- src/sim/process.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/sim/process.cc') diff --git a/src/sim/process.cc b/src/sim/process.cc index 913e9298d..15dc8c3e8 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -278,7 +278,7 @@ Process::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe) // find first free target fd for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) { Process::FdMap *fdo = &fd_map[free_fd]; - if (fdo->fd == -1) { + if (fdo->fd == -1 && fdo->driver == NULL) { fdo->fd = sim_fd; fdo->filename = filename; fdo->mode = mode; @@ -309,6 +309,7 @@ Process::free_fd(int tgt_fd) fdo->flags = 0; fdo->isPipe = false; fdo->readPipeSource = 0; + fdo->driver = NULL; } @@ -567,7 +568,8 @@ Process::map(Addr vaddr, Addr paddr, int size) LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile) : Process(params), objFile(_objFile), - argv(params->cmd), envp(params->env), cwd(params->cwd) + argv(params->cmd), envp(params->env), cwd(params->cwd), + drivers(params->drivers) { __uid = params->uid; __euid = params->euid; @@ -608,6 +610,19 @@ LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width) return getSyscallArg(tc, i); } + +EmulatedDriver * +LiveProcess::findDriver(std::string filename) +{ + for (EmulatedDriver *d : drivers) { + if (d->match(filename)) + return d; + } + + return NULL; +} + + LiveProcess * LiveProcess::create(LiveProcessParams * params) { -- cgit v1.2.3 From 9ac7f14fc021075af458404096e76225b1ea59df Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Wed, 22 Oct 2014 15:53:34 -0700 Subject: syscall_emul: minor style fix to LiveProcess constructor --- src/sim/process.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/sim/process.cc') diff --git a/src/sim/process.cc b/src/sim/process.cc index 15dc8c3e8..d1fb22029 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -566,17 +566,14 @@ Process::map(Addr vaddr, Addr paddr, int size) //////////////////////////////////////////////////////////////////////// -LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile) +LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile) : Process(params), objFile(_objFile), argv(params->cmd), envp(params->env), cwd(params->cwd), + __uid(params->uid), __euid(params->euid), + __gid(params->gid), __egid(params->egid), + __pid(params->pid), __ppid(params->ppid), drivers(params->drivers) { - __uid = params->uid; - __euid = params->euid; - __gid = params->gid; - __egid = params->egid; - __pid = params->pid; - __ppid = params->ppid; // load up symbols, if any... these may be used for debugging or // profiling. -- cgit v1.2.3