diff options
author | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-02-15 17:40:08 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-02-15 17:40:08 -0500 |
commit | 1eec115c31395e2819c073a1859d75eb5933dac2 (patch) | |
tree | 503552557b8a5504bbb9aa9a3515b0bb398a97fc /src/cpu/simple/atomic.cc | |
parent | 1c7aa665bfc678c33cc05829acc52aebb1d2612c (diff) | |
download | gem5-1eec115c31395e2819c073a1859d75eb5933dac2.tar.xz |
cpu: Refactor memory system checks
CPUs need to test that the memory system is in the right mode in two
places, when the CPU is initialized (unless it's switched out) and on
a drainResume(). This led to some code duplication in the CPU
models. This changeset introduces the verifyMemoryMode() method which
is called by BaseCPU::init() if the CPU isn't switched out. The
individual CPU models are responsible for calling this method when
resuming from a drain as this code is CPU model specific.
Diffstat (limited to 'src/cpu/simple/atomic.cc')
-rw-r--r-- | src/cpu/simple/atomic.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/cpu/simple/atomic.cc b/src/cpu/simple/atomic.cc index 7255469a0..7a0778961 100644 --- a/src/cpu/simple/atomic.cc +++ b/src/cpu/simple/atomic.cc @@ -84,12 +84,6 @@ AtomicSimpleCPU::init() { BaseCPU::init(); - if (!params()->switched_out && - 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()); @@ -157,10 +151,7 @@ AtomicSimpleCPU::drainResume() return; DPRINTF(SimpleCPU, "Resume\n"); - if (system->getMemoryMode() != Enums::atomic) { - fatal("The atomic CPU requires the memory system to be in " - "'atomic' mode.\n"); - } + verifyMemoryMode(); assert(!threadContexts.empty()); if (threadContexts.size() > 1) @@ -218,6 +209,14 @@ AtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU) data_write_req.setThreadContext(_cpuId, 0); // Add thread ID here too } +void +AtomicSimpleCPU::verifyMemoryMode() const +{ + if (system->getMemoryMode() != Enums::atomic) { + fatal("The atomic CPU requires the memory system to be in " + "'atomic' mode.\n"); + } +} void AtomicSimpleCPU::activateContext(ThreadID thread_num, Cycles delay) |