pid(_pid), _name(__name)
{
assert(isPowerOf2(pageSize));
- pTableCache[0].vaddr = 0;
- pTableCache[1].vaddr = 0;
- pTableCache[2].vaddr = 0;
+ pTableCache[0].valid = false;
+ pTableCache[1].valid = false;
+ pTableCache[2].valid = false;
}
PageTable::~PageTable()
}
pTable[vaddr] = TheISA::TlbEntry(pid, vaddr, paddr);
+ eraseCacheEntry(vaddr);
updateCache(vaddr, pTable[vaddr]);
}
}
pTable[new_vaddr] = pTable[vaddr];
pTable.erase(vaddr);
+ eraseCacheEntry(vaddr);
pTable[new_vaddr].updateVaddr(new_vaddr);
updateCache(new_vaddr, pTable[new_vaddr]);
}
for (; size > 0; size -= pageSize, vaddr += pageSize) {
assert(pTable.find(vaddr) != pTable.end());
-
pTable.erase(vaddr);
+ eraseCacheEntry(vaddr);
}
}
{
Addr page_addr = pageAlign(vaddr);
- if (pTableCache[0].vaddr == page_addr) {
+ if (pTableCache[0].valid && pTableCache[0].vaddr == page_addr) {
entry = pTableCache[0].entry;
return true;
}
- if (pTableCache[1].vaddr == page_addr) {
+ if (pTableCache[1].valid && pTableCache[1].vaddr == page_addr) {
entry = pTableCache[1].entry;
return true;
}
- if (pTableCache[2].vaddr == page_addr) {
+ if (pTableCache[2].valid && pTableCache[2].vaddr == page_addr) {
entry = pTableCache[2].entry;
return true;
}
PTable pTable;
struct cacheElement {
+ bool valid;
Addr vaddr;
TheISA::TlbEntry entry;
};
{
pTableCache[2].entry = pTableCache[1].entry;
pTableCache[2].vaddr = pTableCache[1].vaddr;
+ pTableCache[2].valid = pTableCache[1].valid;
+
pTableCache[1].entry = pTableCache[0].entry;
pTableCache[1].vaddr = pTableCache[0].vaddr;
+ pTableCache[1].valid = pTableCache[0].valid;
+
pTableCache[0].entry = entry;
pTableCache[0].vaddr = vaddr;
+ pTableCache[0].valid = true;
}
+ /**
+ * Erase an entry from the page table cache.
+ * @param vaddr virtual address (page aligned) to check
+ */
+ inline void eraseCacheEntry(Addr vaddr)
+ {
+ // Invalidate cached entries if necessary
+ if (pTableCache[0].valid && pTableCache[0].vaddr == vaddr) {
+ pTableCache[0].valid = false;
+ } else if (pTableCache[1].valid && pTableCache[1].vaddr == vaddr) {
+ pTableCache[1].valid = false;
+ } else if (pTableCache[2].valid && pTableCache[2].vaddr == vaddr) {
+ pTableCache[2].valid = false;
+ }
+ }
void serialize(std::ostream &os);