summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2007-06-05 01:03:43 -0400
committerAli Saidi <saidi@eecs.umich.edu>2007-06-05 01:03:43 -0400
commitc5a946efea8bc9c2c9245be1cbbee92af4def09c (patch)
tree51a8ffa3340af142590021faa998a4ae558f22a2
parentdba02f703b1e7fc8639e0342bd572d9572520331 (diff)
parent85986e9dff0e3dc7e54adf4da54a7c099c7e815f (diff)
downloadgem5-c5a946efea8bc9c2c9245be1cbbee92af4def09c.tar.xz
Merge zizzer.eecs.umich.edu:/z/m5/Bitkeeper/newmem
into zizzer.eecs.umich.edu:/tmp/newmem --HG-- extra : convert_revision : e0721f59cce9cb356b53977e21bd4a7c779c217d
-rw-r--r--src/mem/page_table.cc22
-rw-r--r--src/mem/page_table.hh16
2 files changed, 24 insertions, 14 deletions
diff --git a/src/mem/page_table.cc b/src/mem/page_table.cc
index 96bc23793..b29a07078 100644
--- a/src/mem/page_table.cc
+++ b/src/mem/page_table.cc
@@ -90,8 +90,6 @@ PageTable::page_check(Addr addr, int64_t size) const
}
-
-
void
PageTable::allocate(Addr vaddr, int64_t size)
{
@@ -109,12 +107,7 @@ PageTable::allocate(Addr vaddr, int64_t size)
}
pTable[vaddr] = system->new_page();
- pTableCache[2].paddr = pTableCache[1].paddr;
- pTableCache[2].vaddr = pTableCache[1].vaddr;
- pTableCache[1].paddr = pTableCache[0].paddr;
- pTableCache[1].vaddr = pTableCache[0].vaddr;
- pTableCache[0].paddr = pTable[vaddr];
- pTableCache[0].vaddr = vaddr;
+ updateCache(vaddr, pTable[vaddr]);
}
}
@@ -126,16 +119,16 @@ PageTable::translate(Addr vaddr, Addr &paddr)
Addr page_addr = pageAlign(vaddr);
paddr = 0;
- if (pTableCache[0].vaddr == vaddr) {
- paddr = pTableCache[0].paddr;
+ if (pTableCache[0].vaddr == page_addr) {
+ paddr = pTableCache[0].paddr + pageOffset(vaddr);
return true;
}
- if (pTableCache[1].vaddr == vaddr) {
- paddr = pTableCache[1].paddr;
+ if (pTableCache[1].vaddr == page_addr) {
+ paddr = pTableCache[1].paddr + pageOffset(vaddr);
return true;
}
- if (pTableCache[2].vaddr == vaddr) {
- paddr = pTableCache[2].paddr;
+ if (pTableCache[2].vaddr == page_addr) {
+ paddr = pTableCache[2].paddr + pageOffset(vaddr);
return true;
}
@@ -145,6 +138,7 @@ PageTable::translate(Addr vaddr, Addr &paddr)
return false;
}
+ updateCache(page_addr, iter->second);
paddr = iter->second + pageOffset(vaddr);
return true;
}
diff --git a/src/mem/page_table.hh b/src/mem/page_table.hh
index 0e2b1f58c..64c824238 100644
--- a/src/mem/page_table.hh
+++ b/src/mem/page_table.hh
@@ -95,6 +95,22 @@ class PageTable
*/
Fault translate(RequestPtr &req);
+ /**
+ * Update the page table cache.
+ * @param vaddr virtual address (page aligned) to check
+ * @param paddr physical address (page aligned) to return
+ */
+ inline void updateCache(Addr vaddr, Addr paddr)
+ {
+ pTableCache[2].paddr = pTableCache[1].paddr;
+ pTableCache[2].vaddr = pTableCache[1].vaddr;
+ pTableCache[1].paddr = pTableCache[0].paddr;
+ pTableCache[1].vaddr = pTableCache[0].vaddr;
+ pTableCache[0].paddr = paddr;
+ pTableCache[0].vaddr = vaddr;
+ }
+
+
void serialize(std::ostream &os);
void unserialize(Checkpoint *cp, const std::string &section);
};