gem5  v20.1.0.0
thread_state.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  */
28 
29 #include "cpu/thread_state.hh"
30 
31 #include "base/output.hh"
32 #include "cpu/base.hh"
33 #include "mem/port.hh"
34 #include "mem/port_proxy.hh"
37 #include "sim/full_system.hh"
38 #include "sim/serialize.hh"
39 #include "sim/system.hh"
40 
42  : numInst(0), numOp(0), threadStats(cpu, this),
43  numLoad(0), startNumLoad(0),
44  _status(ThreadContext::Halted), baseCpu(cpu),
45  _contextId(0), _threadId(_tid), lastActivate(0), lastSuspend(0),
46  process(_process), physProxy(NULL), virtProxy(NULL),
47  funcExeInst(0), storeCondFailures(0)
48 {
49 }
50 
52 {
53  if (physProxy != NULL)
54  delete physProxy;
55  if (virtProxy != NULL)
56  delete virtProxy;
57 }
58 
59 void
61 {
63  // thread_num and cpu_id are deterministic from the config
65 
66  if (!FullSystem)
67  return;
68 }
69 
70 void
72 {
73 
75  // thread_num and cpu_id are deterministic from the config
77 
78  if (!FullSystem)
79  return;
80 }
81 
82 void
84 {
85  // The port proxies only refer to the data port on the CPU side
86  // and can safely be done at init() time even if the CPU is not
87  // connected, i.e. when restoring from a checkpoint and later
88  // switching the CPU in.
89  if (FullSystem) {
90  assert(physProxy == NULL);
91  // This cannot be done in the constructor as the thread state
92  // itself is created in the base cpu constructor and the
93  // getSendFunctional is a virtual function
96 
97  assert(virtProxy == NULL);
99  } else {
100  assert(virtProxy == NULL);
103  }
104 }
105 
106 PortProxy &
108 {
109  assert(FullSystem);
110  assert(physProxy != NULL);
111  return *physProxy;
112 }
113 
114 PortProxy &
116 {
117  assert(virtProxy != NULL);
118  return *virtProxy;
119 }
120 
122  ThreadState *thread)
123  : Stats::Group(cpu, csprintf("thread%i", thread->threadId()).c_str()),
124  ADD_STAT(numInsts, "Number of Instructions committed"),
125  ADD_STAT(numOps, "Number of Ops committed"),
126  ADD_STAT(numMemRefs, "Number of Memory References")
127 {
128 
129 }
thread_state.hh
ThreadState::funcExeInst
Counter funcExeInst
Definition: thread_state.hh:166
SETranslatingPortProxy
Definition: se_translating_port_proxy.hh:46
system.hh
serialize.hh
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:797
Process
Definition: process.hh:65
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
ThreadState::virtProxy
PortProxy * virtProxy
A translating port proxy, outgoing only, for functional accesse to virtual addresses.
Definition: thread_state.hh:159
BaseCPU::cacheLineSize
unsigned int cacheLineSize() const
Get the cache line size of the system.
Definition: base.hh:376
translating_port_proxy.hh
FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:132
output.hh
BaseCPU::getSendFunctional
virtual PortProxy::SendFunctionalFunc getSendFunctional()
Returns a sendFunctional delegate for use with port proxies.
Definition: base.hh:162
SERIALIZE_ENUM
#define SERIALIZE_ENUM(scalar)
Definition: serialize.hh:813
ThreadState
Struct for holding general thread state that is needed across CPU models.
Definition: thread_state.hh:46
ThreadState::_status
ThreadContext::Status _status
Definition: thread_state.hh:132
cp
Definition: cprintf.cc:40
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:67
ThreadState::getPhysProxy
PortProxy & getPhysProxy()
Definition: thread_state.cc:107
port_proxy.hh
SETranslatingPortProxy::NextPage
@ NextPage
Definition: se_translating_port_proxy.hh:53
port.hh
ThreadState::physProxy
PortProxy * physProxy
A port proxy outgoing only for functional accesses to physical addresses.
Definition: thread_state.hh:155
ThreadState::ThreadState
ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
Definition: thread_state.cc:41
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:790
ThreadState::baseCpu
BaseCPU * baseCpu
Definition: thread_state.hh:135
full_system.hh
BaseCPU
Definition: cpu_dummy.hh:43
TranslatingPortProxy
This proxy attempts to translate virtual addresses using the TLBs.
Definition: translating_port_proxy.hh:55
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
ThreadState::initMemProxies
void initMemProxies(ThreadContext *tc)
Initialise the physical and virtual port proxies and tie them to the data port of the CPU.
Definition: thread_state.cc:83
base.hh
ThreadState::~ThreadState
virtual ~ThreadState()
Definition: thread_state.cc:51
ThreadState::getVirtProxy
PortProxy & getVirtProxy()
Definition: thread_state.cc:115
ThreadState::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: thread_state.cc:71
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
Stats
Definition: statistics.cc:61
UNSERIALIZE_ENUM
#define UNSERIALIZE_ENUM(scalar)
Definition: serialize.hh:820
se_translating_port_proxy.hh
ThreadState::ThreadStateStats::ThreadStateStats
ThreadStateStats(BaseCPU *cpu, ThreadState *thread)
Definition: thread_state.cc:121
CheckpointIn
Definition: serialize.hh:67
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
ThreadState::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: thread_state.cc:60

Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17