diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:45:30 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:45:30 -0500 |
commit | 9e3c8de30bafe33f35e4b9e82fb49418941f8cb7 (patch) | |
tree | 016c65f8060c49b31d3fd3c064b97ae09279d689 /src/sim/syscall_emul.hh | |
parent | 1031b824b975cec999c37cabc8c05c485a4ae5ca (diff) | |
download | gem5-9e3c8de30bafe33f35e4b9e82fb49418941f8cb7.tar.xz |
MEM: Make port proxies use references rather than pointers
This patch is adding a clearer design intent to all objects that would
not be complete without a port proxy by making the proxies members
rathen than dynamically allocated. In essence, if NULL would not be a
valid value for the proxy, then we avoid using a pointer to make this
clear.
The same approach is used for the methods using these proxies, such as
loadSections, that now use references rather than pointers to better
reflect the fact that NULL would not be an acceptable value (in fact
the code would break and that is how this patch started out).
Overall the concept of "using a reference to express unconditional
composition where a NULL pointer is never valid" could be done on a
much broader scale throughout the code base, but for now it is only
done in the locations affected by the proxies.
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r-- | src/sim/syscall_emul.hh | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index ad00f6e3d..504add35f 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -121,18 +121,18 @@ class BaseBufferArg { // // copy data into simulator space (read from target memory) // - virtual bool copyIn(SETranslatingPortProxy* memproxy) + virtual bool copyIn(SETranslatingPortProxy &memproxy) { - memproxy->readBlob(addr, bufPtr, size); + 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) + virtual bool copyOut(SETranslatingPortProxy &memproxy) { - memproxy->writeBlob(addr, bufPtr, size); + memproxy.writeBlob(addr, bufPtr, size); return true; // no EFAULT detection for now } @@ -464,7 +464,7 @@ convertStat64Buf(target_stat &tgt, host_stat64 *host, bool fakeTTY = false) //Here are a couple convenience functions template<class OS> static void -copyOutStatBuf(SETranslatingPortProxy* mem, Addr addr, +copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr, hst_stat *host, bool fakeTTY = false) { typedef TypedBufferArg<typename OS::tgt_stat> tgt_stat_buf; @@ -475,7 +475,7 @@ copyOutStatBuf(SETranslatingPortProxy* mem, Addr addr, template<class OS> static void -copyOutStat64Buf(SETranslatingPortProxy* mem, Addr addr, +copyOutStat64Buf(SETranslatingPortProxy &mem, Addr addr, hst_stat64 *host, bool fakeTTY = false) { typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf; @@ -530,7 +530,7 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) return -EFAULT; @@ -608,7 +608,7 @@ chmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -714,7 +714,7 @@ statFunc(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -744,7 +744,7 @@ stat64Func(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) return -EFAULT; Addr bufPtr = process->getSyscallArg(tc, index); @@ -809,7 +809,7 @@ lstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -838,7 +838,7 @@ lstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -899,7 +899,7 @@ statfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -958,19 +958,19 @@ writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process, return -EBADF; } - SETranslatingPortProxy *p = tc->getMemProxy(); + SETranslatingPortProxy &p = tc->getMemProxy(); uint64_t tiov_base = process->getSyscallArg(tc, index); size_t count = process->getSyscallArg(tc, index); struct iovec hiov[count]; for (size_t i = 0; i < count; ++i) { typename OS::tgt_iovec tiov; - p->readBlob(tiov_base + i*sizeof(typename OS::tgt_iovec), - (uint8_t*)&tiov, sizeof(typename OS::tgt_iovec)); + p.readBlob(tiov_base + i*sizeof(typename OS::tgt_iovec), + (uint8_t*)&tiov, sizeof(typename OS::tgt_iovec)); hiov[i].iov_len = TheISA::gtoh(tiov.iov_len); hiov[i].iov_base = new char [hiov[i].iov_len]; - p->readBlob(TheISA::gtoh(tiov.iov_base), (uint8_t *)hiov[i].iov_base, - hiov[i].iov_len); + p.readBlob(TheISA::gtoh(tiov.iov_base), (uint8_t *)hiov[i].iov_base, + hiov[i].iov_len); } int result = writev(process->sim_fd(fd), hiov, count); @@ -1136,7 +1136,7 @@ utimesFunc(SyscallDesc *desc, int callnum, LiveProcess *process, std::string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -1255,8 +1255,8 @@ timeFunc(SyscallDesc *desc, int callnum, LiveProcess *process, if(taddr != 0) { typename OS::time_t t = sec; t = TheISA::htog(t); - SETranslatingPortProxy *p = tc->getMemProxy(); - p->writeBlob(taddr, (uint8_t*)&t, (int)sizeof(typename OS::time_t)); + SETranslatingPortProxy &p = tc->getMemProxy(); + p.writeBlob(taddr, (uint8_t*)&t, (int)sizeof(typename OS::time_t)); } return sec; } |