changeset 2b416ef3b400 in /z/repo/gem5 details: http://repo.gem5.org/gem5?cmd=changeset;node=2b416ef3b400 description: automated merge
diffstat: src/arch/alpha/linux/process.cc | 4 +- src/arch/arm/linux/process.cc | 4 +- src/arch/mips/linux/process.cc | 4 +- src/arch/power/linux/process.cc | 4 +- src/arch/sparc/linux/syscalls.cc | 8 +- src/arch/x86/linux/process.cc | 4 +- src/sim/Process.py | 8 + src/sim/emul_driver.hh | 90 ++++++++++++++++++++ src/sim/process.cc | 30 ++++-- src/sim/process.hh | 15 +++- src/sim/syscall_emul.cc | 47 +--------- src/sim/syscall_emul.hh | 113 ++++++------------------- src/sim/syscall_emul_buf.hh | 168 +++++++++++++++++++++++++++++++++++++++ src/sim/syscallreturn.hh | 15 +++- 14 files changed, 366 insertions(+), 148 deletions(-) diffs (truncated from 821 to 300 lines): diff -r ca4438b6e39a -r 2b416ef3b400 src/arch/alpha/linux/process.cc --- a/src/arch/alpha/linux/process.cc Wed Oct 29 23:18:29 2014 -0500 +++ b/src/arch/alpha/linux/process.cc Wed Oct 29 23:22:26 2014 -0500 @@ -431,7 +431,7 @@ /* 302 */ SyscallDesc("mount", unimplementedFunc), /* 303 */ SyscallDesc("old_adjtimex", unimplementedFunc), /* 304 */ SyscallDesc("swapoff", unimplementedFunc), - /* 305 */ SyscallDesc("getdents", getdentsFunc), + /* 305 */ SyscallDesc("getdents", unimplementedFunc), /* 306 */ SyscallDesc("create_module", unimplementedFunc), /* 307 */ SyscallDesc("init_module", unimplementedFunc), /* 308 */ SyscallDesc("delete_module", unimplementedFunc), @@ -503,7 +503,7 @@ /* 374 */ SyscallDesc("pivot_root", unimplementedFunc), /* 375 */ SyscallDesc("mincore", unimplementedFunc), /* 376 */ SyscallDesc("pciconfig_iobase", unimplementedFunc), - /* 377 */ SyscallDesc("getdents64", getdents64Func), + /* 377 */ SyscallDesc("getdents64", unimplementedFunc), /* 378 */ SyscallDesc("gettid", unimplementedFunc), /* 379 */ SyscallDesc("readahead", unimplementedFunc), /* 380 */ SyscallDesc("security", unimplementedFunc), diff -r ca4438b6e39a -r 2b416ef3b400 src/arch/arm/linux/process.cc --- a/src/arch/arm/linux/process.cc Wed Oct 29 23:18:29 2014 -0500 +++ b/src/arch/arm/linux/process.cc Wed Oct 29 23:22:26 2014 -0500 @@ -260,7 +260,7 @@ /* 138 */ SyscallDesc("setfsuid", unimplementedFunc), /* 139 */ SyscallDesc("setfsgid", unimplementedFunc), /* 140 */ SyscallDesc("llseek", _llseekFunc), - /* 141 */ SyscallDesc("getdents", getdentsFunc), + /* 141 */ SyscallDesc("getdents", unimplementedFunc), /* 142 */ SyscallDesc("newselect", unimplementedFunc), /* 143 */ SyscallDesc("flock", unimplementedFunc), /* 144 */ SyscallDesc("msync", unimplementedFunc), @@ -336,7 +336,7 @@ /* 214 */ SyscallDesc("setgid", unimplementedFunc), /* 215 */ SyscallDesc("setfsuid", unimplementedFunc), /* 216 */ SyscallDesc("setfsgid", unimplementedFunc), - /* 217 */ SyscallDesc("getdents64", getdents64Func), + /* 217 */ SyscallDesc("getdents64", unimplementedFunc), /* 218 */ SyscallDesc("pivot_root", unimplementedFunc), /* 219 */ SyscallDesc("mincore", unimplementedFunc), /* 220 */ SyscallDesc("madvise", unimplementedFunc), diff -r ca4438b6e39a -r 2b416ef3b400 src/arch/mips/linux/process.cc --- a/src/arch/mips/linux/process.cc Wed Oct 29 23:18:29 2014 -0500 +++ b/src/arch/mips/linux/process.cc Wed Oct 29 23:22:26 2014 -0500 @@ -277,7 +277,7 @@ /* 138 */ SyscallDesc("setfsuid", unimplementedFunc), /* 139 */ SyscallDesc("setfsgid", unimplementedFunc), /* 140 */ SyscallDesc("llseek", unimplementedFunc), - /* 141 */ SyscallDesc("getdents", getdentsFunc), + /* 141 */ SyscallDesc("getdents", unimplementedFunc), /* 142 */ SyscallDesc("newselect", unimplementedFunc), /* 143 */ SyscallDesc("flock", unimplementedFunc), /* 144 */ SyscallDesc("msync", unimplementedFunc), @@ -355,7 +355,7 @@ /* 216 */ SyscallDesc("pivot_root", unimplementedFunc), /* 217 */ SyscallDesc("mincore", unimplementedFunc), /* 218 */ SyscallDesc("madvise", unimplementedFunc), - /* 219 */ SyscallDesc("getdents64", getdents64Func), + /* 219 */ SyscallDesc("getdents64", unimplementedFunc), /* 220 */ SyscallDesc("fcntl64", fcntl64Func), /* 221 */ SyscallDesc("reserved#221", unimplementedFunc), /* 222 */ SyscallDesc("gettid", unimplementedFunc), diff -r ca4438b6e39a -r 2b416ef3b400 src/arch/power/linux/process.cc --- a/src/arch/power/linux/process.cc Wed Oct 29 23:18:29 2014 -0500 +++ b/src/arch/power/linux/process.cc Wed Oct 29 23:22:26 2014 -0500 @@ -205,7 +205,7 @@ /* 138 */ SyscallDesc("setfsuid", unimplementedFunc), /* 139 */ SyscallDesc("setfsgid", unimplementedFunc), /* 140 */ SyscallDesc("llseek", _llseekFunc), - /* 141 */ SyscallDesc("getdents", getdentsFunc), + /* 141 */ SyscallDesc("getdents", unimplementedFunc), /* 142 */ SyscallDesc("newselect", unimplementedFunc), /* 143 */ SyscallDesc("flock", unimplementedFunc), /* 144 */ SyscallDesc("msync", unimplementedFunc), @@ -281,7 +281,7 @@ /* 214 */ SyscallDesc("setgid", unimplementedFunc), /* 215 */ SyscallDesc("setfsuid", unimplementedFunc), /* 216 */ SyscallDesc("setfsgid", unimplementedFunc), - /* 217 */ SyscallDesc("getdents64", getdents64Func), + /* 217 */ SyscallDesc("getdents64", unimplementedFunc), /* 218 */ SyscallDesc("pivot_root", unimplementedFunc), /* 219 */ SyscallDesc("mincore", unimplementedFunc), /* 220 */ SyscallDesc("madvise", unimplementedFunc), diff -r ca4438b6e39a -r 2b416ef3b400 src/arch/sparc/linux/syscalls.cc --- a/src/arch/sparc/linux/syscalls.cc Wed Oct 29 23:18:29 2014 -0500 +++ b/src/arch/sparc/linux/syscalls.cc Wed Oct 29 23:22:26 2014 -0500 @@ -241,7 +241,7 @@ /* 151 */ SyscallDesc("inotify_init", unimplementedFunc), /* 152 */ SyscallDesc("inotify_add_watch", unimplementedFunc), /* 153 */ SyscallDesc("poll", unimplementedFunc), - /* 154 */ SyscallDesc("getdents64", getdents64Func), + /* 154 */ SyscallDesc("getdents64", unimplementedFunc), /* 155 */ SyscallDesc("fcntl64", unimplementedFunc), /* 156 */ SyscallDesc("inotify_rm_watch", unimplementedFunc), /* 157 */ SyscallDesc("statfs", unimplementedFunc), @@ -261,7 +261,7 @@ /* 171 */ SyscallDesc("fsetxattr", unimplementedFunc), // 32 bit /* 172 */ SyscallDesc("getxattr", unimplementedFunc), /* 173 */ SyscallDesc("lgetxattr", unimplementedFunc), - /* 174 */ SyscallDesc("getdents", getdentsFunc), + /* 174 */ SyscallDesc("getdents", unimplementedFunc), /* 175 */ SyscallDesc("setsid", unimplementedFunc), /* 176 */ SyscallDesc("fchdir", unimplementedFunc), /* 177 */ SyscallDesc("fgetxattr", unimplementedFunc), // 32 bit @@ -547,7 +547,7 @@ /* 151 */ SyscallDesc("inotify_init", unimplementedFunc), /* 152 */ SyscallDesc("inotify_add_watch", unimplementedFunc), /* 153 */ SyscallDesc("poll", unimplementedFunc), - /* 154 */ SyscallDesc("getdents64", getdents64Func), + /* 154 */ SyscallDesc("getdents64", unimplementedFunc), /* 155 */ SyscallDesc("fcntl64", unimplementedFunc), /* 156 */ SyscallDesc("inotify_rm_watch", unimplementedFunc), /* 157 */ SyscallDesc("statfs", unimplementedFunc), @@ -567,7 +567,7 @@ /* 171 */ SyscallDesc("fsetxattr", unimplementedFunc), /* 172 */ SyscallDesc("getxattr", unimplementedFunc), /* 173 */ SyscallDesc("lgetxattr", unimplementedFunc), - /* 174 */ SyscallDesc("getdents", getdentsFunc), + /* 174 */ SyscallDesc("getdents", unimplementedFunc), /* 175 */ SyscallDesc("setsid", unimplementedFunc), /* 176 */ SyscallDesc("fchdir", unimplementedFunc), /* 177 */ SyscallDesc("fgetxattr", unimplementedFunc), diff -r ca4438b6e39a -r 2b416ef3b400 src/arch/x86/linux/process.cc --- a/src/arch/x86/linux/process.cc Wed Oct 29 23:18:29 2014 -0500 +++ b/src/arch/x86/linux/process.cc Wed Oct 29 23:22:26 2014 -0500 @@ -296,7 +296,7 @@ /* 75 */ SyscallDesc("fdatasync", unimplementedFunc), /* 76 */ SyscallDesc("truncate", truncateFunc), /* 77 */ SyscallDesc("ftruncate", ftruncateFunc), - /* 78 */ SyscallDesc("getdents", getdentsFunc), + /* 78 */ SyscallDesc("getdents", unimplementedFunc), /* 79 */ SyscallDesc("getcwd", getcwdFunc), /* 80 */ SyscallDesc("chdir", unimplementedFunc), /* 81 */ SyscallDesc("fchdir", unimplementedFunc), @@ -435,7 +435,7 @@ /* 214 */ SyscallDesc("epoll_ctl_old", unimplementedFunc), /* 215 */ SyscallDesc("epoll_wait_old", unimplementedFunc), /* 216 */ SyscallDesc("remap_file_pages", unimplementedFunc), - /* 217 */ SyscallDesc("getdents64", getdents64Func), + /* 217 */ SyscallDesc("getdents64", unimplementedFunc), /* 218 */ SyscallDesc("set_tid_address", unimplementedFunc), /* 219 */ SyscallDesc("restart_syscall", unimplementedFunc), /* 220 */ SyscallDesc("semtimedop", unimplementedFunc), diff -r ca4438b6e39a -r 2b416ef3b400 src/sim/Process.py --- a/src/sim/Process.py Wed Oct 29 23:18:29 2014 -0500 +++ b/src/sim/Process.py Wed Oct 29 23:22:26 2014 -0500 @@ -46,6 +46,12 @@ def export_methods(cls, code): code('bool map(Addr vaddr, Addr paddr, int size);') +class EmulatedDriver(SimObject): + type = 'EmulatedDriver' + cxx_header = "sim/emul_driver.hh" + abstract = True + filename = Param.String("device file name (under /dev)") + class LiveProcess(Process): type = 'LiveProcess' cxx_header = "sim/process.hh" @@ -60,3 +66,5 @@ pid = Param.Int(100, 'process id') ppid = Param.Int(99, 'parent process id') simpoint = Param.UInt64(0, 'simulation point at which to start simulation') + drivers = VectorParam.EmulatedDriver([], 'Available emulated drivers') + diff -r ca4438b6e39a -r 2b416ef3b400 src/sim/emul_driver.hh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sim/emul_driver.hh Wed Oct 29 23:22:26 2014 -0500 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014 Advanced Micro Devices, Inc. + * All rights reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Steve Reinhardt + */ + +#ifndef __SIM_EMUL_DRIVER_HH +#define __SIM_EMUL_DRIVER_HH + +#include <string> + +#include "params/EmulatedDriver.hh" +#include "sim/sim_object.hh" + +class LiveProcess; +class ThreadContext; + +/** + * EmulatedDriver is an abstract base class for fake SE-mode device drivers. + * + * Specific drivers that allow applications to communicate with simulated + * hardware inside gem5 can be created by deriving from this class and + * overriding the abstract virtual methods. + * + * Currently only open() and ioctl() calls are supported, but other calls + * (e.g., read(), write(), mmap()) could be added as needed. + */ +class EmulatedDriver : public SimObject +{ + protected: + /** + * filename for opening this driver (under /dev) + */ + const std::string &filename; + + public: + EmulatedDriver(EmulatedDriverParams *p) + : SimObject(p), filename(p->filename) + { + } + + /** + * Check for a match with this driver's filename. + */ + bool match(const std::string &s) const { return (s == filename); } + + /** + * Abstract method, invoked when the user program calls open() on + * the device driver. The parameters are the same as those passed + * to openFunc() (q.v.). + * @return A newly allocated target fd, or -1 on error. + */ + virtual int open(LiveProcess *p, ThreadContext *tc, + int mode, int flags) = 0; + + /** + * Abstract method, invoked when the user program calls ioctl() on + * the file descriptor returned by a previous open(). The parameters + * are the same as those passed in to ioctlFunc() (q.v.). + * @return The return code for the ioctl, or the negation of the errno + * (see the SyscallReturn class). + */ + virtual int ioctl(LiveProcess *p, ThreadContext *tc, unsigned req) = 0; +}; + +#endif // __SIM_EMUL_DRIVER_HH diff -r ca4438b6e39a -r 2b416ef3b400 src/sim/process.cc --- a/src/sim/process.cc Wed Oct 29 23:18:29 2014 -0500 +++ b/src/sim/process.cc Wed Oct 29 23:22:26 2014 -0500 @@ -278,7 +278,7 @@ // 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 @@ fdo->flags = 0; fdo->isPipe = false; fdo->readPipeSource = 0; + fdo->driver = NULL; } @@ -565,16 +566,14 @@ //////////////////////////////////////////////////////////////////////// -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) + 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; _______________________________________________ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev