cpu: Correctly call parent on switchOut() and takeOverFrom()
[gem5.git] / src / cpu / thread_state.cc
index 3d58b4da4f3fa71e485315baa85db7c57ea08f4a..d0f946989d04eb84583a7436c5a351c8b988b664 100644 (file)
@@ -101,17 +101,49 @@ ThreadState::unserialize(Checkpoint *cp, const std::string &section)
 void
 ThreadState::initMemProxies(ThreadContext *tc)
 {
-    // Note that this only refers to the port on the CPU side and can
-    // safely be done at init() time even if the CPU is not connected
-    // (i.e. due to restoring from a checkpoint and later switching
-    // in.
-    if (physProxy == NULL)
-        // this cannot be done in the constructor as the thread state
+    // The port proxies only refer to the data port on the CPU side
+    // and can safely be done at init() time even if the CPU is not
+    // connected, i.e. when restoring from a checkpoint and later
+    // switching the CPU in.
+    if (FullSystem) {
+        assert(physProxy == NULL);
+        // This cannot be done in the constructor as the thread state
         // itself is created in the base cpu constructor and the
-        // getPort is a virtual function at the moment
+        // getDataPort is a virtual function
         physProxy = new PortProxy(baseCpu->getDataPort());
-    if (virtProxy == NULL)
+
+        assert(virtProxy == NULL);
         virtProxy = new FSTranslatingPortProxy(tc);
+    } else {
+        assert(proxy == NULL);
+        proxy = new SETranslatingPortProxy(baseCpu->getDataPort(),
+                                           process,
+                                           SETranslatingPortProxy::NextPage);
+    }
+}
+
+PortProxy &
+ThreadState::getPhysProxy()
+{
+    assert(FullSystem);
+    assert(physProxy != NULL);
+    return *physProxy;
+}
+
+FSTranslatingPortProxy &
+ThreadState::getVirtProxy()
+{
+    assert(FullSystem);
+    assert(virtProxy != NULL);
+    return *virtProxy;
+}
+
+SETranslatingPortProxy &
+ThreadState::getMemProxy()
+{
+    assert(!FullSystem);
+    assert(proxy != NULL);
+    return *proxy;
 }
 
 void
@@ -127,13 +159,3 @@ ThreadState::profileSample()
     if (profile)
         profile->sample(profileNode, profilePC);
 }
-
-SETranslatingPortProxy &
-ThreadState::getMemProxy()
-{
-    if (proxy == NULL)
-        proxy = new SETranslatingPortProxy(baseCpu->getDataPort(),
-                                           process,
-                                           SETranslatingPortProxy::NextPage);
-    return *proxy;
-}