diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-03-30 09:38:35 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-03-30 09:38:35 -0400 |
commit | a14013af3a9e04d68985aea7bcff6c1e70bdbb82 (patch) | |
tree | 67e1fcae84daca1bd507d439a24919d178f4d16e /src/cpu/thread_state.cc | |
parent | 390cfc7be9e5e477451a31a1dc8df82b42ee4011 (diff) | |
download | gem5-a14013af3a9e04d68985aea7bcff6c1e70bdbb82.tar.xz |
CPU: Unify initMemProxies across CPUs and simulation modes
This patch unifies where initMemProxies is called, in the init()
method of each BaseCPU subclass, before TheISA::initCPU is
called. Moreover, it also ensures that initMemProxies is called in
both full-system and syscall-emulation mode, thus unifying also across
the modes. An additional check is added in the ThreadState to ensure
that initMemProxies is only called once.
Diffstat (limited to 'src/cpu/thread_state.cc')
-rw-r--r-- | src/cpu/thread_state.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/cpu/thread_state.cc b/src/cpu/thread_state.cc index 3d58b4da4..eda62dad1 100644 --- a/src/cpu/thread_state.cc +++ b/src/cpu/thread_state.cc @@ -101,17 +101,25 @@ ThreadState::unserialize(Checkpoint *cp, const std::string §ion) void ThreadState::initMemProxies(ThreadContext *tc) { - // Note that this only refers to the port on the CPU side and can - // safely be done at init() time even if the CPU is not connected - // (i.e. due to restoring from a checkpoint and later switching - // in. - if (physProxy == NULL) - // this cannot be done in the constructor as the thread state + // The port proxies only refer to the data port on the CPU side + // and can safely be done at init() time even if the CPU is not + // connected, i.e. when restoring from a checkpoint and later + // switching the CPU in. + if (FullSystem) { + assert(physProxy == NULL); + // This cannot be done in the constructor as the thread state // itself is created in the base cpu constructor and the - // getPort is a virtual function at the moment + // getDataPort is a virtual function physProxy = new PortProxy(baseCpu->getDataPort()); - if (virtProxy == NULL) + + assert(virtProxy == NULL); virtProxy = new FSTranslatingPortProxy(tc); + } else { + assert(proxy == NULL); + proxy = new SETranslatingPortProxy(baseCpu->getDataPort(), + process, + SETranslatingPortProxy::NextPage); + } } void @@ -127,13 +135,3 @@ ThreadState::profileSample() if (profile) profile->sample(profileNode, profilePC); } - -SETranslatingPortProxy & -ThreadState::getMemProxy() -{ - if (proxy == NULL) - proxy = new SETranslatingPortProxy(baseCpu->getDataPort(), - process, - SETranslatingPortProxy::NextPage); - return *proxy; -} |