cpu: Consolidate and move the CPU's calls to TheISA::initCPU.
authorGabe Black <gabeblack@google.com>
Thu, 9 Jan 2020 10:10:15 +0000 (02:10 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 23 Jan 2020 00:51:57 +0000 (00:51 +0000)
TheISA::initCPU is basically an ISA specific implementation of reset
logic on architectural state. As such, it only needs to be called if
we're not going to load a checkpoint, ie in initState.

Also, since the implementation was the same across all CPUs, this
change collapses all the individual implementations down into the base
CPU class.

Change-Id: Id68133fd7f31619c90bf7b3aad35ae20871acaa4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24189
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/cpu/base.cc
src/cpu/base.hh
src/cpu/kvm/base.cc
src/cpu/minor/cpu.cc
src/cpu/o3/cpu.cc
src/cpu/simple/base.cc

index ac0c7ac5b75f30c5a3cd78fcdaf703cd76a87801..5d6a85703d3d7f6120b45ca25c109d6fbef1117b 100644 (file)
@@ -320,6 +320,15 @@ BaseCPU::init()
     }
 }
 
+void
+BaseCPU::initState()
+{
+    if (FullSystem && !params()->switched_out) {
+        for (auto *tc: threadContexts)
+            TheISA::initCPU(tc, tc->contextId());
+    }
+}
+
 void
 BaseCPU::startup()
 {
index 5b15f41860d3c3ec9a974a538e225bf068b05a08..f47bc8e7c2cf0f9abe5ad1c46314821f54a92b37 100644 (file)
@@ -314,6 +314,7 @@ class BaseCPU : public ClockedObject
     virtual ~BaseCPU();
 
     void init() override;
+    void initState() override;
     void startup() override;
     void regStats() override;
 
index 83cb04f47f8e3ac42cb04a36d8ed72f940d2df7f..cda98b4a5895eff897122914e63bc2237c1c5765 100644 (file)
@@ -114,10 +114,6 @@ BaseKvmCPU::init()
         fatal("KVM: Multithreading not supported");
 
     tc->initMemProxies(tc);
-
-    // initialize CPU, including PC
-    if (FullSystem && !switchedOut())
-        TheISA::initCPU(tc, tc->contextId());
 }
 
 void
index ddba0cdaa289ac5aedf6563c57b7ddc02a18d3f6..5edc570c72aefd0630bfb1531e3ced443658b442 100644 (file)
@@ -108,17 +108,6 @@ MinorCPU::init()
 
         tc->initMemProxies(tc);
     }
-
-    /* Initialise CPUs (== threads in the ISA) */
-    if (FullSystem && !params()->switched_out) {
-        for (ThreadID thread_id = 0; thread_id < threads.size(); thread_id++)
-        {
-            ThreadContext *tc = getContext(thread_id);
-
-            /* Initialize CPU, including PC */
-            TheISA::initCPU(tc, cpuId());
-        }
-    }
 }
 
 /** Stats interface from SimObject (by way of BaseCPU) */
index 996f6360bc434f6c3c1200384754cddb89dc42fc..e4f1c046454112c4f5c042a4cca5350818e16030 100644 (file)
@@ -599,13 +599,6 @@ FullO3CPU<Impl>::init()
         thread[tid]->initMemProxies(thread[tid]->getTC());
     }
 
-    if (FullSystem && !params()->switched_out) {
-        for (ThreadID tid = 0; tid < numThreads; tid++) {
-            ThreadContext *src_tc = threadContexts[tid];
-            TheISA::initCPU(src_tc, src_tc->contextId());
-        }
-    }
-
     // Clear noSquashFromTC.
     for (int tid = 0; tid < numThreads; ++tid)
         thread[tid]->noSquashFromTC = false;
index 566533c73173e24964cd258c4d5a87d84baa88ad..06dd7739057aa570ad7cee86c32737ac46d9294c 100644 (file)
@@ -130,11 +130,6 @@ BaseSimpleCPU::init()
     for (auto tc : threadContexts) {
         // Initialise the ThreadContext's memory proxies
         tc->initMemProxies(tc);
-
-        if (FullSystem && !params()->switched_out) {
-            // initialize CPU, including PC
-            TheISA::initCPU(tc, tc->contextId());
-        }
     }
 }