2 * Copyright (c) 2006 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef __CPU_THREAD_STATE_HH__
30 #define __CPU_THREAD_STATE_HH__
32 #include "cpu/exec_context.hh"
35 #include "mem/translating_port.hh"
39 class EndQuiesceEvent;
40 class FunctionProfile;
46 class FunctionalMemory;
51 * Struct for holding general thread state that is needed across CPU
52 * models. This includes things such as pointers to the process,
53 * memory, quiesce events, and certain stats. This can be expanded
54 * to hold more thread-specific stats within it.
58 ThreadState(int _cpuId, int _tid)
59 : cpuId(_cpuId), tid(_tid), lastActivate(0), lastSuspend(0),
60 profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL)
62 ThreadState(int _cpuId, int _tid, MemObject *mem,
63 Process *_process, short _asid)
64 : cpuId(_cpuId), tid(_tid), process(_process), asid(_asid)
68 storeCondFailures = 0;
70 /* Use this port to for syscall emulation writes to memory. */
72 port = new TranslatingPort(csprintf("%d-funcport",
74 process->pTable, false);
75 mem_port = mem->getPort("functional");
76 mem_port->setPeer(port);
77 port->setPeer(mem_port);
81 ExecContext::Status status;
85 // Index of hardware thread context on the CPU that this represents.
89 Stats::Scalar<> numInsts;
90 Stats::Scalar<> numMemRefs;
92 // number of simulated loads
100 FunctionProfile *profile;
101 ProfileNode *profileNode;
104 EndQuiesceEvent *quiesceEvent;
106 Kernel::Statistics *kernelStats;
108 TranslatingPort *port;
112 // Address space ID. Note that this is used for TIMING cache
113 // simulation only; all functional memory accesses should use
114 // one of the FunctionalMemory pointers above.
120 * Temporary storage to pass the source address from copy_load to
122 * @todo Remove this temporary when we have a better way to do it.
126 * Temp storage for the physical source address of a copy.
127 * @todo Remove this temporary when we have a better way to do it.
129 Addr copySrcPhysAddr;
132 * number of executed instructions, for matching with syscall trace
133 * points in EIO files.
138 // Count failed store conditionals so we can warn of apparent
139 // application deadlock situations.
140 unsigned storeCondFailures;
143 #endif // __CPU_THREAD_STATE_HH__