gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
thread_context_impl.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2012 ARM Limited
3  * Copyright (c) 2013 Advanced Micro Devices, Inc.
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 2004-2006 The Regents of The University of Michigan
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Authors: Kevin Lim
42  * Korey Sewell
43  */
44 
45 #ifndef __CPU_O3_THREAD_CONTEXT_IMPL_HH__
46 #define __CPU_O3_THREAD_CONTEXT_IMPL_HH__
47 
48 #include "arch/kernel_stats.hh"
49 #include "arch/registers.hh"
50 #include "config/the_isa.hh"
51 #include "cpu/o3/thread_context.hh"
52 #include "cpu/quiesce_event.hh"
53 #include "debug/O3CPU.hh"
54 
55 template <class Impl>
58 {
59  return thread->getVirtProxy();
60 }
61 
62 template <class Impl>
63 void
65 {
66  thread->dumpFuncProfile();
67 }
68 
69 template <class Impl>
70 void
72 {
73  ::takeOverFrom(*this, *old_context);
74  TheISA::Decoder *newDecoder = getDecoderPtr();
75  TheISA::Decoder *oldDecoder = old_context->getDecoderPtr();
76  newDecoder->takeOverFrom(oldDecoder);
77 
78  thread->kernelStats = old_context->getKernelStats();
79  thread->funcExeInst = old_context->readFuncExeInst();
80 
81  thread->noSquashFromTC = false;
82  thread->trapPending = false;
83 }
84 
85 template <class Impl>
86 void
88 {
89  DPRINTF(O3CPU, "Calling activate on Thread Context %d\n",
90  threadId());
91 
92  if (thread->status() == ThreadContext::Active)
93  return;
94 
95  thread->lastActivate = curTick();
96  thread->setStatus(ThreadContext::Active);
97 
98  // status() == Suspended
99  cpu->activateContext(thread->threadId());
100 }
101 
102 template <class Impl>
103 void
105 {
106  DPRINTF(O3CPU, "Calling suspend on Thread Context %d\n",
107  threadId());
108 
109  if (thread->status() == ThreadContext::Suspended)
110  return;
111 
112  thread->lastActivate = curTick();
113  thread->lastSuspend = curTick();
114 
115  thread->setStatus(ThreadContext::Suspended);
116  cpu->suspendContext(thread->threadId());
117 }
118 
119 template <class Impl>
120 void
122 {
123  DPRINTF(O3CPU, "Calling halt on Thread Context %d\n", threadId());
124 
125  if (thread->status() == ThreadContext::Halted)
126  return;
127 
128  thread->setStatus(ThreadContext::Halted);
129  cpu->haltContext(thread->threadId());
130 }
131 
132 template <class Impl>
133 void
135 {
136  if (FullSystem) {
137  thread->kernelStats = new TheISA::Kernel::Statistics(cpu->system);
138  thread->kernelStats->regStats(name + ".kern");
139  }
140 }
141 
142 template <class Impl>
143 Tick
145 {
146  return thread->lastActivate;
147 }
148 
149 template <class Impl>
150 Tick
152 {
153  return thread->lastSuspend;
154 }
155 
156 template <class Impl>
157 void
159 {
160  thread->profileClear();
161 }
162 
163 template <class Impl>
164 void
166 {
167  thread->profileSample();
168 }
169 
170 template <class Impl>
171 void
173 {
174  // Prevent squashing
175  thread->noSquashFromTC = true;
176  TheISA::copyRegs(tc, this);
177  thread->noSquashFromTC = false;
178 
179  if (!FullSystem)
180  this->thread->funcExeInst = tc->readFuncExeInst();
181 }
182 
183 template <class Impl>
184 void
186 {
187  cpu->isa[thread->threadId()]->clear();
188 }
189 
190 template <class Impl>
191 uint64_t
193 {
194  return cpu->readArchIntReg(reg_idx, thread->threadId());
195 }
196 
197 template <class Impl>
200 {
201  return cpu->readArchFloatReg(reg_idx, thread->threadId());
202 }
203 
204 template <class Impl>
207 {
208  return cpu->readArchFloatRegInt(reg_idx, thread->threadId());
209 }
210 
211 template <class Impl>
214 {
215  return cpu->readArchCCReg(reg_idx, thread->threadId());
216 }
217 
218 template <class Impl>
219 void
221 {
222  cpu->setArchIntReg(reg_idx, val, thread->threadId());
223 
224  conditionalSquash();
225 }
226 
227 template <class Impl>
228 void
230 {
231  cpu->setArchFloatReg(reg_idx, val, thread->threadId());
232 
233  conditionalSquash();
234 }
235 
236 template <class Impl>
237 void
239 {
240  cpu->setArchFloatRegInt(reg_idx, val, thread->threadId());
241 
242  conditionalSquash();
243 }
244 
245 template <class Impl>
246 void
248 {
249  cpu->setArchCCReg(reg_idx, val, thread->threadId());
250 
251  conditionalSquash();
252 }
253 
254 template <class Impl>
255 void
257 {
258  cpu->pcState(val, thread->threadId());
259 
260  conditionalSquash();
261 }
262 
263 template <class Impl>
264 void
266 {
267  cpu->pcState(val, thread->threadId());
268 
269  conditionalSquash();
270 }
271 
272 template <class Impl>
273 int
275 {
276  return cpu->isa[thread->threadId()]->flattenIntIndex(reg);
277 }
278 
279 template <class Impl>
280 int
282 {
283  return cpu->isa[thread->threadId()]->flattenFloatIndex(reg);
284 }
285 
286 template <class Impl>
287 int
289 {
290  return cpu->isa[thread->threadId()]->flattenCCIndex(reg);
291 }
292 
293 template <class Impl>
294 int
296 {
297  return cpu->isa[thread->threadId()]->flattenMiscIndex(reg);
298 }
299 
300 template <class Impl>
301 void
303 {
304  cpu->setMiscRegNoEffect(misc_reg, val, thread->threadId());
305 
306  conditionalSquash();
307 }
308 
309 #endif//__CPU_O3_THREAD_CONTEXT_IMPL_HH__
310 template <class Impl>
311 void
313 {
314  cpu->setMiscReg(misc_reg, val, thread->threadId());
315 
316  conditionalSquash();
317 }
318 
#define DPRINTF(x,...)
Definition: trace.hh:212
A TranslatingPortProxy in FS mode translates a virtual address to a physical address and then calls t...
uint8_t CCReg
Definition: registers.hh:57
virtual void copyArchRegs(ThreadContext *tc)
Copies the architectural registers from another TC into this TC.
Bitfield< 5, 3 > reg
Definition: types.hh:89
virtual TheISA::Decoder * getDecoderPtr()=0
const std::string & name()
Definition: trace.cc:49
virtual void activate()
Set the status to Active.
TheISA::MiscReg MiscReg
virtual void clearArchRegs()
Resets all architectural registers to 0.
virtual Counter readFuncExeInst()=0
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:146
virtual void setMiscReg(int misc_reg, const MiscReg &val)
Sets a misc.
virtual void dumpFuncProfile()
Dumps the function profiling information.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
virtual FloatReg readFloatRegFlat(int idx)
Bitfield< 63 > val
Definition: misc.hh:770
virtual void halt()
Set the status to Halted.
Tick curTick()
The current simulated tick.
Definition: core.hh:47
virtual FloatRegBits readFloatRegBitsFlat(int idx)
uint64_t FloatRegBits
Definition: registers.hh:51
virtual Tick readLastSuspend()
Reads the last tick that this thread was suspended on.
virtual int flattenCCIndex(int reg)
void takeOverFrom(ThreadContext &ntc, ThreadContext &otc)
Copy state between thread contexts in preparation for CPU handover.
uint64_t Tick
Tick count type.
Definition: types.hh:63
TheISA::FloatRegBits FloatRegBits
virtual void profileClear()
Clears the function profiling information.
virtual void setFloatRegBitsFlat(int idx, FloatRegBits val)
virtual void regStats(const std::string &name)
Registers statistics associated with this TC.
virtual void profileSample()
Samples the function profiling information.
virtual void suspend()
Set the status to Suspended.
virtual FSTranslatingPortProxy & getVirtProxy()
TheISA::FloatReg FloatReg
double FloatReg
Definition: registers.hh:50
virtual int flattenMiscIndex(int reg)
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val)
Sets a misc.
virtual CCReg readCCRegFlat(int idx)
virtual int flattenFloatIndex(int reg)
Permanently shut down.
virtual TheISA::PCState pcState()
Reads this thread's PC state.
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
virtual Tick readLastActivate()
Reads the last tick that this thread was activated on.
virtual uint64_t readIntRegFlat(int idx)
Flat register interfaces.
Impl::O3CPU O3CPU
void copyRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:65
virtual void pcStateNoRecord(const TheISA::PCState &val)
virtual void takeOverFrom(ThreadContext *old_context)
Takes over execution of a thread from another CPU.
Temporarily inactive.
virtual int flattenIntIndex(int reg)
virtual void setFloatRegFlat(int idx, FloatReg val)
virtual void setCCRegFlat(int idx, CCReg val)
virtual void setIntRegFlat(int idx, uint64_t val)
virtual TheISA::Kernel::Statistics * getKernelStats()=0

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6