ARM: Implement WFE/WFI/SEV semantics.
[gem5.git] / src / sim / stat_control.cc
index 25c5be1040a8f149bb99638dc0612a956882dc87..80aec224e5358ff92dcf34f6891c525802c1d2b1 100644 (file)
 #include "base/hostinfo.hh"
 #include "base/statistics.hh"
 #include "base/time.hh"
+#include "config/the_isa.hh"
+#if THE_ISA == NO_ISA
+#include "arch/noisa/cpu_dummy.hh"
+#else
 #include "cpu/base.hh"
+#endif
+
 #include "sim/eventq.hh"
+#include "sim/stat_control.hh"
 
 using namespace std;
 
-Stats::Formula hostInstRate;
-Stats::Formula hostTickRate;
-Stats::Value hostMemory;
-Stats::Value hostSeconds;
-
+Stats::Formula simSeconds;
 Stats::Value simTicks;
-Stats::Value simInsts;
 Stats::Value simFreq;
-Stats::Formula simSeconds;
 
 namespace Stats {
 
@@ -63,29 +64,42 @@ struct SimTicksReset : public Callback
 {
     void process()
     {
-        statTime.set();
-        startTick = curTick;
+        statTime.setTimer();
+        startTick = curTick();
     }
 };
 
 double
 statElapsedTime()
 {
-    Time now(true);
+    Time now;
+    now.setTimer();
+
     Time elapsed = now - statTime;
-    return elapsed();
+    return elapsed;
 }
 
 Tick
 statElapsedTicks()
 {
-    return curTick - startTick;
+    return curTick() - startTick;
 }
 
 SimTicksReset simTicksReset;
 
-void
-initSimStats()
+struct Global
+{
+    Stats::Formula hostInstRate;
+    Stats::Formula hostTickRate;
+    Stats::Value hostMemory;
+    Stats::Value hostSeconds;
+
+    Stats::Value simInsts;
+
+    Global();
+};
+
+Global::Global()
 {
     simInsts
         .functor(BaseCPU::numSimulatedInstructions)
@@ -101,7 +115,7 @@ initSimStats()
         ;
 
     simFreq
-        .scalar(Clock::Frequency)
+        .scalar(SimClock::Frequency)
         .name("sim_freq")
         .desc("Frequency of simulated ticks")
         ;
@@ -146,7 +160,13 @@ initSimStats()
     registerResetCallback(&simTicksReset);
 }
 
-class _StatEvent : public Event
+void
+initSimStats()
+{
+    static Global global;
+}
+
+class StatEvent : public Event
 {
   private:
     bool dump;
@@ -154,7 +174,7 @@ class _StatEvent : public Event
     Tick repeat;
 
   public:
-    _StatEvent(bool _dump, bool _reset, Tick _repeat)
+    StatEvent(bool _dump, bool _reset, Tick _repeat)
         : Event(Stat_Event_Pri), dump(_dump), reset(_reset), repeat(_repeat)
     {
         setFlags(AutoDelete);
@@ -170,17 +190,16 @@ class _StatEvent : public Event
             Stats::reset();
 
         if (repeat) {
-            Event *event = new _StatEvent(dump, reset, repeat);
-            mainEventQueue.schedule(event, curTick + repeat);
+            Stats::schedStatEvent(dump, reset, curTick() + repeat, repeat);
         }
     }
 };
 
 void
-StatEvent(bool dump, bool reset, Tick when, Tick repeat)
+schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
 {
-    Event *event = new _StatEvent(dump, reset, repeat);
+    Event *event = new StatEvent(dump, reset, repeat);
     mainEventQueue.schedule(event, when);
 }
 
-/* namespace Stats */ }
+} // namespace Stats