diff options
Diffstat (limited to 'sim/syscall_emul.hh')
-rw-r--r-- | sim/syscall_emul.hh | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh index 35129bcb4..25f8c6cb8 100644 --- a/sim/syscall_emul.hh +++ b/sim/syscall_emul.hh @@ -46,11 +46,12 @@ #include <sys/uio.h> #include "base/intmath.hh" // for RoundUp -#include "mem/functional/functional.hh" +#include "mem/translating_port.hh" #include "arch/isa_traits.hh" // for Addr #include "base/trace.hh" #include "cpu/exec_context.hh" +#include "cpu/base.hh" #include "sim/process.hh" /// @@ -106,18 +107,18 @@ class BaseBufferArg { // // copy data into simulator space (read from target memory) // - virtual bool copyIn(FunctionalMemory *mem) + virtual bool copyIn(TranslatingPort *memport) { - mem->access(Read, addr, bufPtr, size); + memport->readBlobFunctional(addr, bufPtr, size); return true; // no EFAULT detection for now } // // copy data out of simulator space (write to target memory) // - virtual bool copyOut(FunctionalMemory *mem) + virtual bool copyOut(TranslatingPort *memport) { - mem->access(Write, addr, bufPtr, size); + memport->writeBlobFunctional(addr, bufPtr, size); return true; // no EFAULT detection for now } @@ -369,7 +370,7 @@ openFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) return -EFAULT; if (path == "/dev/sysdev0") { @@ -416,7 +417,7 @@ chmodFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) return -EFAULT; uint32_t mode = xc->getSyscallArg(1); @@ -469,8 +470,8 @@ statFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; struct stat hostBuf; int result = stat(path.c_str(), &hostBuf); @@ -478,7 +479,7 @@ statFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -507,7 +508,7 @@ fstat64Func(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStat64Buf(xc->getMemPtr(), fd, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStat64Buf(xc->port, fd, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -521,8 +522,8 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; struct stat hostBuf; int result = lstat(path.c_str(), &hostBuf); @@ -530,7 +531,7 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -543,8 +544,8 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; #if BSD_HOST struct stat hostBuf; @@ -557,7 +558,7 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStat64Buf(xc->getMemPtr(), -1, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStat64Buf(xc->port, -1, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -581,7 +582,8 @@ fstatFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf); + return 0; } @@ -594,8 +596,8 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; struct statfs hostBuf; int result = statfs(path.c_str(), &hostBuf); @@ -603,7 +605,7 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatfsBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatfsBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -626,7 +628,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatfsBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatfsBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -650,12 +652,12 @@ writevFunc(SyscallDesc *desc, int callnum, Process *process, for (int i = 0; i < count; ++i) { typename OS::tgt_iovec tiov; - xc->getMemPtr()->access(Read, tiov_base + i*sizeof(typename OS::tgt_iovec), + xc->port->readBlobFunctional(tiov_base + i*sizeof(typename OS::tgt_iovec),(uint8_t*) &tiov, sizeof(typename OS::tgt_iovec)); hiov[i].iov_len = gtoh(tiov.iov_len); hiov[i].iov_base = new char [hiov[i].iov_len]; - xc->getMemPtr()->access(Read, gtoh(tiov.iov_base), - hiov[i].iov_base, hiov[i].iov_len); + xc->port->readBlobFunctional(gtoh(tiov.iov_base), + (uint8_t *)hiov[i].iov_base, hiov[i].iov_len); } int result = writev(process->sim_fd(fd), hiov, count); @@ -737,7 +739,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process, break; } - rlp.copyOut(xc->getMemPtr()); + rlp.copyOut(xc->port); return 0; } @@ -754,7 +756,7 @@ gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process, tp->tv_sec = htog(tp->tv_sec); tp->tv_usec = htog(tp->tv_usec); - tp.copyOut(xc->getMemPtr()); + tp.copyOut(xc->port); return 0; } @@ -768,11 +770,11 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; TypedBufferArg<typename OS::timeval [2]> tp(xc->getSyscallArg(1)); - tp.copyIn(xc->getMemPtr()); + tp.copyIn(xc->port); struct timeval hostTimeval[2]; for (int i = 0; i < 2; ++i) @@ -824,7 +826,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process, rup->ru_nvcsw = 0; rup->ru_nivcsw = 0; - rup.copyOut(xc->getMemPtr()); + rup.copyOut(xc->port); return 0; } |