sim: Move the BaseTLB to src/arch/generic/
[gem5.git] / src / arch / mips / utility.cc
index fc6e9e2f9250b6ad30584671eb0270a09021958a..80047fbfdca3b439f2ca14822d867dcca126d664 100644 (file)
 #include <cmath>
 
 #include "arch/mips/isa_traits.hh"
+#include "arch/mips/registers.hh"
 #include "arch/mips/utility.hh"
+#include "arch/mips/vtophys.hh"
 #include "base/bitfield.hh"
 #include "base/misc.hh"
-#include "config/full_system.hh"
 #include "cpu/static_inst.hh"
 #include "cpu/thread_context.hh"
-#include "sim/serialize.hh"
-
-#if FULL_SYSTEM
-#include "arch/mips/registers.hh"
-#include "arch/mips/vtophys.hh"
 #include "mem/fs_translating_port_proxy.hh"
-#endif
+#include "sim/serialize.hh"
 
 
 using namespace MipsISA;
@@ -54,23 +50,8 @@ namespace MipsISA {
 uint64_t
 getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
 {
-#if FULL_SYSTEM
-    if (number < 4) {
-        if (fp)
-            return tc->readFloatRegBits(FirstArgumentReg + number);
-        else
-            return tc->readIntReg(FirstArgumentReg + number);
-    } else {
-        Addr sp = tc->readIntReg(StackPointerReg);
-        FSTranslatingPortProxy* vp = tc->getVirtProxy();
-        uint64_t arg = vp->read<uint64_t>(sp +
-                (number - 4) * sizeof(uint64_t));
-        return arg;
-    }
-#else
-    panic("getArgument() is Full system only\n");
+    panic("getArgument() not implemented\n");
     M5_DUMMY_RETURN
-#endif
 }
 
 uint64_t
@@ -250,13 +231,33 @@ zeroRegisters(CPU *cpu)
 void
 startupCPU(ThreadContext *tc, int cpuId)
 {
-    tc->activate(0/*tc->threadId()*/);
+    tc->activate();
 }
 
+void
+initCPU(ThreadContext *tc, int cpuId)
+{}
+
 void
 copyRegs(ThreadContext *src, ThreadContext *dest)
 {
-    panic("Copy Regs Not Implemented Yet\n");
+    // First loop through the integer registers.
+    for (int i = 0; i < NumIntRegs; i++)
+        dest->setIntRegFlat(i, src->readIntRegFlat(i));
+
+    // Then loop through the floating point registers.
+    for (int i = 0; i < NumFloatRegs; i++)
+        dest->setFloatRegFlat(i, src->readFloatRegFlat(i));
+
+    // Would need to add condition-code regs if implemented
+    assert(NumCCRegs == 0);
+
+    // Copy misc. registers
+    for (int i = 0; i < NumMiscRegs; i++)
+        dest->setMiscRegNoEffect(i, src->readMiscRegNoEffect(i));
+
+    // Copy over the PC State
+    dest->pcState(src->pcState());
 }
 
 void