From de8baeb58aa2b86c56b0edd6af7541d8fcb4efdb Mon Sep 17 00:00:00 2001 From: Kevin Lim Date: Sat, 22 Apr 2006 18:11:54 -0400 Subject: [PATCH] Move quiesce event to its own class. SConscript: Move quiesce event to its own file/class. --HG-- extra : convert_revision : 6aa7863adb529fc03142666213c3ec348825bd3b --- SConscript | 1 + cpu/cpu_exec_context.cc | 39 ++++++++++++++++----------------------- cpu/cpu_exec_context.hh | 18 ++---------------- cpu/quiesce_event.cc | 20 ++++++++++++++++++++ cpu/quiesce_event.hh | 23 +++++++++++++++++++++++ 5 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 cpu/quiesce_event.cc create mode 100644 cpu/quiesce_event.hh diff --git a/SConscript b/SConscript index 8f2ae761d..062661557 100644 --- a/SConscript +++ b/SConscript @@ -85,6 +85,7 @@ base_sources = Split(''' cpu/cpu_exec_context.cc cpu/exetrace.cc cpu/pc_event.cc + cpu/quiesce_event.cc cpu/static_inst.cc cpu/sampler/sampler.cc cpu/trace/reader/mem_trace_reader.cc diff --git a/cpu/cpu_exec_context.cc b/cpu/cpu_exec_context.cc index b7238e73a..363244e60 100644 --- a/cpu/cpu_exec_context.cc +++ b/cpu/cpu_exec_context.cc @@ -38,6 +38,7 @@ #include "base/output.hh" #include "base/trace.hh" #include "cpu/profile.hh" +#include "cpu/quiesce_event.hh" #include "kern/kernel_stats.hh" #include "sim/serialize.hh" #include "sim/sim_exit.hh" @@ -57,10 +58,12 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num, System *_sys, : _status(ExecContext::Unallocated), cpu(_cpu), thread_num(_thread_num), cpu_id(-1), lastActivate(0), lastSuspend(0), mem(_mem), itb(_itb), dtb(_dtb), system(_sys), memctrl(_sys->memctrl), physmem(_sys->physmem), - profile(NULL), quiesceEvent(this), func_exe_inst(0), storeCondFailures(0) + profile(NULL), func_exe_inst(0), storeCondFailures(0) { proxy = new ProxyExecContext(this); + quiesceEvent = new EndQuiesceEvent(proxy); + memset(®s, 0, sizeof(RegFile)); if (cpu->params->profile) { @@ -82,7 +85,7 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num, Process *_process, int _asid) : _status(ExecContext::Unallocated), cpu(_cpu), thread_num(_thread_num), cpu_id(-1), lastActivate(0), - lastSuspend(0), process(_process), mem(process->getMemory()), asid(_asid), + lastSuspend(0), process(_process), mem(NULL), asid(_asid), func_exe_inst(0), storeCondFailures(0) { memset(®s, 0, sizeof(RegFile)); @@ -91,7 +94,7 @@ CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num, CPUExecContext::CPUExecContext(BaseCPU *_cpu, int _thread_num, FunctionalMemory *_mem, int _asid) - : cpu(_cpu), thread_num(_thread_num), process(0), mem(_mem), asid(_asid), + : cpu(_cpu), thread_num(_thread_num), process(0), mem(NULL), asid(_asid), func_exe_inst(0), storeCondFailures(0) { memset(®s, 0, sizeof(RegFile)); @@ -121,23 +124,6 @@ CPUExecContext::dumpFuncProfile() profile->dump(proxy, *os); } -CPUExecContext::EndQuiesceEvent::EndQuiesceEvent(CPUExecContext *_cpuXC) - : Event(&mainEventQueue), cpuXC(_cpuXC) -{ -} - -void -CPUExecContext::EndQuiesceEvent::process() -{ - cpuXC->activate(); -} - -const char* -CPUExecContext::EndQuiesceEvent::description() -{ - return "End Quiesce Event."; -} - void CPUExecContext::profileClear() { @@ -189,8 +175,8 @@ CPUExecContext::serialize(ostream &os) #if FULL_SYSTEM Tick quiesceEndTick = 0; - if (quiesceEvent.scheduled()) - quiesceEndTick = quiesceEvent.when(); + if (quiesceEvent->scheduled()) + quiesceEndTick = quiesceEvent->when(); SERIALIZE_SCALAR(quiesceEndTick); #endif @@ -210,7 +196,7 @@ CPUExecContext::unserialize(Checkpoint *cp, const std::string §ion) Tick quiesceEndTick; UNSERIALIZE_SCALAR(quiesceEndTick); if (quiesceEndTick) - quiesceEvent.schedule(quiesceEndTick); + quiesceEvent->schedule(quiesceEndTick); #endif } @@ -223,7 +209,14 @@ CPUExecContext::activate(int delay) lastActivate = curTick; + if (status() == ExecContext::Unallocated) { + cpu->activateWhenReady(thread_num); + return; + } + _status = ExecContext::Active; + + // status() == Suspended cpu->activateContext(thread_num, delay); } diff --git a/cpu/cpu_exec_context.hh b/cpu/cpu_exec_context.hh index beaf67352..40153ff08 100644 --- a/cpu/cpu_exec_context.hh +++ b/cpu/cpu_exec_context.hh @@ -135,23 +135,9 @@ class CPUExecContext Addr profilePC; void dumpFuncProfile(); - /** Event for timing out quiesce instruction */ - struct EndQuiesceEvent : public Event - { - /** A pointer to the execution context that is quiesced */ - CPUExecContext *cpuXC; - - EndQuiesceEvent(CPUExecContext *_cpuXC); - - /** Event process to occur at interrupt*/ - virtual void process(); - - /** Event description */ - virtual const char *description(); - }; - EndQuiesceEvent quiesceEvent; + Event *quiesceEvent; - Event *getQuiesceEvent() { return &quiesceEvent; } + Event *getQuiesceEvent() { return quiesceEvent; } Tick readLastActivate() { return lastActivate; } diff --git a/cpu/quiesce_event.cc b/cpu/quiesce_event.cc new file mode 100644 index 000000000..37814ae09 --- /dev/null +++ b/cpu/quiesce_event.cc @@ -0,0 +1,20 @@ + +#include "cpu/exec_context.hh" +#include "cpu/quiesce_event.hh" + +EndQuiesceEvent::EndQuiesceEvent(ExecContext *_xc) + : Event(&mainEventQueue), xc(_xc) +{ +} + +void +EndQuiesceEvent::process() +{ + xc->activate(); +} + +const char* +EndQuiesceEvent::description() +{ + return "End Quiesce Event."; +} diff --git a/cpu/quiesce_event.hh b/cpu/quiesce_event.hh new file mode 100644 index 000000000..18e88ecce --- /dev/null +++ b/cpu/quiesce_event.hh @@ -0,0 +1,23 @@ +#ifndef __CPU_QUIESCE_EVENT_HH__ +#define __CPU_QUIESCE_EVENT_HH__ + +#include "sim/eventq.hh" + +class ExecContext; + +/** Event for timing out quiesce instruction */ +struct EndQuiesceEvent : public Event +{ + /** A pointer to the execution context that is quiesced */ + ExecContext *xc; + + EndQuiesceEvent(ExecContext *_xc); + + /** Event process to occur at interrupt*/ + virtual void process(); + + /** Event description */ + virtual const char *description(); +}; + +#endif // __CPU_QUIESCE_EVENT_HH__ -- 2.30.2