cpu: Check that the memory system is in the correct mode

This patch adds checks to all CPU models to make sure that the memory
system is in the correct mode at startup and when resuming after a
drain.  Previously, we only checked that the memory system was in the
right mode when resuming. This is inadequate since this is a
configuration error that should be detected at startup as well as when
resuming. Additionally, since the check was done using an assert, it
wasn't performed when NDEBUG was set (e.g., the fast target).
This commit is contained in:
Andreas Sandberg
2013-01-07 13:05:41 -05:00
parent 94561dd526
commit 7eb0fb8b6e
4 changed files with 36 additions and 3 deletions

View File

@@ -83,6 +83,12 @@ AtomicSimpleCPU::init()
{
BaseCPU::init();
if (!params()->defer_registration &&
system->getMemoryMode() != Enums::atomic) {
fatal("The atomic CPU requires the memory system to be in "
"'atomic' mode.\n");
}
// Initialise the ThreadContext's memory proxies
tcBase()->initMemProxies(tcBase());
@@ -155,7 +161,10 @@ AtomicSimpleCPU::drainResume()
return;
DPRINTF(SimpleCPU, "Resume\n");
assert(system->getMemoryMode() == Enums::atomic);
if (system->getMemoryMode() != Enums::atomic) {
fatal("The atomic CPU requires the memory system to be in "
"'atomic' mode.\n");
}
setDrainState(Drainable::Running);
if (thread->status() == ThreadContext::Active) {

View File

@@ -66,6 +66,12 @@ TimingSimpleCPU::init()
{
BaseCPU::init();
if (!params()->defer_registration &&
system->getMemoryMode() != Enums::timing) {
fatal("The timing CPU requires the memory system to be in "
"'timing' mode.\n");
}
// Initialise the ThreadContext's memory proxies
tcBase()->initMemProxies(tcBase());
@@ -140,7 +146,10 @@ TimingSimpleCPU::drainResume()
{
DPRINTF(SimpleCPU, "Resume\n");
if (_status != SwitchedOut && _status != Idle) {
assert(system->getMemoryMode() == Enums::timing);
if (system->getMemoryMode() != Enums::timing) {
fatal("The timing CPU requires the memory system to be in "
"'timing' mode.\n");
}
if (fetchEvent.scheduled())
deschedule(fetchEvent);