arch,sim: Merge initCPU and startupCPU.

These two functions were called in exactly one place one right after
the other, and served similar purposes.

This change merges them together, and cleans them up slightly. It also
removes checks for FullSystem, since those functions are only called
in full system to begin with.

Change-Id: I214f7d2d3f88960dccb5895c1241f61cd78716a8
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24904
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/arch/alpha/ev5.cc b/src/arch/alpha/ev5.cc
index 29910ca..4e2420d 100644
--- a/src/arch/alpha/ev5.cc
+++ b/src/arch/alpha/ev5.cc
@@ -73,11 +73,12 @@
     tc->setIntReg(16, cpuId);
     tc->setIntReg(0, cpuId);
 
-    AlphaFault *reset = new ResetFault;
+    Addr base = tc->readMiscRegNoEffect(IPR_PAL_BASE);
+    Addr offset = ResetFault().vect();
 
-    tc->pcState(tc->readMiscRegNoEffect(IPR_PAL_BASE) + reset->vect());
+    tc->pcState(base + offset);
 
-    delete reset;
+    tc->activate();
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/src/arch/alpha/utility.hh b/src/arch/alpha/utility.hh
index 46af121..a0f70a3 100644
--- a/src/arch/alpha/utility.hh
+++ b/src/arch/alpha/utility.hh
@@ -60,8 +60,6 @@
 
 // Alpha IPR register accessors
 inline bool PcPAL(Addr addr) { return addr & 0x3; }
-inline void startupCPU(ThreadContext *tc, int cpuId)
-{ tc->activate(); }
 
 ////////////////////////////////////////////////////////////////////////
 //
diff --git a/src/arch/arm/utility.cc b/src/arch/arm/utility.cc
index e3d64fa..627fc53 100644
--- a/src/arch/arm/utility.cc
+++ b/src/arch/arm/utility.cc
@@ -61,8 +61,8 @@
 
     // FPEXC.EN = 0
 
-    static Fault reset = std::make_shared<Reset>();
-    reset->invoke(tc);
+    Reset().invoke(tc);
+    tc->activate();
 }
 
 uint64_t
diff --git a/src/arch/arm/utility.hh b/src/arch/arm/utility.hh
index 538c831..d209664 100644
--- a/src/arch/arm/utility.hh
+++ b/src/arch/arm/utility.hh
@@ -95,11 +95,6 @@
     }
 }
 
-inline void startupCPU(ThreadContext *tc, int cpuId)
-{
-    tc->activate();
-}
-
 void copyRegs(ThreadContext *src, ThreadContext *dest);
 
 static inline void
diff --git a/src/arch/mips/utility.cc b/src/arch/mips/utility.cc
index 24c451d..a98b58e 100644
--- a/src/arch/mips/utility.cc
+++ b/src/arch/mips/utility.cc
@@ -218,16 +218,12 @@
 }
 
 void
-startupCPU(ThreadContext *tc, int cpuId)
+initCPU(ThreadContext *tc, int cpuId)
 {
     tc->activate();
 }
 
 void
-initCPU(ThreadContext *tc, int cpuId)
-{}
-
-void
 copyRegs(ThreadContext *src, ThreadContext *dest)
 {
     // First loop through the integer registers.
diff --git a/src/arch/mips/utility.hh b/src/arch/mips/utility.hh
index 0cd066f..67fe3a4 100644
--- a/src/arch/mips/utility.hh
+++ b/src/arch/mips/utility.hh
@@ -103,7 +103,6 @@
 //
 // CPU Utility
 //
-void startupCPU(ThreadContext *tc, int cpuId);
 void initCPU(ThreadContext *tc, int cpuId);
 
 void copyRegs(ThreadContext *src, ThreadContext *dest);
diff --git a/src/arch/null/utility.hh b/src/arch/null/utility.hh
index d92e552..69055c7 100644
--- a/src/arch/null/utility.hh
+++ b/src/arch/null/utility.hh
@@ -43,13 +43,16 @@
 #include "base/types.hh"
 #include "cpu/thread_context.hh"
 
-namespace NullISA {
+namespace NullISA
+{
 
-inline uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size,
-                            bool fp) { return 0; }
+static inline uint64_t
+getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
+{
+    return 0;
+}
 
 inline void initCPU(ThreadContext *tc, int cpuId) {}
-inline void startupCPU(ThreadContext *tc, int cpuId) {}
 
 }
 
diff --git a/src/arch/power/utility.hh b/src/arch/power/utility.hh
index b41533e..3ae1d82 100644
--- a/src/arch/power/utility.hh
+++ b/src/arch/power/utility.hh
@@ -49,14 +49,7 @@
     return retPC;
 }
 
-inline void
-startupCPU(ThreadContext *tc, int cpuId)
-{
-    tc->activate();
-}
-
-void
-copyRegs(ThreadContext *src, ThreadContext *dest);
+void copyRegs(ThreadContext *src, ThreadContext *dest);
 
 static inline void
 copyMiscRegs(ThreadContext *src, ThreadContext *dest)
diff --git a/src/arch/riscv/utility.cc b/src/arch/riscv/utility.cc
index 6e21a04..949d7c6 100644
--- a/src/arch/riscv/utility.cc
+++ b/src/arch/riscv/utility.cc
@@ -37,8 +37,8 @@
 
 void initCPU(ThreadContext *tc, int cpuId)
 {
-    static Fault reset = std::make_shared<Reset>();
-    reset->invoke(tc);
+    Reset().invoke(tc);
+    tc->activate();
 }
 
-}
\ No newline at end of file
+}
diff --git a/src/arch/riscv/utility.hh b/src/arch/riscv/utility.hh
index 6c0fcc1..f6e1f34 100644
--- a/src/arch/riscv/utility.hh
+++ b/src/arch/riscv/utility.hh
@@ -117,11 +117,6 @@
     return 0;
 }
 
-inline void startupCPU(ThreadContext *tc, int cpuId)
-{
-    tc->activate();
-}
-
 inline void
 copyRegs(ThreadContext *src, ThreadContext *dest)
 {
diff --git a/src/arch/sparc/faults.hh b/src/arch/sparc/faults.hh
index 2c44d51..b3827fc 100644
--- a/src/arch/sparc/faults.hh
+++ b/src/arch/sparc/faults.hh
@@ -99,7 +99,8 @@
 
 class PowerOnReset : public SparcFault<PowerOnReset>
 {
-    void invoke(ThreadContext * tc, const StaticInstPtr &inst =
+  public:
+    void invoke(ThreadContext *tc, const StaticInstPtr &inst =
                 StaticInst::nullStaticInstPtr);
 };
 
diff --git a/src/arch/sparc/utility.cc b/src/arch/sparc/utility.cc
index 5b05eaf..245f455 100644
--- a/src/arch/sparc/utility.cc
+++ b/src/arch/sparc/utility.cc
@@ -257,9 +257,12 @@
 void
 initCPU(ThreadContext *tc, int cpuId)
 {
-    static Fault por = std::make_shared<PowerOnReset>();
-    if (cpuId == 0)
-        por->invoke(tc);
+    // Other CPUs will get activated by IPIs.
+    if (cpuId != 0)
+        return;
+
+    PowerOnReset().invoke(tc);
+    tc->activate();
 }
 
 } // namespace SPARC_ISA
diff --git a/src/arch/sparc/utility.hh b/src/arch/sparc/utility.hh
index 48476cb..74e0c11 100644
--- a/src/arch/sparc/utility.hh
+++ b/src/arch/sparc/utility.hh
@@ -64,14 +64,6 @@
 
 void initCPU(ThreadContext *tc, int cpuId);
 
-inline void
-startupCPU(ThreadContext *tc, int cpuId)
-{
-    // Other CPUs will get activated by IPIs
-    if (cpuId == 0 || !FullSystem)
-        tc->activate();
-}
-
 void copyRegs(ThreadContext *src, ThreadContext *dest);
 
 void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
diff --git a/src/arch/x86/utility.cc b/src/arch/x86/utility.cc
index 75f242d..21765ce 100644
--- a/src/arch/x86/utility.cc
+++ b/src/arch/x86/utility.cc
@@ -75,11 +75,8 @@
 initCPU(ThreadContext *tc, int cpuId)
 {
     InitInterrupt(0).invoke(tc);
-}
 
-void startupCPU(ThreadContext *tc, int cpuId)
-{
-    if (cpuId == 0 || !FullSystem) {
+    if (cpuId == 0) {
         tc->activate();
     } else {
         // This is an application processor (AP). It should be initialized to
diff --git a/src/arch/x86/utility.hh b/src/arch/x86/utility.hh
index c88a4c7..88c7a17 100644
--- a/src/arch/x86/utility.hh
+++ b/src/arch/x86/utility.hh
@@ -71,8 +71,6 @@
 
     void initCPU(ThreadContext *tc, int cpuId);
 
-    void startupCPU(ThreadContext *tc, int cpuId);
-
     void copyRegs(ThreadContext *src, ThreadContext *dest);
 
     void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
diff --git a/src/sim/system.cc b/src/sim/system.cc
index e59c404..368eb54 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -349,10 +349,8 @@
 System::initState()
 {
     if (FullSystem) {
-        for (auto *tc: threadContexts) {
+        for (auto *tc: threadContexts)
             TheISA::initCPU(tc, tc->contextId());
-            TheISA::startupCPU(tc, tc->contextId());
-        }
         // Moved from the constructor to here since it relies on the
         // address map being resolved in the interconnect
         /**