ARM: Make VMSR, RFE PC/LR etc non speculative, and serializing
[gem5.git] / src / sim / system.cc
index d16524c415b2c2b4981fbdc48eebcc9dcec94853..45e06616da83929bfd217a348e6658dfbe2179af 100644 (file)
 #include "base/loader/symtab.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
+#include "config/full_system.hh"
+#include "config/the_isa.hh"
 #include "mem/mem_object.hh"
 #include "mem/physical.hh"
 #include "sim/byteswap.hh"
 #include "sim/system.hh"
 #include "sim/debug.hh"
+
 #if FULL_SYSTEM
 #include "arch/vtophys.hh"
 #include "kern/kernel_stats.hh"
@@ -63,6 +66,7 @@ System::System(Params *p)
       init_param(p->init_param),
       functionalPort(p->name + "-fport"),
       virtPort(p->name + "-vport"),
+      loadAddrMask(p->load_addr_mask),
 #else
       page_ptr(0),
       next_PID(0),
@@ -106,7 +110,7 @@ System::System(Params *p)
             fatal("Could not load kernel file %s", params()->kernel);
 
         // Load program sections into memory
-        kernel->loadSections(&functionalPort, LoadAddrMask);
+        kernel->loadSections(&functionalPort, loadAddrMask);
 
         // setup entry points
         kernelStart = kernel->textBase();
@@ -148,9 +152,6 @@ System::~System()
 #endif // FULL_SYSTEM}
 }
 
-int rgdb_wait = -1;
-int rgdb_enable = true;
-
 void
 System::setMemoryMode(Enums::MemoryMode mode)
 {
@@ -165,6 +166,13 @@ bool System::breakpoint()
     return false;
 }
 
+/**
+ * Setting rgdb_wait to a positive integer waits for a remote debugger to
+ * connect to that context ID before continuing.  This should really
+   be a parameter on the CPU object or something...
+ */
+int rgdb_wait = -1;
+
 int
 System::registerThreadContext(ThreadContext *tc, int assigned)
 {
@@ -190,14 +198,11 @@ System::registerThreadContext(ThreadContext *tc, int assigned)
     _numContexts++;
 
     int port = getRemoteGDBPort();
-    if (rgdb_enable && port) {
+    if (port) {
         RemoteGDB *rgdb = new RemoteGDB(this, tc);
         GDBListener *gdbl = new GDBListener(rgdb, port + id);
         gdbl->listen();
-        /**
-         * Uncommenting this line waits for a remote debugger to
-         * connect to the simulator before continuing.
-         */
+
         if (rgdb_wait != -1 && rgdb_wait == id)
             gdbl->accept();
 
@@ -211,6 +216,17 @@ System::registerThreadContext(ThreadContext *tc, int assigned)
     return id;
 }
 
+int
+System::numRunningContexts()
+{
+    int running = 0;
+    for (int i = 0; i < _numContexts; ++i) {
+        if (threadContexts[i]->status() != ThreadContext::Halted)
+            ++running;
+    }
+    return running;
+}
+
 void
 System::startup()
 {