Get rid of "Functional" suffix from (read|write)(Blob|String) functions.

--HG--
extra : convert_revision : 1456308af0fd686dff53ec1baddd7747354e1c0a
This commit is contained in:
Steve Reinhardt 2006-03-12 16:38:16 -05:00
parent 159cee1719
commit 2d9c9dba37
8 changed files with 73 additions and 82 deletions

View file

@ -74,11 +74,11 @@ ObjectFile::loadSection(Section *sec, TranslatingPort *memPort, bool loadPhys)
}
if (sec->fileImage) {
memPort->writeBlobFunctional(addr, sec->fileImage, sec->size, true);
memPort->writeBlob(addr, sec->fileImage, sec->size, true);
}
else {
// no image: must be bss
memPort->memsetBlobFunctional(addr, 0, sec->size, true);
memPort->memsetBlob(addr, 0, sec->size, true);
}
}
return true;

View file

@ -52,19 +52,19 @@ Port::blobHelper(Addr addr, uint8_t *p, int size, Command cmd)
}
void
Port::writeBlobFunctional(Addr addr, uint8_t *p, int size)
Port::writeBlob(Addr addr, uint8_t *p, int size)
{
blobHelper(addr, p, size, Write);
}
void
Port::readBlobFunctional(Addr addr, uint8_t *p, int size)
Port::readBlob(Addr addr, uint8_t *p, int size)
{
blobHelper(addr, p, size, Read);
}
void
Port::memsetBlobFunctional(Addr addr, uint8_t val, int size)
Port::memsetBlob(Addr addr, uint8_t val, int size)
{
// quick and dirty...
uint8_t *buf = new uint8_t[size];

View file

@ -191,29 +191,26 @@ class Port
void getPeerAddressRanges(AddrRangeList &range_list, bool &owner)
{ peer->getDeviceAddressRanges(range_list, owner); }
// Do we need similar wrappers for sendAtomic()? If not, should
// we drop the "Functional" from the names?
/** This function is a wrapper around sendFunctional()
that breaks a larger, arbitrarily aligned access into
appropriate chunks. The default implementation can use
getBlockSize() to determine the block size and go from there.
*/
void readBlob(Addr addr, uint8_t *p, int size);
/** This function is a wrapper around sendFunctional()
that breaks a larger, arbitrarily aligned access into
appropriate chunks. The default implementation can use
getBlockSize() to determine the block size and go from there.
*/
void readBlobFunctional(Addr addr, uint8_t *p, int size);
/** This function is a wrapper around sendFunctional()
that breaks a larger, arbitrarily aligned access into
appropriate chunks. The default implementation can use
getBlockSize() to determine the block size and go from there.
*/
void writeBlobFunctional(Addr addr, uint8_t *p, int size);
void writeBlob(Addr addr, uint8_t *p, int size);
/** Fill size bytes starting at addr with byte value val. This
should not need to be virtual, since it can be implemented in
terms of writeBlobFunctional(). However, it shouldn't be
terms of writeBlob(). However, it shouldn't be
performance-critical either, so it could be if we wanted to.
*/
void memsetBlobFunctional(Addr addr, uint8_t val, int size);
void memsetBlob(Addr addr, uint8_t val, int size);
private:

View file

@ -42,7 +42,7 @@ TranslatingPort::~TranslatingPort()
{ }
bool
TranslatingPort::tryReadBlobFunctional(Addr addr, uint8_t *p, int size)
TranslatingPort::tryReadBlob(Addr addr, uint8_t *p, int size)
{
Addr paddr;
int prevSize = 0;
@ -52,7 +52,7 @@ TranslatingPort::tryReadBlobFunctional(Addr addr, uint8_t *p, int size)
if (!pTable->translate(gen.addr(),paddr))
return false;
port->readBlobFunctional(paddr, p + prevSize, gen.size());
port->readBlob(paddr, p + prevSize, gen.size());
prevSize += gen.size();
}
@ -60,16 +60,15 @@ TranslatingPort::tryReadBlobFunctional(Addr addr, uint8_t *p, int size)
}
void
TranslatingPort::readBlobFunctional(Addr addr, uint8_t *p, int size)
TranslatingPort::readBlob(Addr addr, uint8_t *p, int size)
{
if (!tryReadBlobFunctional(addr, p, size))
fatal("readBlobFunctional(0x%x, ...) failed", addr);
if (!tryReadBlob(addr, p, size))
fatal("readBlob(0x%x, ...) failed", addr);
}
bool
TranslatingPort::tryWriteBlobFunctional(Addr addr, uint8_t *p, int size,
bool alloc)
TranslatingPort::tryWriteBlob(Addr addr, uint8_t *p, int size, bool alloc)
{
Addr paddr;
@ -87,7 +86,7 @@ TranslatingPort::tryWriteBlobFunctional(Addr addr, uint8_t *p, int size,
}
}
port->writeBlobFunctional(paddr, p + prevSize, gen.size());
port->writeBlob(paddr, p + prevSize, gen.size());
prevSize += gen.size();
}
@ -96,16 +95,14 @@ TranslatingPort::tryWriteBlobFunctional(Addr addr, uint8_t *p, int size,
void
TranslatingPort::writeBlobFunctional(Addr addr, uint8_t *p, int size,
bool alloc)
TranslatingPort::writeBlob(Addr addr, uint8_t *p, int size, bool alloc)
{
if (!tryWriteBlobFunctional(addr, p, size, alloc))
fatal("writeBlobFunctional(0x%x, ...) failed", addr);
if (!tryWriteBlob(addr, p, size, alloc))
fatal("writeBlob(0x%x, ...) failed", addr);
}
bool
TranslatingPort::tryMemsetBlobFunctional(Addr addr, uint8_t val, int size,
bool alloc)
TranslatingPort::tryMemsetBlob(Addr addr, uint8_t val, int size, bool alloc)
{
Addr paddr;
@ -121,23 +118,22 @@ TranslatingPort::tryMemsetBlobFunctional(Addr addr, uint8_t val, int size,
}
}
port->memsetBlobFunctional(paddr, val, gen.size());
port->memsetBlob(paddr, val, gen.size());
}
return true;
}
void
TranslatingPort::memsetBlobFunctional(Addr addr, uint8_t val, int size,
bool alloc)
TranslatingPort::memsetBlob(Addr addr, uint8_t val, int size, bool alloc)
{
if (!tryMemsetBlobFunctional(addr, val, size, alloc))
fatal("memsetBlobFunctional(0x%x, ...) failed", addr);
if (!tryMemsetBlob(addr, val, size, alloc))
fatal("memsetBlob(0x%x, ...) failed", addr);
}
bool
TranslatingPort::tryWriteStringFunctional(Addr addr, const char *str)
TranslatingPort::tryWriteString(Addr addr, const char *str)
{
Addr paddr,vaddr;
uint8_t c;
@ -149,21 +145,21 @@ TranslatingPort::tryWriteStringFunctional(Addr addr, const char *str)
if (!pTable->translate(vaddr++,paddr))
return false;
port->writeBlobFunctional(paddr, &c, 1);
port->writeBlob(paddr, &c, 1);
} while (c);
return true;
}
void
TranslatingPort::writeStringFunctional(Addr addr, const char *str)
TranslatingPort::writeString(Addr addr, const char *str)
{
if (!tryWriteStringFunctional(addr, str))
fatal("writeStringFunctional(0x%x, ...) failed", addr);
if (!tryWriteString(addr, str))
fatal("writeString(0x%x, ...) failed", addr);
}
bool
TranslatingPort::tryReadStringFunctional(std::string &str, Addr addr)
TranslatingPort::tryReadString(std::string &str, Addr addr)
{
Addr paddr,vaddr;
uint8_t c;
@ -174,7 +170,7 @@ TranslatingPort::tryReadStringFunctional(std::string &str, Addr addr)
if (!pTable->translate(vaddr++,paddr))
return false;
port->readBlobFunctional(paddr, &c, 1);
port->readBlob(paddr, &c, 1);
str += c;
} while (c);
@ -182,9 +178,9 @@ TranslatingPort::tryReadStringFunctional(std::string &str, Addr addr)
}
void
TranslatingPort::readStringFunctional(std::string &str, Addr addr)
TranslatingPort::readString(std::string &str, Addr addr)
{
if (!tryReadStringFunctional(str, addr))
fatal("readStringFunctional(0x%x, ...) failed", addr);
if (!tryReadString(str, addr))
fatal("readString(0x%x, ...) failed", addr);
}

View file

@ -48,21 +48,17 @@ class TranslatingPort
virtual ~TranslatingPort();
public:
bool tryReadBlobFunctional(Addr addr, uint8_t *p, int size);
bool tryWriteBlobFunctional(Addr addr, uint8_t *p, int size,
bool alloc = false);
bool tryMemsetBlobFunctional(Addr addr, uint8_t val, int size,
bool alloc = false);
bool tryWriteStringFunctional(Addr addr, const char *str);
bool tryReadStringFunctional(std::string &str, Addr addr);
bool tryReadBlob(Addr addr, uint8_t *p, int size);
bool tryWriteBlob(Addr addr, uint8_t *p, int size, bool alloc = false);
bool tryMemsetBlob(Addr addr, uint8_t val, int size, bool alloc = false);
bool tryWriteString(Addr addr, const char *str);
bool tryReadString(std::string &str, Addr addr);
void readBlobFunctional(Addr addr, uint8_t *p, int size);
void writeBlobFunctional(Addr addr, uint8_t *p, int size,
bool alloc = false);
void memsetBlobFunctional(Addr addr, uint8_t val, int size,
bool alloc = false);
void writeStringFunctional(Addr addr, const char *str);
void readStringFunctional(std::string &str, Addr addr);
void readBlob(Addr addr, uint8_t *p, int size);
void writeBlob(Addr addr, uint8_t *p, int size, bool alloc = false);
void memsetBlob(Addr addr, uint8_t val, int size, bool alloc = false);
void writeString(Addr addr, const char *str);
void readString(std::string &str, Addr addr);
};
#endif

View file

@ -245,15 +245,15 @@ copyStringArray(vector<string> &strings, Addr array_ptr, Addr data_ptr,
Addr data_ptr_swap;
for (int i = 0; i < strings.size(); ++i) {
data_ptr_swap = htog(data_ptr);
memPort->writeBlobFunctional(array_ptr, (uint8_t*)&data_ptr_swap, sizeof(Addr));
memPort->writeStringFunctional(data_ptr, strings[i].c_str());
memPort->writeBlob(array_ptr, (uint8_t*)&data_ptr_swap, sizeof(Addr));
memPort->writeString(data_ptr, strings[i].c_str());
array_ptr += sizeof(Addr);
data_ptr += strings[i].size() + 1;
}
// add NULL terminator
data_ptr = 0;
memPort->writeBlobFunctional(array_ptr, (uint8_t*)&data_ptr, sizeof(Addr));
memPort->writeBlob(array_ptr, (uint8_t*)&data_ptr, sizeof(Addr));
}
LiveProcess::LiveProcess(const string &nm, ObjectFile *_objFile,
@ -336,7 +336,7 @@ LiveProcess::startup()
// write contents to stack
uint64_t argc = argv.size();
argc = htog(argc);
initVirtMem->writeBlobFunctional(stack_min, (uint8_t*)&argc, sizeof(uint64_t));
initVirtMem->writeBlob(stack_min, (uint8_t*)&argc, sizeof(uint64_t));
copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);

View file

@ -193,7 +193,7 @@ unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return (TheISA::IntReg)-EFAULT;
int result = unlink(path.c_str());
@ -205,12 +205,12 @@ renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
string old_name;
if (!xc->getMemPort()->tryReadStringFunctional(old_name, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(old_name, xc->getSyscallArg(0)))
return -EFAULT;
string new_name;
if (!xc->getMemPort()->tryReadStringFunctional(new_name, xc->getSyscallArg(1)))
if (!xc->getMemPort()->tryReadString(new_name, xc->getSyscallArg(1)))
return -EFAULT;
int64_t result = rename(old_name.c_str(), new_name.c_str());
@ -222,7 +222,7 @@ truncateFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
off_t length = xc->getSyscallArg(1);
@ -250,7 +250,7 @@ chownFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
/* XXX endianess */

View file

@ -109,7 +109,7 @@ class BaseBufferArg {
//
virtual bool copyIn(TranslatingPort *memport)
{
memport->readBlobFunctional(addr, bufPtr, size);
memport->readBlob(addr, bufPtr, size);
return true; // no EFAULT detection for now
}
@ -118,7 +118,7 @@ class BaseBufferArg {
//
virtual bool copyOut(TranslatingPort *memport)
{
memport->writeBlobFunctional(addr, bufPtr, size);
memport->writeBlob(addr, bufPtr, size);
return true; // no EFAULT detection for now
}
@ -370,7 +370,7 @@ openFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
if (path == "/dev/sysdev0") {
@ -417,7 +417,7 @@ chmodFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
uint32_t mode = xc->getSyscallArg(1);
@ -470,7 +470,7 @@ statFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
struct stat hostBuf;
@ -522,7 +522,7 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
struct stat hostBuf;
@ -544,7 +544,7 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
#if BSD_HOST
@ -596,7 +596,7 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
struct statfs hostBuf;
@ -646,18 +646,20 @@ writevFunc(SyscallDesc *desc, int callnum, Process *process,
return -EBADF;
}
TranslatingPort *p = xc->getMemPort();
uint64_t tiov_base = xc->getSyscallArg(1);
size_t count = xc->getSyscallArg(2);
struct iovec hiov[count];
for (int i = 0; i < count; ++i)
{
typename OS::tgt_iovec tiov;
xc->getMemPort()->readBlobFunctional(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 = gtoh(tiov.iov_len);
hiov[i].iov_base = new char [hiov[i].iov_len];
xc->getMemPort()->readBlobFunctional(gtoh(tiov.iov_base),
(uint8_t *)hiov[i].iov_base, hiov[i].iov_len);
p->readBlob(gtoh(tiov.iov_base), (uint8_t *)hiov[i].iov_base,
hiov[i].iov_len);
}
int result = writev(process->sim_fd(fd), hiov, count);
@ -770,7 +772,7 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0)))
return -EFAULT;
TypedBufferArg<typename OS::timeval [2]> tp(xc->getSyscallArg(1));