thread_state.cc revision 2683:d6b72bb2ed97
1#include "base/output.hh"
2#include "cpu/profile.hh"
3#include "cpu/thread_state.hh"
4
5#if FULL_SYSTEM
6ThreadState::ThreadState(int _cpuId, int _tid)
7    : cpuId(_cpuId), tid(_tid), lastActivate(0), lastSuspend(0),
8      profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL),
9      funcExeInst(0), storeCondFailures(0)
10#else
11ThreadState::ThreadState(int _cpuId, int _tid, MemObject *mem,
12                         Process *_process, short _asid)
13    : cpuId(_cpuId), tid(_tid), lastActivate(0), lastSuspend(0),
14      process(_process), asid(_asid),
15      funcExeInst(0), storeCondFailures(0)
16#endif
17{
18#if !FULL_SYSTEM
19        /* Use this port to for syscall emulation writes to memory. */
20        Port *mem_port;
21        port = new TranslatingPort(csprintf("%d-funcport",
22                                            tid),
23                                   process->pTable, false);
24        mem_port = mem->getPort("functional");
25        mem_port->setPeer(port);
26        port->setPeer(mem_port);
27#endif
28}
29
30#if FULL_SYSTEM
31
32void
33ThreadState::profileClear()
34{
35    if (profile)
36        profile->clear();
37}
38
39void
40ThreadState::profileSample()
41{
42    if (profile)
43        profile->sample(profileNode, profilePC);
44}
45
46#endif
47