x86: implements vtophys
authorJoel Hestness <hestness@cs.utexas.edu>
Mon, 7 Feb 2011 06:14:17 +0000 (22:14 -0800)
committerJoel Hestness <hestness@cs.utexas.edu>
Mon, 7 Feb 2011 06:14:17 +0000 (22:14 -0800)
Calls walker to look up virt. to phys. page mapping

src/arch/x86/pagetable_walker.hh
src/arch/x86/system.cc
src/arch/x86/vtophys.cc
src/arch/x86/vtophys.hh

index 38ce6ce021bd3551eeb4a4a937dc540afb15eff5..68f85be9356ec77c8567d2e708ca5c36504f3cd3 100644 (file)
@@ -48,6 +48,7 @@
 #include "mem/mem_object.hh"
 #include "mem/packet.hh"
 #include "params/X86PagetableWalker.hh"
+#include "sim/faults.hh"
 
 class ThreadContext;
 
index 3fc16e72947538a572bb637866c1394c8e0aba4b..20ee484fb9888fbe838acee1b5ad0ac66fe2e507 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "arch/x86/bios/smbios.hh"
 #include "arch/x86/bios/intelmp.hh"
+#include "arch/x86/isa_traits.hh"
 #include "arch/x86/regs/misc.hh"
 #include "arch/x86/system.hh"
 #include "arch/vtophys.hh"
index e0bb6c993bb3dc874c4db84e4e2331a8e54c5092..3a69325640dff4e10e65fb9b4020c92a80eb0f15 100644 (file)
 
 #include <string>
 
+#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"
+#include "sim/fault.hh"
 
 using namespace std;
 
 namespace X86ISA
 {
-    Addr vtophys(Addr vaddr)
+    Addr
+    vtophys(Addr vaddr)
     {
+#if FULL_SYSTEM
+        panic("Need access to page tables\n");
+#endif
         return vaddr;
     }
 
-    Addr vtophys(ThreadContext *tc, Addr addr)
+    Addr
+    vtophys(ThreadContext *tc, Addr vaddr)
     {
-        return addr;
+#if FULL_SYSTEM
+        Walker *walker = tc->getDTBPtr()->getWalker();
+        Addr size;
+        Addr addr = vaddr;
+        Fault fault = walker->startFunctional(tc, addr, size, BaseTLB::Read);
+        if (fault != NoFault)
+            panic("vtophys page walk returned fault\n");
+        Addr masked_addr = vaddr & (size - 1);
+        Addr paddr = addr | masked_addr;
+        DPRINTF(VtoPhys, "vtophys(%#x) -> %#x\n", vaddr, paddr);
+        return paddr;
+#endif
+        return vaddr;
     }
 }
index 8b8ddf46780d625e4931c149d89a337f87bc8eb0..10522313cac0e0256e94ac6fb9a1a7d543bb1cac 100644 (file)
 #ifndef __ARCH_X86_VTOPHYS_HH__
 #define __ARCH_X86_VTOPHYS_HH__
 
-#include "arch/x86/isa_traits.hh"
-#include "arch/x86/pagetable.hh"
 #include "base/types.hh"
 
 class ThreadContext;
-class FunctionalPort;
 
 namespace X86ISA
 {