#if FULL_SYSTEM
#include "arch/kernel_stats.hh"
#include "cpu/quiesce_event.hh"
+#include "mem/vport.hh"
#endif
#if FULL_SYSTEM
-ThreadState::ThreadState(BaseCPU *cpu, int _cpuId, int _tid)
- : baseCpu(cpu), cpuId(_cpuId), tid(_tid), lastActivate(0), lastSuspend(0),
+ThreadState::ThreadState(BaseCPU *cpu, ThreadID _tid)
+#else
+ThreadState::ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
+#endif
+ : numInst(0), numLoad(0), _status(ThreadContext::Halted),
+ baseCpu(cpu), _threadId(_tid), lastActivate(0), lastSuspend(0),
+#if FULL_SYSTEM
profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL),
- physPort(NULL), virtPort(NULL),
- microPC(0), nextMicroPC(1), funcExeInst(0), storeCondFailures(0)
+ kernelStats(NULL), physPort(NULL), virtPort(NULL),
#else
-ThreadState::ThreadState(BaseCPU *cpu, int _cpuId, int _tid, Process *_process,
- short _asid)
- : baseCpu(cpu), cpuId(_cpuId), tid(_tid), lastActivate(0), lastSuspend(0),
- port(NULL), process(_process), asid(_asid),
- microPC(0), nextMicroPC(1), funcExeInst(0), storeCondFailures(0)
+ port(NULL), process(_process),
#endif
+ funcExeInst(0), storeCondFailures(0)
{
- numInst = 0;
- numLoad = 0;
}
ThreadState::~ThreadState()
// thread_num and cpu_id are deterministic from the config
SERIALIZE_SCALAR(funcExeInst);
SERIALIZE_SCALAR(inst);
- SERIALIZE_SCALAR(microPC);
- SERIALIZE_SCALAR(nextMicroPC);
#if FULL_SYSTEM
Tick quiesceEndTick = 0;
// thread_num and cpu_id are deterministic from the config
UNSERIALIZE_SCALAR(funcExeInst);
UNSERIALIZE_SCALAR(inst);
- UNSERIALIZE_SCALAR(microPC);
- UNSERIALIZE_SCALAR(nextMicroPC);
#if FULL_SYSTEM
Tick quiesceEndTick;
UNSERIALIZE_SCALAR(quiesceEndTick);
if (quiesceEndTick)
- quiesceEvent->schedule(quiesceEndTick);
+ baseCpu->schedule(quiesceEvent, quiesceEndTick);
if (kernelStats)
kernelStats->unserialize(cp, section);
#endif
}
#if FULL_SYSTEM
+void
+ThreadState::connectMemPorts(ThreadContext *tc)
+{
+ connectPhysPort();
+ connectVirtPort(tc);
+}
+
+void
+ThreadState::connectPhysPort()
+{
+ // @todo: For now this disregards any older port that may have
+ // already existed. Fix this memory leak once the bus port IDs
+ // for functional ports is resolved.
+ if (physPort)
+ physPort->removeConn();
+ else
+ physPort = new FunctionalPort(csprintf("%s-%d-funcport",
+ baseCpu->name(), _threadId));
+ connectToMemFunc(physPort);
+}
+
+void
+ThreadState::connectVirtPort(ThreadContext *tc)
+{
+ // @todo: For now this disregards any older port that may have
+ // already existed. Fix this memory leak once the bus port IDs
+ // for functional ports is resolved.
+ if (virtPort)
+ virtPort->removeConn();
+ else
+ virtPort = new VirtualPort(csprintf("%s-%d-vport",
+ baseCpu->name(), _threadId), tc);
+ connectToMemFunc(virtPort);
+}
void
ThreadState::profileClear()
return port;
/* Use this port to for syscall emulation writes to memory. */
- port = new TranslatingPort(csprintf("%s-%d-funcport",
- baseCpu->name(), tid),
- process->pTable, false);
+ port = new TranslatingPort(csprintf("%s-%d-funcport", baseCpu->name(), _threadId),
+ process, TranslatingPort::NextPage);
- 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;
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);
}