init: don't build files that centralize python and swig code
[gem5.git] / src / sim / pseudo_inst.cc
index 60a74b224d99394ad7ace98fe0100f6f1b87f642..7a91bfbd4d2e459f52c81f6934ed58450c157254 100644 (file)
 #include <string>
 
 #include "arch/vtophys.hh"
-#include "base/annotate.hh"
+#include "base/debug.hh"
+#include "config/full_system.hh"
+#include "config/the_isa.hh"
 #include "cpu/base.hh"
 #include "cpu/thread_context.hh"
 #include "cpu/quiesce_event.hh"
-#include "arch/kernel_stats.hh"
+#include "params/BaseCPU.hh"
 #include "sim/pseudo_inst.hh"
 #include "sim/serialize.hh"
+#include "sim/sim_events.hh"
 #include "sim/sim_exit.hh"
 #include "sim/stat_control.hh"
 #include "sim/stats.hh"
 #include "sim/system.hh"
-#include "sim/debug.hh"
+
+#if FULL_SYSTEM
+#include "arch/kernel_stats.hh"
 #include "sim/vptr.hh"
+#endif
 
 using namespace std;
 
@@ -57,6 +63,8 @@ using namespace TheISA;
 
 namespace PseudoInst {
 
+#if FULL_SYSTEM
+
 void
 arm(ThreadContext *tc)
 {
@@ -67,7 +75,7 @@ arm(ThreadContext *tc)
 void
 quiesce(ThreadContext *tc)
 {
-    if (!tc->getCpuPtr()->params->do_quiesce)
+    if (!tc->getCpuPtr()->params()->do_quiesce)
         return;
 
     DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name());
@@ -80,14 +88,14 @@ quiesce(ThreadContext *tc)
 void
 quiesceNs(ThreadContext *tc, uint64_t ns)
 {
-    if (!tc->getCpuPtr()->params->do_quiesce || ns == 0)
+    if (!tc->getCpuPtr()->params()->do_quiesce || ns == 0)
         return;
 
     EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent();
 
-    Tick resume = curTick + Clock::Int::ns * ns;
+    Tick resume = curTick + SimClock::Int::ns * ns;
 
-    quiesceEvent->reschedule(resume, true);
+    mainEventQueue.reschedule(quiesceEvent, resume, true);
 
     DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n",
             tc->getCpuPtr()->name(), ns, resume);
@@ -100,14 +108,14 @@ quiesceNs(ThreadContext *tc, uint64_t ns)
 void
 quiesceCycles(ThreadContext *tc, uint64_t cycles)
 {
-    if (!tc->getCpuPtr()->params->do_quiesce || cycles == 0)
+    if (!tc->getCpuPtr()->params()->do_quiesce || cycles == 0)
         return;
 
     EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent();
 
     Tick resume = curTick + tc->getCpuPtr()->ticks(cycles);
 
-    quiesceEvent->reschedule(resume, true);
+    mainEventQueue.reschedule(quiesceEvent, resume, true);
 
     DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n",
             tc->getCpuPtr()->name(), cycles, resume);
@@ -120,16 +128,37 @@ quiesceCycles(ThreadContext *tc, uint64_t cycles)
 uint64_t
 quiesceTime(ThreadContext *tc)
 {
-    return (tc->readLastActivate() - tc->readLastSuspend()) / Clock::Int::ns;
+    return (tc->readLastActivate() - tc->readLastSuspend()) /
+        SimClock::Int::ns;
+}
+
+#endif
+
+uint64_t
+rpns(ThreadContext *tc)
+{
+    return curTick / SimClock::Int::ns;
+}
+
+void
+wakeCPU(ThreadContext *tc, uint64_t cpuid)
+{
+    System *sys = tc->getSystemPtr();
+    ThreadContext *other_tc = sys->threadContexts[cpuid];
+    if (other_tc->status() == ThreadContext::Suspended)
+        other_tc->activate();
 }
 
 void
 m5exit(ThreadContext *tc, Tick delay)
 {
-    Tick when = curTick + delay * Clock::Int::ns;
-    schedExitSimLoop("m5_exit instruction encountered", when);
+    Tick when = curTick + delay * SimClock::Int::ns;
+    Event *event = new SimLoopExitEvent("m5_exit instruction encountered", 0);
+    mainEventQueue.schedule(event, when);
 }
 
+#if FULL_SYSTEM
+
 void
 loadsymbol(ThreadContext *tc)
 {
@@ -150,7 +179,7 @@ loadsymbol(ThreadContext *tc)
         if (buffer.empty())
             continue;
 
-        int idx = buffer.find(' ');
+        string::size_type idx = buffer.find(' ');
         if (idx == string::npos)
             continue;
 
@@ -179,52 +208,56 @@ loadsymbol(ThreadContext *tc)
 }
 
 void
-resetstats(ThreadContext *tc, Tick delay, Tick period)
+addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
 {
-    if (!tc->getCpuPtr()->params->do_statistics_insts)
-        return;
-
+    char symb[100];
+    CopyStringOut(tc, symb, symbolAddr, 100);
+    std::string symbol(symb);
 
-    Tick when = curTick + delay * Clock::Int::ns;
-    Tick repeat = period * Clock::Int::ns;
+    DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
 
-    Stats::StatEvent(false, true, when, repeat);
+    tc->getSystemPtr()->kernelSymtab->insert(addr,symbol);
+    debugSymbolTable->insert(addr,symbol);
 }
 
+#endif
+
+
 void
-dumpstats(ThreadContext *tc, Tick delay, Tick period)
+resetstats(ThreadContext *tc, Tick delay, Tick period)
 {
-    if (!tc->getCpuPtr()->params->do_statistics_insts)
+    if (!tc->getCpuPtr()->params()->do_statistics_insts)
         return;
 
 
-    Tick when = curTick + delay * Clock::Int::ns;
-    Tick repeat = period * Clock::Int::ns;
+    Tick when = curTick + delay * SimClock::Int::ns;
+    Tick repeat = period * SimClock::Int::ns;
 
-    Stats::StatEvent(true, false, when, repeat);
+    Stats::StatEvent(false, true, when, repeat);
 }
 
 void
-addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
+dumpstats(ThreadContext *tc, Tick delay, Tick period)
 {
-    char symb[100];
-    CopyStringOut(tc, symb, symbolAddr, 100);
-    std::string symbol(symb);
+    if (!tc->getCpuPtr()->params()->do_statistics_insts)
+        return;
 
-    DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
 
-    tc->getSystemPtr()->kernelSymtab->insert(addr,symbol);
+    Tick when = curTick + delay * SimClock::Int::ns;
+    Tick repeat = period * SimClock::Int::ns;
+
+    Stats::StatEvent(true, false, when, repeat);
 }
 
 void
 dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
 {
-    if (!tc->getCpuPtr()->params->do_statistics_insts)
+    if (!tc->getCpuPtr()->params()->do_statistics_insts)
         return;
 
 
-    Tick when = curTick + delay * Clock::Int::ns;
-    Tick repeat = period * Clock::Int::ns;
+    Tick when = curTick + delay * SimClock::Int::ns;
+    Tick repeat = period * SimClock::Int::ns;
 
     Stats::StatEvent(true, true, when, repeat);
 }
@@ -232,15 +265,18 @@ dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
 void
 m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
 {
-    if (!tc->getCpuPtr()->params->do_checkpoint_insts)
+    if (!tc->getCpuPtr()->params()->do_checkpoint_insts)
         return;
 
-    Tick when = curTick + delay * Clock::Int::ns;
-    Tick repeat = period * Clock::Int::ns;
+    Tick when = curTick + delay * SimClock::Int::ns;
+    Tick repeat = period * SimClock::Int::ns;
 
-    schedExitSimLoop("checkpoint", when, repeat);
+    Event *event = new SimLoopExitEvent("checkpoint", 0, repeat);
+    mainEventQueue.schedule(event, when);
 }
 
+#if FULL_SYSTEM
+
 uint64_t
 readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
 {
@@ -276,6 +312,8 @@ readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
     return result;
 }
 
+#endif
+
 void
 debugbreak(ThreadContext *tc)
 {