diff options
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/base_cpu.hh | 4 | ||||
-rw-r--r-- | cpu/exec_context.cc | 14 | ||||
-rw-r--r-- | cpu/exec_context.hh | 4 | ||||
-rw-r--r-- | cpu/simple_cpu/simple_cpu.cc | 31 | ||||
-rw-r--r-- | cpu/simple_cpu/simple_cpu.hh | 11 |
5 files changed, 21 insertions, 43 deletions
diff --git a/cpu/base_cpu.hh b/cpu/base_cpu.hh index 5a20aaa54..143fc9662 100644 --- a/cpu/base_cpu.hh +++ b/cpu/base_cpu.hh @@ -73,7 +73,7 @@ class BaseCPU : public SimObject std::vector<ExecContext *> execContexts; public: - virtual void execCtxStatusChg() {} + virtual void execCtxStatusChg(int thread_num) {} public: @@ -94,7 +94,7 @@ class BaseCPU : public SimObject virtual void regStats(); - virtual void registerExecContexts(); + void registerExecContexts(); /// Prepare for another CPU to take over execution. Called by /// takeOverFrom() on its argument. diff --git a/cpu/exec_context.cc b/cpu/exec_context.cc index 6c24500cc..a4670f291 100644 --- a/cpu/exec_context.cc +++ b/cpu/exec_context.cc @@ -44,24 +44,22 @@ using namespace std; ExecContext::ExecContext(BaseCPU *_cpu, int _thread_num, System *_sys, AlphaItb *_itb, AlphaDtb *_dtb, FunctionalMemory *_mem) - : kernelStats(this, _cpu), cpu(_cpu), thread_num(_thread_num), + : _status(ExecContext::Unallocated), + kernelStats(this, _cpu), cpu(_cpu), thread_num(_thread_num), cpu_id(-1), mem(_mem), itb(_itb), dtb(_dtb), system(_sys), memCtrl(_sys->memCtrl), physmem(_sys->physmem), func_exe_insn(0), storeCondFailures(0) { memset(®s, 0, sizeof(RegFile)); - setStatus(ExecContext::Unallocated); } #else ExecContext::ExecContext(BaseCPU *_cpu, int _thread_num, Process *_process, int _asid) - : cpu(_cpu), thread_num(_thread_num), cpu_id(-1), - process(_process), asid (_asid), + : _status(ExecContext::Unallocated), + cpu(_cpu), thread_num(_thread_num), cpu_id(-1), + process(_process), mem(process->getMemory()), asid(_asid), func_exe_insn(0), storeCondFailures(0) { - setStatus(ExecContext::Unallocated); - - mem = process->getMemory(); } ExecContext::ExecContext(BaseCPU *_cpu, int _thread_num, @@ -114,7 +112,7 @@ ExecContext::setStatus(Status new_status) #endif _status = new_status; - cpu->execCtxStatusChg(); + cpu->execCtxStatusChg(thread_num); } void diff --git a/cpu/exec_context.hh b/cpu/exec_context.hh index 5c6e84cee..f2afaa334 100644 --- a/cpu/exec_context.hh +++ b/cpu/exec_context.hh @@ -68,10 +68,6 @@ class ExecContext public: Status status() const { return _status; } - // Unlike setStatus(), initStatus() has no side effects other than - // setting the _status variable. - void initStatus(Status init_status) { _status = init_status; } - void setStatus(Status new_status); #ifdef FULL_SYSTEM diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc index 41e3de24e..891e6cdb3 100644 --- a/cpu/simple_cpu/simple_cpu.cc +++ b/cpu/simple_cpu/simple_cpu.cc @@ -164,25 +164,6 @@ SimpleCPU::~SimpleCPU() void -SimpleCPU::registerExecContexts() -{ - BaseCPU::registerExecContexts(); - - // if any of this CPU's ExecContexts are active, mark the CPU as - // running and schedule its tick event. - for (int i = 0; i < execContexts.size(); ++i) { - ExecContext *xc = execContexts[i]; - if (xc->status() == ExecContext::Active && _status != Running) { - _status = Running; - // this should only happen at initialization time - assert(curTick == 0); - tickEvent.schedule(0); - } - } -} - - -void SimpleCPU::switchOut() { _status = SwitchedOut; @@ -213,6 +194,18 @@ SimpleCPU::takeOverFrom(BaseCPU *oldCPU) void +SimpleCPU::execCtxStatusChg(int thread_num) { + assert(thread_num == 0); + assert(xc); + + if (xc->status() == ExecContext::Active) + setStatus(Running); + else + setStatus(Idle); +} + + +void SimpleCPU::regStats() { BaseCPU::regStats(); diff --git a/cpu/simple_cpu/simple_cpu.hh b/cpu/simple_cpu/simple_cpu.hh index e1b351cab..60c038163 100644 --- a/cpu/simple_cpu/simple_cpu.hh +++ b/cpu/simple_cpu/simple_cpu.hh @@ -136,8 +136,6 @@ class SimpleCPU : public BaseCPU // execution context ExecContext *xc; - void registerExecContexts(); - void switchOut(); void takeOverFrom(BaseCPU *oldCPU); @@ -178,14 +176,7 @@ class SimpleCPU : public BaseCPU Status status() const { return _status; } - virtual void execCtxStatusChg() { - if (xc) { - if (xc->status() == ExecContext::Active) - setStatus(Running); - else - setStatus(Idle); - } - } + virtual void execCtxStatusChg(int thread_num); void setStatus(Status new_status) { Status old_status = status(); |