#include <string>
+#include "arch/isa_traits.hh"
#include "base/chunk_generator.hh"
#include "config/the_isa.hh"
#include "mem/page_table.hh"
#include "mem/se_translating_port_proxy.hh"
#include "sim/process.hh"
+#include "sim/system.hh"
using namespace TheISA;
-SETranslatingPortProxy::SETranslatingPortProxy(Port& port, Process *p,
+SETranslatingPortProxy::SETranslatingPortProxy(MasterPort& port, Process *p,
AllocType alloc)
- : PortProxy(port), pTable(p->pTable), process(p),
- allocating(alloc)
+ : PortProxy(port, p->system->cacheLineSize()), pTable(p->pTable),
+ process(p), allocating(alloc)
{ }
SETranslatingPortProxy::~SETranslatingPortProxy()
{ }
bool
-SETranslatingPortProxy::tryReadBlob(Addr addr, uint8_t *p, int size)
+SETranslatingPortProxy::tryReadBlob(Addr addr, uint8_t *p, int size) const
{
- Addr paddr;
int prevSize = 0;
- for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) {
+ for (ChunkGenerator gen(addr, size, PageBytes); !gen.done(); gen.next()) {
+ Addr paddr;
if (!pTable->translate(gen.addr(),paddr))
return false;
}
void
-SETranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size)
+SETranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size) const
{
if (!tryReadBlob(addr, p, size))
fatal("readBlob(0x%x, ...) failed", addr);
bool
-SETranslatingPortProxy::tryWriteBlob(Addr addr, uint8_t *p, int size)
+SETranslatingPortProxy::tryWriteBlob(Addr addr, const uint8_t *p,
+ int size) const
{
-
- Addr paddr;
int prevSize = 0;
- for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) {
+ for (ChunkGenerator gen(addr, size, PageBytes); !gen.done(); gen.next()) {
+ Addr paddr;
if (!pTable->translate(gen.addr(), paddr)) {
if (allocating == Always) {
- process->allocateMem(roundDown(gen.addr(), VMPageSize),
- VMPageSize);
+ process->allocateMem(roundDown(gen.addr(), PageBytes),
+ PageBytes);
} else if (allocating == NextPage) {
// check if we've accessed the next page on the stack
if (!process->fixupStackFault(gen.addr()))
void
-SETranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size)
+SETranslatingPortProxy::writeBlob(Addr addr, const uint8_t *p, int size) const
{
if (!tryWriteBlob(addr, p, size))
fatal("writeBlob(0x%x, ...) failed", addr);
}
bool
-SETranslatingPortProxy::tryMemsetBlob(Addr addr, uint8_t val, int size)
+SETranslatingPortProxy::tryMemsetBlob(Addr addr, uint8_t val, int size) const
{
- Addr paddr;
-
- for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) {
+ for (ChunkGenerator gen(addr, size, PageBytes); !gen.done(); gen.next()) {
+ Addr paddr;
if (!pTable->translate(gen.addr(), paddr)) {
if (allocating == Always) {
- process->allocateMem(roundDown(gen.addr(), VMPageSize),
- VMPageSize);
+ process->allocateMem(roundDown(gen.addr(), PageBytes),
+ PageBytes);
pTable->translate(gen.addr(), paddr);
} else {
return false;
}
void
-SETranslatingPortProxy::memsetBlob(Addr addr, uint8_t val, int size)
+SETranslatingPortProxy::memsetBlob(Addr addr, uint8_t val, int size) const
{
if (!tryMemsetBlob(addr, val, size))
fatal("memsetBlob(0x%x, ...) failed", addr);
bool
-SETranslatingPortProxy::tryWriteString(Addr addr, const char *str)
+SETranslatingPortProxy::tryWriteString(Addr addr, const char *str) const
{
- Addr paddr,vaddr;
uint8_t c;
- vaddr = addr;
+ Addr vaddr = addr;
do {
c = *str++;
- if (!pTable->translate(vaddr++,paddr))
+ Addr paddr;
+
+ if (!pTable->translate(vaddr++, paddr))
return false;
PortProxy::writeBlob(paddr, &c, 1);
}
void
-SETranslatingPortProxy::writeString(Addr addr, const char *str)
+SETranslatingPortProxy::writeString(Addr addr, const char *str) const
{
if (!tryWriteString(addr, str))
fatal("writeString(0x%x, ...) failed", addr);
}
bool
-SETranslatingPortProxy::tryReadString(std::string &str, Addr addr)
+SETranslatingPortProxy::tryReadString(std::string &str, Addr addr) const
{
- Addr paddr,vaddr;
uint8_t c;
- vaddr = addr;
+ Addr vaddr = addr;
- do {
- if (!pTable->translate(vaddr++,paddr))
+ while (true) {
+ Addr paddr;
+
+ if (!pTable->translate(vaddr++, paddr))
return false;
PortProxy::readBlob(paddr, &c, 1);
+ if (c == '\0')
+ break;
+
str += c;
- } while (c);
+ }
return true;
}
void
-SETranslatingPortProxy::readString(std::string &str, Addr addr)
+SETranslatingPortProxy::readString(std::string &str, Addr addr) const
{
if (!tryReadString(str, addr))
fatal("readString(0x%x, ...) failed", addr);