summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-01-05 15:01:00 -0800
committerGabe Black <gabeblack@google.com>2018-01-20 08:06:56 +0000
commit2a15bfd79ced20a6d4cbf0a0a4c2fbb1444b9a44 (patch)
treed1fec5a31a00928dc9d5a3f4f05394236187d19c /src/mem
parentb1ade08b2da4a0b398b69ea4eb2de35b08941826 (diff)
downloadgem5-2a15bfd79ced20a6d4cbf0a0a4c2fbb1444b9a44.tar.xz
arch, mem: Make the page table lookup function return a pointer.
This avoids having a copy in the lookup function itself, and the declaration of a lot of temporary TLB entry pointers in callers. The gpu TLB seems to have had the most dependence on the original signature of the lookup function, partially because it was relying on a somewhat unsafe copy to a TLB entry using a base class pointer type. Change-Id: I8b1cf494468163deee000002d243541657faf57f Reviewed-on: https://gem5-review.googlesource.com/7343 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/page_table.cc18
-rw-r--r--src/mem/page_table.hh4
2 files changed, 9 insertions, 13 deletions
diff --git a/src/mem/page_table.cc b/src/mem/page_table.cc
index 3854a8ccd..26cc6e537 100644
--- a/src/mem/page_table.cc
+++ b/src/mem/page_table.cc
@@ -146,29 +146,25 @@ EmulationPageTable::isUnmapped(Addr vaddr, int64_t size)
return true;
}
-bool
-EmulationPageTable::lookup(Addr vaddr, TheISA::TlbEntry &entry)
+TheISA::TlbEntry *
+EmulationPageTable::lookup(Addr vaddr)
{
Addr page_addr = pageAlign(vaddr);
-
PTableItr iter = pTable.find(page_addr);
-
if (iter == pTable.end())
- return false;
-
- entry = *iter->second;
- return true;
+ return nullptr;
+ return iter->second;
}
bool
EmulationPageTable::translate(Addr vaddr, Addr &paddr)
{
- TheISA::TlbEntry entry;
- if (!lookup(vaddr, entry)) {
+ TheISA::TlbEntry *entry = lookup(vaddr);
+ if (!entry) {
DPRINTF(MMU, "Couldn't Translate: %#x\n", vaddr);
return false;
}
- paddr = pageOffset(vaddr) + entry.pageStart();
+ paddr = pageOffset(vaddr) + entry->pageStart();
DPRINTF(MMU, "Translating: %#x->%#x\n", vaddr, paddr);
return true;
}
diff --git a/src/mem/page_table.hh b/src/mem/page_table.hh
index 30437a6f9..470a3e7d6 100644
--- a/src/mem/page_table.hh
+++ b/src/mem/page_table.hh
@@ -121,9 +121,9 @@ class EmulationPageTable : public Serializable
/**
* Lookup function
* @param vaddr The virtual address.
- * @return entry The page table entry corresponding to vaddr.
+ * @return The page table entry corresponding to vaddr.
*/
- virtual bool lookup(Addr vaddr, TheISA::TlbEntry &entry);
+ virtual TheISA::TlbEntry *lookup(Addr vaddr);
/**
* Translate function