* Authors: Gabe Black
*/
+#include "arch/x86/vtophys.hh"
+
#include <string>
-#include "arch/x86/vtophys.hh"
+#include "arch/x86/pagetable_walker.hh"
+#include "arch/x86/tlb.hh"
+#include "base/trace.hh"
+#include "cpu/thread_context.hh"
+#include "debug/VtoPhys.hh"
using namespace std;
namespace X86ISA
{
- Addr vtophys(Addr vaddr)
+ Addr
+ vtophys(Addr vaddr)
{
- return vaddr;
+ panic("Need access to page tables\n");
}
- Addr vtophys(ThreadContext *tc, Addr addr)
+ Addr
+ vtophys(ThreadContext *tc, Addr vaddr)
{
- return addr;
+ Walker *walker = dynamic_cast<TLB *>(tc->getDTBPtr())->getWalker();
+ unsigned logBytes;
+ Addr addr = vaddr;
+ Fault fault = walker->startFunctional(
+ tc, addr, logBytes, BaseTLB::Read);
+ if (fault != NoFault)
+ panic("vtophys page walk returned fault\n");
+ Addr masked_addr = vaddr & mask(logBytes);
+ Addr paddr = addr | masked_addr;
+ DPRINTF(VtoPhys, "vtophys(%#x) -> %#x\n", vaddr, paddr);
+ return paddr;
}
}