*/
#include <string>
-#include "arch/faults.hh"
#include "base/chunk_generator.hh"
#include "mem/port.hh"
#include "mem/translating_port.hh"
TranslatingPort::~TranslatingPort()
{ }
-Fault
-TranslatingPort::readBlobFunctional(Addr addr, uint8_t *p, int size)
+bool
+TranslatingPort::tryReadBlobFunctional(Addr addr, uint8_t *p, int size)
{
Addr paddr;
int prevSize = 0;
for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) {
if (!pTable->translate(gen.addr(),paddr))
- return genMachineCheckFault();
+ return false;
port->readBlobFunctional(paddr, p + prevSize, gen.size());
prevSize += gen.size();
}
- return NoFault;
+ return true;
}
-Fault
-TranslatingPort::writeBlobFunctional(Addr addr, uint8_t *p, int size,
- bool alloc)
+void
+TranslatingPort::readBlobFunctional(Addr addr, uint8_t *p, int size)
+{
+ if (!tryReadBlobFunctional(addr, p, size))
+ fatal("readBlobFunctional(0x%x, ...) failed", addr);
+}
+
+
+bool
+TranslatingPort::tryWriteBlobFunctional(Addr addr, uint8_t *p, int size,
+ bool alloc)
{
+
Addr paddr;
int prevSize = 0;
VMPageSize);
pTable->translate(gen.addr(), paddr);
} else {
- return genMachineCheckFault();
+ return false;
}
}
prevSize += gen.size();
}
- return NoFault;
+ return true;
}
-Fault
-TranslatingPort::memsetBlobFunctional(Addr addr, uint8_t val, int size,
- bool alloc)
+void
+TranslatingPort::writeBlobFunctional(Addr addr, uint8_t *p, int size,
+ bool alloc)
+{
+ if (!tryWriteBlobFunctional(addr, p, size, alloc))
+ fatal("writeBlobFunctional(0x%x, ...) failed", addr);
+}
+
+bool
+TranslatingPort::tryMemsetBlobFunctional(Addr addr, uint8_t val, int size,
+ bool alloc)
{
Addr paddr;
VMPageSize);
pTable->translate(gen.addr(), paddr);
} else {
- return genMachineCheckFault();
+ return false;
}
}
port->memsetBlobFunctional(paddr, val, gen.size());
}
- return NoFault;
+ return true;
}
+void
+TranslatingPort::memsetBlobFunctional(Addr addr, uint8_t val, int size,
+ bool alloc)
+{
+ if (!tryMemsetBlobFunctional(addr, val, size, alloc))
+ fatal("memsetBlobFunctional(0x%x, ...) failed", addr);
+}
-Fault
-TranslatingPort::writeStringFunctional(Addr addr, const char *str)
+
+bool
+TranslatingPort::tryWriteStringFunctional(Addr addr, const char *str)
{
Addr paddr,vaddr;
uint8_t c;
do {
c = *str++;
if (!pTable->translate(vaddr++,paddr))
- return genMachineCheckFault();
+ return false;
port->writeBlobFunctional(paddr, &c, 1);
} while (c);
- return NoFault;
+ return true;
}
-Fault
-TranslatingPort::readStringFunctional(std::string &str, Addr addr)
+void
+TranslatingPort::writeStringFunctional(Addr addr, const char *str)
+{
+ if (!tryWriteStringFunctional(addr, str))
+ fatal("writeStringFunctional(0x%x, ...) failed", addr);
+}
+
+bool
+TranslatingPort::tryReadStringFunctional(std::string &str, Addr addr)
{
Addr paddr,vaddr;
uint8_t c;
do {
if (!pTable->translate(vaddr++,paddr))
- return genMachineCheckFault();
+ return false;
port->readBlobFunctional(paddr, &c, 1);
str += c;
} while (c);
- return NoFault;
+ return true;
+}
+
+void
+TranslatingPort::readStringFunctional(std::string &str, Addr addr)
+{
+ if (!tryReadStringFunctional(str, addr))
+ fatal("readStringFunctional(0x%x, ...) failed", addr);
}
virtual ~TranslatingPort();
public:
- Fault readBlobFunctional(Addr addr, uint8_t *p, int size);
- Fault writeBlobFunctional(Addr addr, uint8_t *p, int size,
- bool alloc = false);
- Fault memsetBlobFunctional(Addr addr, uint8_t val, int size,
- bool alloc = false);
- Fault writeStringFunctional(Addr addr, const char *str);
- Fault readStringFunctional(std::string &str, Addr addr);
+ 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);
+ 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);
};
#endif
{
string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return (TheISA::IntReg)-EFAULT;
int result = unlink(path.c_str());
{
string old_name;
- if (xc->getMemPort()->readStringFunctional(old_name, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(old_name, xc->getSyscallArg(0)))
return -EFAULT;
string new_name;
- if (xc->getMemPort()->readStringFunctional(new_name, xc->getSyscallArg(1)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(new_name, xc->getSyscallArg(1)))
return -EFAULT;
int64_t result = rename(old_name.c_str(), new_name.c_str());
{
string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
off_t length = xc->getSyscallArg(1);
{
string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
/* XXX endianess */
{
std::string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
if (path == "/dev/sysdev0") {
{
std::string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
uint32_t mode = xc->getSyscallArg(1);
{
std::string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
struct stat hostBuf;
{
std::string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
struct stat hostBuf;
{
std::string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
#if BSD_HOST
{
std::string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
struct statfs hostBuf;
{
std::string path;
- if (xc->getMemPort()->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault)
+ if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0)))
return -EFAULT;
TypedBufferArg<typename OS::timeval [2]> tp(xc->getSyscallArg(1));