Some touchup to the reorganized includes and "using" directives.
[gem5.git] / src / cpu / base.cc
index 8641d987db4864aba7eb8396f74d16a8d9619ae5..ce440aeffc2eaf9ba316ea5e8a7abb13e093224f 100644 (file)
@@ -24,6 +24,9 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Steve Reinhardt
+ *          Nathan Binkert
  */
 
 #include <iostream>
@@ -36,9 +39,8 @@
 #include "base/output.hh"
 #include "cpu/base.hh"
 #include "cpu/cpuevent.hh"
-#include "cpu/exec_context.hh"
+#include "cpu/thread_context.hh"
 #include "cpu/profile.hh"
-#include "cpu/sampler/sampler.hh"
 #include "sim/param.hh"
 #include "sim/process.hh"
 #include "sim/sim_events.hh"
@@ -57,11 +59,11 @@ int maxThreadsPerCPU = 1;
 
 #if FULL_SYSTEM
 BaseCPU::BaseCPU(Params *p)
-    : SimObject(p->name), clock(p->clock), checkInterrupts(true),
+    : MemObject(p->name), clock(p->clock), checkInterrupts(true),
       params(p), number_of_threads(p->numberOfThreads), system(p->system)
 #else
 BaseCPU::BaseCPU(Params *p)
-    : SimObject(p->name), clock(p->clock), params(p),
+    : MemObject(p->name), clock(p->clock), params(p),
       number_of_threads(p->numberOfThreads), system(p->system)
 #endif
 {
@@ -86,8 +88,8 @@ BaseCPU::BaseCPU(Params *p)
     //
     if (p->max_insts_any_thread != 0)
         for (int i = 0; i < number_of_threads; ++i)
-            new SimExitEvent(comInstEventQueue[i], p->max_insts_any_thread,
-                "a thread reached the max instruction count");
+            new SimLoopExitEvent(comInstEventQueue[i], p->max_insts_any_thread,
+                                 "a thread reached the max instruction count");
 
     if (p->max_insts_all_threads != 0) {
         // allocate & initialize shared downcounter: each event will
@@ -111,8 +113,8 @@ BaseCPU::BaseCPU(Params *p)
     //
     if (p->max_loads_any_thread != 0)
         for (int i = 0; i < number_of_threads; ++i)
-            new SimExitEvent(comLoadEventQueue[i], p->max_loads_any_thread,
-                "a thread reached the max load count");
+            new SimLoopExitEvent(comLoadEventQueue[i], p->max_loads_any_thread,
+                                 "a thread reached the max load count");
 
     if (p->max_loads_all_threads != 0) {
         // allocate & initialize shared downcounter: each event will
@@ -176,7 +178,7 @@ void
 BaseCPU::init()
 {
     if (!params->deferRegistration)
-        registerExecContexts();
+        registerThreadContexts();
 }
 
 void
@@ -199,15 +201,15 @@ BaseCPU::regStats()
         .desc("number of cpu cycles simulated")
         ;
 
-    int size = execContexts.size();
+    int size = threadContexts.size();
     if (size > 1) {
         for (int i = 0; i < size; ++i) {
             stringstream namestr;
             ccprintf(namestr, "%s.ctx%d", name(), i);
-            execContexts[i]->regStats(namestr.str());
+            threadContexts[i]->regStats(namestr.str());
         }
     } else if (size == 1)
-        execContexts[0]->regStats(name());
+        threadContexts[0]->regStats(name());
 
 #if FULL_SYSTEM
 #endif
@@ -215,27 +217,26 @@ BaseCPU::regStats()
 
 
 void
-BaseCPU::registerExecContexts()
+BaseCPU::registerThreadContexts()
 {
-    for (int i = 0; i < execContexts.size(); ++i) {
-        ExecContext *xc = execContexts[i];
+    for (int i = 0; i < threadContexts.size(); ++i) {
+        ThreadContext *tc = threadContexts[i];
 
 #if FULL_SYSTEM
         int id = params->cpu_id;
         if (id != -1)
             id += i;
 
-        xc->setCpuId(system->registerExecContext(xc, id));
+        tc->setCpuId(system->registerThreadContext(tc, id));
 #else
-        xc->setCpuId(xc->getProcessPtr()->registerExecContext(xc));
+        tc->setCpuId(tc->getProcessPtr()->registerThreadContext(tc));
 #endif
-        }
     }
 }
 
 
 void
-BaseCPU::switchOut(Sampler *sampler)
+BaseCPU::switchOut()
 {
     panic("This CPU doesn't support sampling!");
 }
@@ -243,22 +244,22 @@ BaseCPU::switchOut(Sampler *sampler)
 void
 BaseCPU::takeOverFrom(BaseCPU *oldCPU)
 {
-    assert(execContexts.size() == oldCPU->execContexts.size());
+    assert(threadContexts.size() == oldCPU->threadContexts.size());
 
-    for (int i = 0; i < execContexts.size(); ++i) {
-        ExecContext *newXC = execContexts[i];
-        ExecContext *oldXC = oldCPU->execContexts[i];
+    for (int i = 0; i < threadContexts.size(); ++i) {
+        ThreadContext *newTC = threadContexts[i];
+        ThreadContext *oldTC = oldCPU->threadContexts[i];
 
-        newXC->takeOverFrom(oldXC);
+        newTC->takeOverFrom(oldTC);
 
-        CpuEvent::replaceExecContext(oldXC, newXC);
+        CpuEvent::replaceThreadContext(oldTC, newTC);
 
-        assert(newXC->readCpuId() == oldXC->readCpuId());
+        assert(newTC->readCpuId() == oldTC->readCpuId());
 #if FULL_SYSTEM
-        system->replaceExecContext(newXC, newXC->readCpuId());
+        system->replaceThreadContext(newTC, newTC->readCpuId());
 #else
-        assert(newXC->getProcessPtr() == oldXC->getProcessPtr());
-        newXC->getProcessPtr()->replaceExecContext(newXC, newXC->readCpuId());
+        assert(newTC->getProcessPtr() == oldTC->getProcessPtr());
+        newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->readCpuId());
 #endif
     }
 
@@ -267,8 +268,8 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU)
         interrupts[i] = oldCPU->interrupts[i];
     intstatus = oldCPU->intstatus;
 
-    for (int i = 0; i < execContexts.size(); ++i)
-        execContexts[i]->profileClear();
+    for (int i = 0; i < threadContexts.size(); ++i)
+        threadContexts[i]->profileClear();
 
     if (profileEvent)
         profileEvent->schedule(curTick);
@@ -284,9 +285,9 @@ BaseCPU::ProfileEvent::ProfileEvent(BaseCPU *_cpu, int _interval)
 void
 BaseCPU::ProfileEvent::process()
 {
-    for (int i = 0, size = cpu->execContexts.size(); i < size; ++i) {
-        ExecContext *xc = cpu->execContexts[i];
-        xc->profileSample();
+    for (int i = 0, size = cpu->threadContexts.size(); i < size; ++i) {
+        ThreadContext *tc = cpu->threadContexts[i];
+        tc->profileSample();
     }
 
     schedule(curTick + interval);