pseudoinst: get rid of mainEventQueue references.

Avoid direct references to mainEventQueue in pseudo-insts
by indirecting through associated CPU object.
Made exitSimLoop() more flexible to enable some of these.
This commit is contained in:
Steve Reinhardt 2011-01-07 21:50:29 -08:00
parent d60c293bbc
commit df9f99567d
3 changed files with 19 additions and 15 deletions

View file

@ -88,17 +88,19 @@ quiesce(ThreadContext *tc)
void void
quiesceNs(ThreadContext *tc, uint64_t ns) quiesceNs(ThreadContext *tc, uint64_t ns)
{ {
if (!tc->getCpuPtr()->params()->do_quiesce || ns == 0) BaseCPU *cpu = tc->getCpuPtr();
if (!cpu->params()->do_quiesce || ns == 0)
return; return;
EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent();
Tick resume = curTick + SimClock::Int::ns * ns; Tick resume = curTick + SimClock::Int::ns * ns;
mainEventQueue.reschedule(quiesceEvent, resume, true); cpu->reschedule(quiesceEvent, resume, true);
DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n", DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n",
tc->getCpuPtr()->name(), ns, resume); cpu->name(), ns, resume);
tc->suspend(); tc->suspend();
if (tc->getKernelStats()) if (tc->getKernelStats())
@ -108,17 +110,19 @@ quiesceNs(ThreadContext *tc, uint64_t ns)
void void
quiesceCycles(ThreadContext *tc, uint64_t cycles) quiesceCycles(ThreadContext *tc, uint64_t cycles)
{ {
if (!tc->getCpuPtr()->params()->do_quiesce || cycles == 0) BaseCPU *cpu = tc->getCpuPtr();
if (!cpu->params()->do_quiesce || cycles == 0)
return; return;
EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent();
Tick resume = curTick + tc->getCpuPtr()->ticks(cycles); Tick resume = curTick + cpu->ticks(cycles);
mainEventQueue.reschedule(quiesceEvent, resume, true); cpu->reschedule(quiesceEvent, resume, true);
DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n", DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n",
tc->getCpuPtr()->name(), cycles, resume); cpu->name(), cycles, resume);
tc->suspend(); tc->suspend();
if (tc->getKernelStats()) if (tc->getKernelStats())
@ -153,8 +157,7 @@ void
m5exit(ThreadContext *tc, Tick delay) m5exit(ThreadContext *tc, Tick delay)
{ {
Tick when = curTick + delay * SimClock::Int::ns; Tick when = curTick + delay * SimClock::Int::ns;
Event *event = new SimLoopExitEvent("m5_exit instruction encountered", 0); exitSimLoop("m5_exit instruction encountered", 0, when);
mainEventQueue.schedule(event, when);
} }
#if FULL_SYSTEM #if FULL_SYSTEM
@ -271,8 +274,7 @@ m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
Tick when = curTick + delay * SimClock::Int::ns; Tick when = curTick + delay * SimClock::Int::ns;
Tick repeat = period * SimClock::Int::ns; Tick repeat = period * SimClock::Int::ns;
Event *event = new SimLoopExitEvent("checkpoint", 0, repeat); exitSimLoop("checkpoint", 0, when, repeat);
mainEventQueue.schedule(event, when);
} }
#if FULL_SYSTEM #if FULL_SYSTEM

View file

@ -78,10 +78,10 @@ SimLoopExitEvent::description() const
} }
void void
exitSimLoop(const std::string &message, int exit_code) exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat)
{ {
Event *event = new SimLoopExitEvent(message, exit_code); Event *event = new SimLoopExitEvent(message, exit_code, repeat);
mainEventQueue.schedule(event, curTick); mainEventQueue.schedule(event, when);
} }
CountedDrainEvent::CountedDrainEvent() CountedDrainEvent::CountedDrainEvent()

View file

@ -35,6 +35,7 @@
#include <string> #include <string>
#include "base/types.hh" #include "base/types.hh"
#include "sim/core.hh"
// forward declaration // forward declaration
class Callback; class Callback;
@ -49,6 +50,7 @@ void registerExitCallback(Callback *);
/// Python) at the end of the current cycle (curTick). The message /// Python) at the end of the current cycle (curTick). The message
/// and exit_code parameters are saved in the SimLoopExitEvent to /// and exit_code parameters are saved in the SimLoopExitEvent to
/// indicate why the exit occurred. /// indicate why the exit occurred.
void exitSimLoop(const std::string &message, int exit_code = 0); void exitSimLoop(const std::string &message, int exit_code = 0,
Tick when = curTick, Tick repeat = 0);
#endif // __SIM_EXIT_HH__ #endif // __SIM_EXIT_HH__