Make an initialization pass for the thread context and set the [phys,virt]Port correctly

src/cpu/simple/atomic.cc:
src/cpu/simple/timing.cc:
    Call the thread context initialization

--HG--
extra : convert_revision : d7dc2a8b893dc670077b7f6150d4b710a1778620
This commit is contained in:
Ron Dreslinski 2006-11-17 21:55:28 -05:00
parent dbdf2f14ae
commit cd0b65508e
6 changed files with 32 additions and 14 deletions

View file

@ -77,6 +77,9 @@ AtomicSimpleCPU::init()
for (int i = 0; i < threadContexts.size(); ++i) { for (int i = 0; i < threadContexts.size(); ++i) {
ThreadContext *tc = threadContexts[i]; ThreadContext *tc = threadContexts[i];
// initialize the mem pointers
tc->init();
// initialize CPU, including PC // initialize CPU, including PC
TheISA::initCPU(tc, tc->readCpuId()); TheISA::initCPU(tc, tc->readCpuId());
} }

View file

@ -59,6 +59,9 @@ TimingSimpleCPU::init()
for (int i = 0; i < threadContexts.size(); ++i) { for (int i = 0; i < threadContexts.size(); ++i) {
ThreadContext *tc = threadContexts[i]; ThreadContext *tc = threadContexts[i];
// initialize the mem pointers
tc->init();
// initialize CPU, including PC // initialize CPU, including PC
TheISA::initCPU(tc, tc->readCpuId()); TheISA::initCPU(tc, tc->readCpuId());
} }

View file

@ -91,18 +91,6 @@ SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys,
} else { } else {
kernelStats = NULL; 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 #else
SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num,
@ -116,6 +104,25 @@ SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num,
#endif #endif
#if FULL_SYSTEM
void
SimpleThread::init()
{
Port *mem_port;
physPort = new FunctionalPort(csprintf("%s-%d-funcport",
cpu->name(), tid));
mem_port = getMemFuncPort();
mem_port->setPeer(physPort);
physPort->setPeer(mem_port);
virtPort = new VirtualPort(csprintf("%s-%d-vport",
cpu->name(), tid));
mem_port = getMemFuncPort();
mem_port->setPeer(virtPort);
virtPort->setPeer(mem_port);
}
#endif
SimpleThread::SimpleThread() SimpleThread::SimpleThread()
#if FULL_SYSTEM #if FULL_SYSTEM
: ThreadState(NULL, -1, -1) : ThreadState(NULL, -1, -1)

View file

@ -118,6 +118,8 @@ class SimpleThread : public ThreadState
SimpleThread(BaseCPU *_cpu, int _thread_num, System *_system, SimpleThread(BaseCPU *_cpu, int _thread_num, System *_system,
TheISA::ITB *_itb, TheISA::DTB *_dtb, TheISA::ITB *_itb, TheISA::DTB *_dtb,
bool use_kernel_stats = true); bool use_kernel_stats = true);
void init();
#else #else
SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process, int _asid); SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process, int _asid);
#endif #endif

View file

@ -133,6 +133,8 @@ class ThreadContext
virtual VirtualPort *getVirtPort(ThreadContext *tc = NULL) = 0; virtual VirtualPort *getVirtPort(ThreadContext *tc = NULL) = 0;
virtual void delVirtPort(VirtualPort *vp) = 0; virtual void delVirtPort(VirtualPort *vp) = 0;
virtual void init() = 0;
#else #else
virtual TranslatingPort *getMemPort() = 0; virtual TranslatingPort *getMemPort() = 0;
@ -305,6 +307,8 @@ class ProxyThreadContext : public ThreadContext
VirtualPort *getVirtPort(ThreadContext *tc = NULL) { return actualTC->getVirtPort(tc); } VirtualPort *getVirtPort(ThreadContext *tc = NULL) { return actualTC->getVirtPort(tc); }
void delVirtPort(VirtualPort *vp) { return actualTC->delVirtPort(vp); } void delVirtPort(VirtualPort *vp) { return actualTC->delVirtPort(vp); }
void init() {actualTC->init(); }
#else #else
TranslatingPort *getMemPort() { return actualTC->getMemPort(); } TranslatingPort *getMemPort() { return actualTC->getMemPort(); }

View file

@ -141,12 +141,11 @@ struct ThreadState {
/** Sets the status of this thread. */ /** Sets the status of this thread. */
void setStatus(Status new_status) { _status = new_status; } void setStatus(Status new_status) { _status = new_status; }
protected: public:
/** Gets a functional port from the memory object that's connected /** Gets a functional port from the memory object that's connected
* to the CPU. */ * to the CPU. */
Port *getMemFuncPort(); Port *getMemFuncPort();
public:
/** Number of instructions committed. */ /** Number of instructions committed. */
Counter numInst; Counter numInst;
/** Stat for number instructions committed. */ /** Stat for number instructions committed. */