summaryrefslogtreecommitdiff
path: root/src/cpu/base.cc
diff options
context:
space:
mode:
authorLisa Hsu <hsul@eecs.umich.edu>2008-11-02 21:56:57 -0500
committerLisa Hsu <hsul@eecs.umich.edu>2008-11-02 21:56:57 -0500
commitc55a467a06eaa59c47c52a2adddc266b8e545589 (patch)
treee86f0c75e6009285507cd2414b829c122bb0be1f /src/cpu/base.cc
parentf4bceb9760c93d3b5ff3c2606f7e460b42724670 (diff)
downloadgem5-c55a467a06eaa59c47c52a2adddc266b8e545589.tar.xz
make BaseCPU the provider of _cpuId, and cpuId() instead of being scattered
across the subclasses. generally make it so that member data is _cpuId and accessor functions are cpuId(). The ID val comes from the python (default -1 if none provided), and if it is -1, the index of cpuList will be given. this has passed util/regress quick and se.py -n4 and fs.py -n4 as well as standard switch.
Diffstat (limited to 'src/cpu/base.cc')
-rw-r--r--src/cpu/base.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index 8c461cccb..3e899d993 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -94,21 +94,29 @@ CPUProgressEvent::description() const
#if FULL_SYSTEM
BaseCPU::BaseCPU(Params *p)
- : MemObject(p), clock(p->clock), instCnt(0), interrupts(p->interrupts),
+ : MemObject(p), clock(p->clock), instCnt(0), _cpuId(p->cpu_id),
+ interrupts(p->interrupts),
number_of_threads(p->numThreads), system(p->system),
phase(p->phase)
#else
BaseCPU::BaseCPU(Params *p)
- : MemObject(p), clock(p->clock),
+ : MemObject(p), clock(p->clock), _cpuId(p->cpu_id),
number_of_threads(p->numThreads), system(p->system),
phase(p->phase)
#endif
{
// currentTick = curTick;
+ // if Python did not provide a valid ID, do it here
+ if (_cpuId == -1 ) {
+ _cpuId = cpuList.size();
+ }
+
// add self to global list of CPUs
cpuList.push_back(this);
+ DPRINTF(SyscallVerbose, "Constructing CPU with id %d\n", _cpuId);
+
if (number_of_threads > maxThreadsPerCPU)
maxThreadsPerCPU = number_of_threads;
@@ -278,13 +286,9 @@ BaseCPU::registerThreadContexts()
ThreadContext *tc = threadContexts[i];
#if FULL_SYSTEM
- int id = params()->cpu_id;
- if (id != -1)
- id += i;
-
- tc->setCpuId(system->registerThreadContext(tc, id));
+ system->registerThreadContext(tc);
#else
- tc->setCpuId(tc->getProcessPtr()->registerThreadContext(tc));
+ tc->getProcessPtr()->registerThreadContext(tc);
#endif
}
}
@@ -315,6 +319,8 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
{
assert(threadContexts.size() == oldCPU->threadContexts.size());
+ _cpuId = oldCPU->cpuId();
+
for (int i = 0; i < threadContexts.size(); ++i) {
ThreadContext *newTC = threadContexts[i];
ThreadContext *oldTC = oldCPU->threadContexts[i];
@@ -323,12 +329,12 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
CpuEvent::replaceThreadContext(oldTC, newTC);
- assert(newTC->readCpuId() == oldTC->readCpuId());
+ assert(newTC->cpuId() == oldTC->cpuId());
#if FULL_SYSTEM
- system->replaceThreadContext(newTC, newTC->readCpuId());
+ system->replaceThreadContext(newTC, newTC->cpuId());
#else
assert(newTC->getProcessPtr() == oldTC->getProcessPtr());
- newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->readCpuId());
+ newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->cpuId());
#endif
if (DTRACE(Context))