From 6523aad25c32f2443c48b114db4dab078bfb16d1 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Wed, 22 Oct 2014 15:59:57 -0500 Subject: sim: revert 6709bbcf564d The identifier SYS_getdents is not available on Mac OS X. Therefore, its use results in compilation failure. It seems there is no straight forward way to implement the system call getdents using readdir() or similar C functions. Hence the commit 6709bbcf564d is being rolled back. --- src/sim/syscall_emul.hh | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/sim/syscall_emul.hh') diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index f793bc41f..dff34982d 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -439,14 +439,6 @@ futexFunc(SyscallDesc *desc, int callnum, LiveProcess *process, } -/// Target getdents() handler. -SyscallReturn getdentsFunc(SyscallDesc *desc, int num, - LiveProcess *process, ThreadContext *tc); - -/// Target getdents64() handler. -SyscallReturn getdents64Func(SyscallDesc *desc, int num, - LiveProcess *process, ThreadContext *tc); - /// Pseudo Funcs - These functions use a different return convension, /// returning a second value in a register other than the normal return register -- cgit v1.2.3 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/syscall_emul.hh | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/sim/syscall_emul.hh') 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/") || -- cgit v1.2.3 From 44af2c6a6913d35a2c34bd928dbfdef3c16dcaf9 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Wed, 22 Oct 2014 15:53:34 -0700 Subject: syscall_emul: Put BufferArg classes in a separate header. Move the BufferArg classes that support syscall buffer args (i.e., pointers into simulated user space) out of syscall_emul.hh and into a new header syscall_emul_buf.hh so they are accessible to emulated driver implementations. Take the opportunity to add some comments as well. --- src/sim/syscall_emul.hh | 69 +------------------------------------------------ 1 file changed, 1 insertion(+), 68 deletions(-) (limited to 'src/sim/syscall_emul.hh') diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 1c84e9f48..a4f9b238e 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -75,10 +75,10 @@ #include "cpu/thread_context.hh" #include "debug/SyscallVerbose.hh" #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/syscall_emul_buf.hh" #include "sim/syscallreturn.hh" #include "sim/system.hh" @@ -117,73 +117,6 @@ class SyscallDesc { }; -class BaseBufferArg { - - public: - - BaseBufferArg(Addr _addr, int _size) : addr(_addr), size(_size) - { - bufPtr = new uint8_t[size]; - // clear out buffer: in case we only partially populate this, - // and then do a copyOut(), we want to make sure we don't - // introduce any random junk into the simulated address space - memset(bufPtr, 0, size); - } - - virtual ~BaseBufferArg() { delete [] bufPtr; } - - // - // copy data into simulator space (read from target memory) - // - virtual bool copyIn(SETranslatingPortProxy &memproxy) - { - memproxy.readBlob(addr, bufPtr, size); - return true; // no EFAULT detection for now - } - - // - // copy data out of simulator space (write to target memory) - // - virtual bool copyOut(SETranslatingPortProxy &memproxy) - { - memproxy.writeBlob(addr, bufPtr, size); - return true; // no EFAULT detection for now - } - - protected: - Addr addr; - int size; - uint8_t *bufPtr; -}; - - -class BufferArg : public BaseBufferArg -{ - public: - BufferArg(Addr _addr, int _size) : BaseBufferArg(_addr, _size) { } - void *bufferPtr() { return bufPtr; } -}; - -template -class TypedBufferArg : public BaseBufferArg -{ - public: - // user can optionally specify a specific number of bytes to - // allocate to deal with those structs that have variable-size - // arrays at the end - TypedBufferArg(Addr _addr, int _size = sizeof(T)) - : BaseBufferArg(_addr, _size) - { } - - // type case - operator T*() { return (T *)bufPtr; } - - // dereference operators - T &operator*() { return *((T *)bufPtr); } - T* operator->() { return (T *)bufPtr; } - T &operator[](int i) { return ((T *)bufPtr)[i]; } -}; - ////////////////////////////////////////////////////////////////////// // // The following emulation functions are generic enough that they -- cgit v1.2.3