diff -r 3a195e2117c0 -r 69ef0954691c src/arch/x86/vtophys.cc --- a/src/arch/x86/vtophys.cc Thu Jan 20 15:35:29 2011 -0800 +++ b/src/arch/x86/vtophys.cc Thu Jan 20 16:36:27 2011 -0800 @@ -39,7 +39,13 @@ #include +#include "arch/x86/faults.hh" +#include "arch/x86/pagetable_walker.hh" +#include "arch/x86/tlb.hh" #include "arch/x86/vtophys.hh" +#include "base/trace.hh" +#include "config/full_system.hh" +#include "cpu/thread_context.hh" using namespace std; @@ -47,11 +53,28 @@ { Addr vtophys(Addr vaddr) { +#if FULL_SYSTEM + panic("Need access to page tables\n"); +#endif return vaddr; } Addr vtophys(ThreadContext *tc, Addr addr) { +#if FULL_SYSTEM + RequestPtr req = new Request; + req->setVirt(0, addr, 0, 0, 0); + Walker *walker = tc->getDTBPtr()->getWalker(); + FunctionalTranslation trans; + Fault fault = walker->startFunctional(tc, &trans, req, BaseTLB::Read); + if (fault != NoFault) + panic("vtophys page walk returned fault\n"); + Addr masked_addr = addr & (trans.getSize() - 1); + Addr paddr = req->getPaddr() | masked_addr; + delete req; + DPRINTF(VtoPhys, "vtophys(%#x) -> %#x\n", addr, paddr); + return paddr; +#endif return addr; } } diff -r 3a195e2117c0 -r 69ef0954691c src/arch/x86/vtophys.hh --- a/src/arch/x86/vtophys.hh Thu Jan 20 15:35:29 2011 -0800 +++ b/src/arch/x86/vtophys.hh Thu Jan 20 16:36:27 2011 -0800 @@ -43,6 +43,7 @@ #include "arch/x86/isa_traits.hh" #include "arch/x86/pagetable.hh" #include "base/types.hh" +#include "sim/tlb.hh" class ThreadContext; class FunctionalPort; @@ -50,6 +51,38 @@ namespace X86ISA { +class FunctionalTranslation : public BaseTLB::Translation +{ + private: + int size; + + public: + FunctionalTranslation() + : size(0) + { + } + + int + getSize() + { + return size; + } + + void + setSize(int _size) + { + size = _size; + } + + void + finish(Fault fault, RequestPtr req, ThreadContext *tc, + BaseTLB::Mode mode) + { + delete this; + } +}; + + Addr vtophys(Addr vaddr); Addr vtophys(ThreadContext *tc, Addr vaddr);