summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.hh
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2014-10-22 15:53:34 -0700
committerSteve Reinhardt <steve.reinhardt@amd.com>2014-10-22 15:53:34 -0700
commit44ec1d212499246be3cef40ce7c96a3f65286153 (patch)
tree503f72a85b24db8b82f792cd22341aeb0bdcd112 /src/sim/syscall_emul.hh
parent6523aad25c32f2443c48b114db4dab078bfb16d1 (diff)
downloadgem5-44ec1d212499246be3cef40ce7c96a3f65286153.tar.xz
syscall_emul: add EmulatedDriver object
Fake SE-mode device drivers can now be added by deriving from this abstract object.
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r--src/sim/syscall_emul.hh36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index dff34982d..1c84e9f48 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -77,6 +77,7 @@
#include "mem/page_table.hh"
#include "mem/se_translating_port_proxy.hh"
#include "sim/byteswap.hh"
+#include "sim/emul_driver.hh"
#include "sim/process.hh"
#include "sim/syscallreturn.hh"
#include "sim/system.hh"
@@ -604,11 +605,17 @@ ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", fd, req);
- if (fd < 0 || process->sim_fd(fd) < 0) {
+ Process::FdMap *fdObj = process->sim_fd_obj(fd);
+
+ if (fdObj == NULL) {
// doesn't map to any simulator fd: not a valid target fd
return -EBADF;
}
+ if (fdObj->driver != NULL) {
+ return fdObj->driver->ioctl(process, tc, req);
+ }
+
if (OS::isTtyReq(req)) {
return -ENOTTY;
}
@@ -629,13 +636,6 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
process->getSyscallArg(tc, index)))
return -EFAULT;
- if (path == "/dev/sysdev0") {
- // This is a memory-mapped high-resolution timer device on Alpha.
- // We don't support it, so just punt.
- warn("Ignoring open(%s, ...)\n", path);
- return -ENOENT;
- }
-
int tgtFlags = process->getSyscallArg(tc, index);
int mode = process->getSyscallArg(tc, index);
int hostFlags = 0;
@@ -661,6 +661,26 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
DPRINTF(SyscallVerbose, "opening file %s\n", path.c_str());
+ if (startswith(path, "/dev/")) {
+ std::string filename = path.substr(strlen("/dev/"));
+ if (filename == "sysdev0") {
+ // This is a memory-mapped high-resolution timer device on Alpha.
+ // We don't support it, so just punt.
+ warn("Ignoring open(%s, ...)\n", path);
+ return -ENOENT;
+ }
+
+ EmulatedDriver *drv = process->findDriver(filename);
+ if (drv != NULL) {
+ // the driver's open method will allocate a fd from the
+ // process if necessary.
+ return drv->open(process, tc, mode, hostFlags);
+ }
+
+ // fall through here for pass through to host devices, such as
+ // /dev/zero
+ }
+
int fd;
int local_errno;
if (startswith(path, "/proc/") || startswith(path, "/system/") ||