fix the translating ports so it can add a page on a fault
--HG-- extra : convert_revision : 56f6f2cbf4e92b7f2dd8c9453831fab86d83ef80
This commit is contained in:
@@ -34,12 +34,14 @@
|
||||
#include "mem/port.hh"
|
||||
#include "mem/translating_port.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "sim/process.hh"
|
||||
|
||||
using namespace TheISA;
|
||||
|
||||
TranslatingPort::TranslatingPort(const std::string &_name,
|
||||
PageTable *p_table, bool alloc)
|
||||
: FunctionalPort(_name), pTable(p_table), allocating(alloc)
|
||||
Process *p, AllocType alloc)
|
||||
: FunctionalPort(_name), pTable(p->pTable), process(p),
|
||||
allocating(alloc)
|
||||
{ }
|
||||
|
||||
TranslatingPort::~TranslatingPort()
|
||||
@@ -81,13 +83,18 @@ TranslatingPort::tryWriteBlob(Addr addr, uint8_t *p, int size)
|
||||
for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) {
|
||||
|
||||
if (!pTable->translate(gen.addr(), paddr)) {
|
||||
if (allocating) {
|
||||
if (allocating == Always) {
|
||||
pTable->allocate(roundDown(gen.addr(), VMPageSize),
|
||||
VMPageSize);
|
||||
pTable->translate(gen.addr(), paddr);
|
||||
} else if (allocating == NextPage) {
|
||||
// check if we've accessed the next page on the stack
|
||||
if (!process->checkAndAllocNextPage(gen.addr()))
|
||||
panic("Page table fault when accessing virtual address %#x "
|
||||
"during functional write\n", gen.addr());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
pTable->translate(gen.addr(), paddr);
|
||||
}
|
||||
|
||||
Port::writeBlob(paddr, p + prevSize, gen.size());
|
||||
@@ -113,7 +120,7 @@ TranslatingPort::tryMemsetBlob(Addr addr, uint8_t val, int size)
|
||||
for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) {
|
||||
|
||||
if (!pTable->translate(gen.addr(), paddr)) {
|
||||
if (allocating) {
|
||||
if (allocating == Always) {
|
||||
pTable->allocate(roundDown(gen.addr(), VMPageSize),
|
||||
VMPageSize);
|
||||
pTable->translate(gen.addr(), paddr);
|
||||
|
||||
@@ -35,16 +35,25 @@
|
||||
#include "mem/port.hh"
|
||||
|
||||
class PageTable;
|
||||
class Process;
|
||||
|
||||
class TranslatingPort : public FunctionalPort
|
||||
{
|
||||
public:
|
||||
enum AllocType {
|
||||
Always,
|
||||
Never,
|
||||
NextPage
|
||||
};
|
||||
|
||||
private:
|
||||
PageTable *pTable;
|
||||
bool allocating;
|
||||
Process *process;
|
||||
AllocType allocating;
|
||||
|
||||
public:
|
||||
TranslatingPort(const std::string &_name,
|
||||
PageTable *p_table, bool alloc = false);
|
||||
Process *p, AllocType alloc);
|
||||
virtual ~TranslatingPort();
|
||||
|
||||
bool tryReadBlob(Addr addr, uint8_t *p, int size);
|
||||
|
||||
Reference in New Issue
Block a user