summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/o3/alpha/cpu_impl.hh18
-rw-r--r--src/cpu/o3/cpu.cc2
-rwxr-xr-xsrc/cpu/o3/thread_context.hh2
-rwxr-xr-xsrc/cpu/o3/thread_context_impl.hh5
-rw-r--r--src/cpu/simple/atomic.cc3
-rw-r--r--src/cpu/simple/timing.cc3
-rw-r--r--src/cpu/simple_thread.cc17
-rw-r--r--src/cpu/thread_context.hh4
-rw-r--r--src/cpu/thread_state.cc35
-rw-r--r--src/cpu/thread_state.hh15
10 files changed, 54 insertions, 50 deletions
diff --git a/src/cpu/o3/alpha/cpu_impl.hh b/src/cpu/o3/alpha/cpu_impl.hh
index b2ef78360..98fd0699a 100644
--- a/src/cpu/o3/alpha/cpu_impl.hh
+++ b/src/cpu/o3/alpha/cpu_impl.hh
@@ -116,24 +116,6 @@ AlphaO3CPU<Impl>::AlphaO3CPU(Params *params)
#if FULL_SYSTEM
// Setup quiesce event.
this->thread[i]->quiesceEvent = new EndQuiesceEvent(tc);
-
- Port *mem_port;
- FunctionalPort *phys_port;
- VirtualPort *virt_port;
- phys_port = new FunctionalPort(csprintf("%s-%d-funcport",
- name(), i));
- mem_port = this->system->physmem->getPort("functional");
- mem_port->setPeer(phys_port);
- phys_port->setPeer(mem_port);
-
- virt_port = new VirtualPort(csprintf("%s-%d-vport",
- name(), i));
- mem_port = this->system->physmem->getPort("functional");
- mem_port->setPeer(virt_port);
- virt_port->setPeer(mem_port);
-
- this->thread[i]->setPhysPort(phys_port);
- this->thread[i]->setVirtPort(virt_port);
#endif
// Give the thread the TC.
this->thread[i]->tc = tc;
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc
index 580816372..3dc353a9f 100644
--- a/src/cpu/o3/cpu.cc
+++ b/src/cpu/o3/cpu.cc
@@ -497,6 +497,8 @@ FullO3CPU<Impl>::init()
}
#if FULL_SYSTEM
+ src_tc->init();
+
TheISA::initCPU(src_tc, src_tc->readCpuId());
#endif
}
diff --git a/src/cpu/o3/thread_context.hh b/src/cpu/o3/thread_context.hh
index daee2fc7d..031f36480 100755
--- a/src/cpu/o3/thread_context.hh
+++ b/src/cpu/o3/thread_context.hh
@@ -91,6 +91,8 @@ class O3ThreadContext : public ThreadContext
virtual VirtualPort *getVirtPort(ThreadContext *src_tc = NULL);
void delVirtPort(VirtualPort *vp);
+
+ virtual void init() { thread->init(); }
#else
virtual TranslatingPort *getMemPort() { return thread->getMemPort(); }
diff --git a/src/cpu/o3/thread_context_impl.hh b/src/cpu/o3/thread_context_impl.hh
index 8d623f5b8..0180756e3 100755
--- a/src/cpu/o3/thread_context_impl.hh
+++ b/src/cpu/o3/thread_context_impl.hh
@@ -41,12 +41,9 @@ O3ThreadContext<Impl>::getVirtPort(ThreadContext *src_tc)
return thread->getVirtPort();
VirtualPort *vp;
- Port *mem_port;
vp = new VirtualPort("tc-vport", src_tc);
- mem_port = cpu->system->physmem->getPort("functional");
- mem_port->setPeer(vp);
- vp->setPeer(mem_port);
+ thread->connectToMemFunc(vp);
return vp;
}
diff --git a/src/cpu/simple/atomic.cc b/src/cpu/simple/atomic.cc
index 133b5500b..cd335e36d 100644
--- a/src/cpu/simple/atomic.cc
+++ b/src/cpu/simple/atomic.cc
@@ -77,6 +77,9 @@ AtomicSimpleCPU::init()
for (int i = 0; i < threadContexts.size(); ++i) {
ThreadContext *tc = threadContexts[i];
+ // initialize the mem pointers
+ tc->init();
+
// initialize CPU, including PC
TheISA::initCPU(tc, tc->readCpuId());
}
diff --git a/src/cpu/simple/timing.cc b/src/cpu/simple/timing.cc
index 3648f7613..aa23a00e8 100644
--- a/src/cpu/simple/timing.cc
+++ b/src/cpu/simple/timing.cc
@@ -59,6 +59,9 @@ TimingSimpleCPU::init()
for (int i = 0; i < threadContexts.size(); ++i) {
ThreadContext *tc = threadContexts[i];
+ // initialize the mem pointers
+ tc->init();
+
// initialize CPU, including PC
TheISA::initCPU(tc, tc->readCpuId());
}
diff --git a/src/cpu/simple_thread.cc b/src/cpu/simple_thread.cc
index 1edcbf352..13d0e2e29 100644
--- a/src/cpu/simple_thread.cc
+++ b/src/cpu/simple_thread.cc
@@ -91,18 +91,6 @@ SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys,
} else {
kernelStats = NULL;
}
- Port *mem_port;
- physPort = new FunctionalPort(csprintf("%s-%d-funcport",
- cpu->name(), tid));
- mem_port = system->physmem->getPort("functional");
- mem_port->setPeer(physPort);
- physPort->setPeer(mem_port);
-
- virtPort = new VirtualPort(csprintf("%s-%d-vport",
- cpu->name(), tid));
- mem_port = system->physmem->getPort("functional");
- mem_port->setPeer(virtPort);
- virtPort->setPeer(mem_port);
}
#else
SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num,
@@ -309,10 +297,7 @@ SimpleThread::getVirtPort(ThreadContext *src_tc)
return virtPort;
VirtualPort *vp = new VirtualPort("tc-vport", src_tc);
- Port *mem_port = getMemFuncPort();
-
- mem_port->setPeer(vp);
- vp->setPeer(mem_port);
+ connectToMemFunc(vp);
return vp;
}
diff --git a/src/cpu/thread_context.hh b/src/cpu/thread_context.hh
index 1e6a907f8..baeb7a8be 100644
--- a/src/cpu/thread_context.hh
+++ b/src/cpu/thread_context.hh
@@ -133,6 +133,8 @@ class ThreadContext
virtual VirtualPort *getVirtPort(ThreadContext *tc = NULL) = 0;
virtual void delVirtPort(VirtualPort *vp) = 0;
+
+ virtual void init() = 0;
#else
virtual TranslatingPort *getMemPort() = 0;
@@ -305,6 +307,8 @@ class ProxyThreadContext : public ThreadContext
VirtualPort *getVirtPort(ThreadContext *tc = NULL) { return actualTC->getVirtPort(tc); }
void delVirtPort(VirtualPort *vp) { return actualTC->delVirtPort(vp); }
+
+ void init() {actualTC->init(); }
#else
TranslatingPort *getMemPort() { return actualTC->getMemPort(); }
diff --git a/src/cpu/thread_state.cc b/src/cpu/thread_state.cc
index 8602f8a50..9cac4fd26 100644
--- a/src/cpu/thread_state.cc
+++ b/src/cpu/thread_state.cc
@@ -39,6 +39,7 @@
#if FULL_SYSTEM
#include "arch/kernel_stats.hh"
#include "cpu/quiesce_event.hh"
+#include "mem/vport.hh"
#endif
#if FULL_SYSTEM
@@ -111,6 +112,28 @@ ThreadState::unserialize(Checkpoint *cp, const std::string &section)
}
#if FULL_SYSTEM
+void
+ThreadState::init()
+{
+ initPhysPort();
+ initVirtPort();
+}
+
+void
+ThreadState::initPhysPort()
+{
+ physPort = new FunctionalPort(csprintf("%s-%d-funcport",
+ baseCpu->name(), tid));
+ connectToMemFunc(physPort);
+}
+
+void
+ThreadState::initVirtPort()
+{
+ virtPort = new VirtualPort(csprintf("%s-%d-vport",
+ baseCpu->name(), tid));
+ connectToMemFunc(virtPort);
+}
void
ThreadState::profileClear()
@@ -138,17 +161,14 @@ ThreadState::getMemPort()
baseCpu->name(), tid),
process->pTable, false);
- Port *func_port = getMemFuncPort();
-
- func_port->setPeer(port);
- port->setPeer(func_port);
+ connectToMemFunc(port);
return port;
}
#endif
-Port *
-ThreadState::getMemFuncPort()
+void
+ThreadState::connectToMemFunc(Port *port)
{
Port *dcache_port, *func_mem_port;
@@ -161,5 +181,6 @@ ThreadState::getMemFuncPort()
func_mem_port = mem_object->getPort("functional");
assert(func_mem_port != NULL);
- return func_mem_port;
+ func_mem_port->setPeer(port);
+ port->setPeer(func_mem_port);
}
diff --git a/src/cpu/thread_state.hh b/src/cpu/thread_state.hh
index 0a0af8b71..1844be8b7 100644
--- a/src/cpu/thread_state.hh
+++ b/src/cpu/thread_state.hh
@@ -91,6 +91,12 @@ struct ThreadState {
Tick readLastSuspend() { return lastSuspend; }
#if FULL_SYSTEM
+ void init();
+
+ void initPhysPort();
+
+ void initVirtPort();
+
void dumpFuncProfile();
EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; }
@@ -141,12 +147,11 @@ struct ThreadState {
/** Sets the status of this thread. */
void setStatus(Status new_status) { _status = new_status; }
- protected:
- /** Gets a functional port from the memory object that's connected
- * to the CPU. */
- Port *getMemFuncPort();
-
public:
+ /** Connects port to the functional port of the memory object
+ * below the CPU. */
+ void connectToMemFunc(Port *port);
+
/** Number of instructions committed. */
Counter numInst;
/** Stat for number instructions committed. */