diff options
Diffstat (limited to 'mem')
-rw-r--r-- | mem/physical.hh | 2 | ||||
-rw-r--r-- | mem/translating_port.cc | 28 | ||||
-rw-r--r-- | mem/translating_port.hh | 3 |
3 files changed, 21 insertions, 12 deletions
diff --git a/mem/physical.hh b/mem/physical.hh index 90515d7d1..854886a27 100644 --- a/mem/physical.hh +++ b/mem/physical.hh @@ -80,7 +80,7 @@ class PhysicalMemory : public Memory struct MemResponseEvent : public Event { - Packet pkt; + Packet &pkt; MemoryPort *memoryPort; MemResponseEvent(Packet &pkt, MemoryPort *memoryPort); diff --git a/mem/translating_port.cc b/mem/translating_port.cc index 052d350b9..e385a74b6 100644 --- a/mem/translating_port.cc +++ b/mem/translating_port.cc @@ -47,29 +47,37 @@ TranslatingPort::readBlobFunctional(Addr addr, uint8_t *p, int size) for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) { - if (!pTable->translate(gen.addr(),paddr)) - return Machine_Check_Fault; + if (!pTable->translate(gen.addr(),paddr)) + return Machine_Check_Fault; - port->readBlobFunctional(paddr, p + prevSize, gen.size()); - prevSize += gen.size(); + port->readBlobFunctional(paddr, p + prevSize, gen.size()); + prevSize += gen.size(); } return No_Fault; } Fault -TranslatingPort::writeBlobFunctional(Addr addr, uint8_t *p, int size) +TranslatingPort::writeBlobFunctional(Addr addr, uint8_t *p, int size, + bool alloc) { Addr paddr; int prevSize = 0; for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) { - if (!pTable->translate(gen.addr(),paddr)) - return Machine_Check_Fault; - - port->writeBlobFunctional(paddr, p + prevSize, gen.size()); - prevSize += gen.size(); + if (!pTable->translate(gen.addr(), paddr)) { + if (alloc) { + pTable->allocate(roundDown(gen.addr(), VMPageSize), + VMPageSize); + pTable->translate(gen.addr(), paddr); + } else { + return Machine_Check_Fault; + } + } + + port->writeBlobFunctional(paddr, p + prevSize, gen.size()); + prevSize += gen.size(); } return No_Fault; diff --git a/mem/translating_port.hh b/mem/translating_port.hh index 671c32237..3d77b2c2b 100644 --- a/mem/translating_port.hh +++ b/mem/translating_port.hh @@ -49,7 +49,8 @@ class TranslatingPort public: Fault readBlobFunctional(Addr addr, uint8_t *p, int size); - Fault writeBlobFunctional(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); Fault writeStringFunctional(Addr addr, const char *str); Fault readStringFunctional(std::string &str, Addr addr); |