gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
thread_context.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-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) 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  */
43 
44 #ifndef __CPU_CHECKER_THREAD_CONTEXT_HH__
45 #define __CPU_CHECKER_THREAD_CONTEXT_HH__
46 
47 #include "arch/types.hh"
48 #include "config/the_isa.hh"
49 #include "cpu/checker/cpu.hh"
50 #include "cpu/simple_thread.hh"
51 #include "cpu/thread_context.hh"
52 #include "debug/Checker.hh"
53 
54 class EndQuiesceEvent;
55 namespace TheISA {
56  namespace Kernel {
57  class Statistics;
58  };
59  class Decoder;
60 };
61 
70 template <class TC>
72 {
73  public:
74  CheckerThreadContext(TC *actual_tc,
75  CheckerCPU *checker_cpu)
76  : actualTC(actual_tc), checkerTC(checker_cpu->thread),
77  checkerCPU(checker_cpu)
78  { }
79 
80  private:
83  TC *actualTC;
90 
91  public:
92 
93  BaseCPU *getCpuPtr() { return actualTC->getCpuPtr(); }
94 
95  uint32_t socketId() const { return actualTC->socketId(); }
96 
97  int cpuId() const { return actualTC->cpuId(); }
98 
99  ContextID contextId() const { return actualTC->contextId(); }
100 
102  {
103  actualTC->setContextId(id);
104  checkerTC->setContextId(id);
105  }
106 
108  int threadId() const { return actualTC->threadId(); }
109  void setThreadId(int id)
110  {
111  checkerTC->setThreadId(id);
112  actualTC->setThreadId(id);
113  }
114 
115  TheISA::TLB *getITBPtr() { return actualTC->getITBPtr(); }
116 
117  TheISA::TLB *getDTBPtr() { return actualTC->getDTBPtr(); }
118 
120  {
121  return checkerCPU;
122  }
123 
124  TheISA::Decoder *getDecoderPtr() { return actualTC->getDecoderPtr(); }
125 
126  System *getSystemPtr() { return actualTC->getSystemPtr(); }
127 
128  TheISA::Kernel::Statistics *getKernelStats()
129  { return actualTC->getKernelStats(); }
130 
131  Process *getProcessPtr() { return actualTC->getProcessPtr(); }
132 
133  void setProcessPtr(Process *p) { actualTC->setProcessPtr(p); }
134 
135  PortProxy &getPhysProxy() { return actualTC->getPhysProxy(); }
136 
138  { return actualTC->getVirtProxy(); }
139 
141  { actualTC->initMemProxies(tc); }
142 
144  {
145  actualTC->connectMemPorts(tc);
146  }
147 
148  SETranslatingPortProxy &getMemProxy() { return actualTC->getMemProxy(); }
149 
151  void syscall(int64_t callnum, Fault *fault)
152  { return actualTC->syscall(callnum, fault); }
153 
154  Status status() const { return actualTC->status(); }
155 
156  void setStatus(Status new_status)
157  {
158  actualTC->setStatus(new_status);
159  checkerTC->setStatus(new_status);
160  }
161 
163  void activate() { actualTC->activate(); }
164 
166  void suspend() { actualTC->suspend(); }
167 
169  void halt() { actualTC->halt(); }
170 
171  void dumpFuncProfile() { actualTC->dumpFuncProfile(); }
172 
173  void takeOverFrom(ThreadContext *oldContext)
174  {
175  actualTC->takeOverFrom(oldContext);
176  checkerTC->copyState(oldContext);
177  }
178 
179  void regStats(const std::string &name)
180  {
181  actualTC->regStats(name);
182  checkerTC->regStats(name);
183  }
184 
185  EndQuiesceEvent *getQuiesceEvent() { return actualTC->getQuiesceEvent(); }
186 
187  Tick readLastActivate() { return actualTC->readLastActivate(); }
188  Tick readLastSuspend() { return actualTC->readLastSuspend(); }
189 
190  void profileClear() { return actualTC->profileClear(); }
191  void profileSample() { return actualTC->profileSample(); }
192 
193  // @todo: Do I need this?
195  {
196  actualTC->copyArchRegs(tc);
197  checkerTC->copyArchRegs(tc);
198  }
199 
201  {
202  actualTC->clearArchRegs();
204  }
205 
206  //
207  // New accessors for new decoder.
208  //
209  uint64_t readIntReg(int reg_idx)
210  { return actualTC->readIntReg(reg_idx); }
211 
212  FloatReg readFloatReg(int reg_idx)
213  { return actualTC->readFloatReg(reg_idx); }
214 
216  { return actualTC->readFloatRegBits(reg_idx); }
217 
218  CCReg readCCReg(int reg_idx)
219  { return actualTC->readCCReg(reg_idx); }
220 
221  void setIntReg(int reg_idx, uint64_t val)
222  {
223  actualTC->setIntReg(reg_idx, val);
224  checkerTC->setIntReg(reg_idx, val);
225  }
226 
227  void setFloatReg(int reg_idx, FloatReg val)
228  {
229  actualTC->setFloatReg(reg_idx, val);
230  checkerTC->setFloatReg(reg_idx, val);
231  }
232 
233  void setFloatRegBits(int reg_idx, FloatRegBits val)
234  {
235  actualTC->setFloatRegBits(reg_idx, val);
236  checkerTC->setFloatRegBits(reg_idx, val);
237  }
238 
239  void setCCReg(int reg_idx, CCReg val)
240  {
241  actualTC->setCCReg(reg_idx, val);
242  checkerTC->setCCReg(reg_idx, val);
243  }
244 
247  { return actualTC->pcState(); }
248 
251  {
252  DPRINTF(Checker, "Changing PC to %s, old PC %s\n",
253  val, checkerTC->pcState());
254  checkerTC->pcState(val);
256  return actualTC->pcState(val);
257  }
258 
260  {
261  checkerTC->setNPC(val);
262  actualTC->setNPC(val);
263  }
264 
266  {
267  return actualTC->pcState(val);
268  }
269 
272  { return actualTC->instAddr(); }
273 
276  { return actualTC->nextInstAddr(); }
277 
280  { return actualTC->microPC(); }
281 
282  MiscReg readMiscRegNoEffect(int misc_reg) const
283  { return actualTC->readMiscRegNoEffect(misc_reg); }
284 
285  MiscReg readMiscReg(int misc_reg)
286  { return actualTC->readMiscReg(misc_reg); }
287 
288  void setMiscRegNoEffect(int misc_reg, const MiscReg &val)
289  {
290  DPRINTF(Checker, "Setting misc reg with no effect: %d to both Checker"
291  " and O3..\n", misc_reg);
292  checkerTC->setMiscRegNoEffect(misc_reg, val);
293  actualTC->setMiscRegNoEffect(misc_reg, val);
294  }
295 
296  void setMiscReg(int misc_reg, const MiscReg &val)
297  {
298  DPRINTF(Checker, "Setting misc reg with effect: %d to both Checker"
299  " and O3..\n", misc_reg);
300  checkerTC->setMiscReg(misc_reg, val);
301  actualTC->setMiscReg(misc_reg, val);
302  }
303 
304  int flattenIntIndex(int reg) { return actualTC->flattenIntIndex(reg); }
305  int flattenFloatIndex(int reg) { return actualTC->flattenFloatIndex(reg); }
306  int flattenCCIndex(int reg) { return actualTC->flattenCCIndex(reg); }
307  int flattenMiscIndex(int reg) { return actualTC->flattenMiscIndex(reg); }
308 
310  { return actualTC->readStCondFailures(); }
311 
312  void setStCondFailures(unsigned sc_failures)
313  {
314  actualTC->setStCondFailures(sc_failures);
315  }
316 
317  Counter readFuncExeInst() { return actualTC->readFuncExeInst(); }
318 
319  uint64_t readIntRegFlat(int idx)
320  { return actualTC->readIntRegFlat(idx); }
321 
322  void setIntRegFlat(int idx, uint64_t val)
323  { actualTC->setIntRegFlat(idx, val); }
324 
326  { return actualTC->readFloatRegFlat(idx); }
327 
328  void setFloatRegFlat(int idx, FloatReg val)
329  { actualTC->setFloatRegFlat(idx, val); }
330 
332  { return actualTC->readFloatRegBitsFlat(idx); }
333 
335  { actualTC->setFloatRegBitsFlat(idx, val); }
336 
338  { return actualTC->readCCRegFlat(idx); }
339 
340  void setCCRegFlat(int idx, CCReg val)
341  { actualTC->setCCRegFlat(idx, val); }
342 };
343 
344 #endif // __CPU_CHECKER_EXEC_CONTEXT_HH__
#define DPRINTF(x,...)
Definition: trace.hh:212
A TranslatingPortProxy in FS mode translates a virtual address to a physical address and then calls t...
void setContextId(ContextID id)
Definition: thread_state.hh:76
CheckerCPU * checkerCPU
Pointer to the checker CPU.
void setProcessPtr(Process *p)
int flattenMiscIndex(int reg)
void setMiscReg(int misc_reg, const MiscReg &val, ThreadID tid=0)
TheISA::Decoder * getDecoderPtr()
CCReg readCCRegFlat(int idx)
Bitfield< 5, 3 > reg
Definition: types.hh:89
void setThreadId(int id)
void setFloatRegBits(int reg_idx, FloatRegBits val)
void regStats(const std::string &name)
const std::string & name()
Definition: trace.cc:49
CheckerCPU class.
Definition: cpu.hh:91
int threadId() const
Returns this thread's ID number.
uint32_t socketId() const
FloatReg readFloatRegFlat(int idx)
void setStatus(Status newStatus)
TheISA::MiscReg MiscReg
void copyArchRegs(ThreadContext *tc)
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
Definition: system.hh:83
void setThreadId(ThreadID id)
Definition: thread_state.hh:78
void setFloatRegBitsFlat(int idx, FloatRegBits val)
void pcState(const TheISA::PCState &val)
Sets this thread's PC state.
void setNPC(Addr val)
void setIntRegFlat(int idx, uint64_t val)
void setFloatRegFlat(int idx, FloatReg val)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void setIntReg(int reg_idx, uint64_t val)
int flattenFloatIndex(int reg)
Event for timing out quiesce instruction.
void setMiscReg(int misc_reg, const MiscReg &val)
void setStatus(Status new_status)
TC * actualTC
The main CPU's ThreadContext, or class that implements the ThreadContext interface.
void setCCReg(int reg_idx, CCReg val)
Bitfield< 63 > val
Definition: misc.hh:770
Templated Checker class.
Definition: cpu.hh:433
int flattenCCIndex(int reg)
FloatRegBits readFloatRegBits(int reg_idx)
int flattenIntIndex(int reg)
MiscReg readMiscReg(int misc_reg)
Derived ThreadContext class for use with the Checker.
EndQuiesceEvent * getQuiesceEvent()
SETranslatingPortProxy & getMemProxy()
uint64_t Tick
Tick count type.
Definition: types.hh:63
FloatReg readFloatReg(int reg_idx)
TheISA::FloatRegBits FloatRegBits
CCReg readCCReg(int reg_idx)
ContextID contextId() const
void setMiscRegNoEffect(int misc_reg, const MiscReg &val, ThreadID tid=0)
unsigned readStCondFailures()
Addr instAddr()
Reads this thread's PC.
TheISA::PCState pcState()
Reads this thread's PC state.
uint16_t MicroPC
Definition: types.hh:144
FSTranslatingPortProxy & getVirtProxy()
uint64_t readIntReg(int reg_idx)
MicroPC microPC()
Reads this thread's next PC.
TheISA::FloatReg FloatReg
void setFloatRegBits(int reg_idx, FloatRegBits val)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void setFloatReg(int reg_idx, FloatReg val)
void setStCondFailures(unsigned sc_failures)
int64_t Counter
Statistics counter type.
Definition: types.hh:58
void setFloatReg(int reg_idx, FloatReg val)
void activate()
Set the status to Active.
void setCCRegFlat(int idx, CCReg val)
CheckerThreadContext(TC *actual_tc, CheckerCPU *checker_cpu)
CheckerCPU * getCheckerCpuPtr()
TheISA::PCState pcState()
This object is a proxy for a structural port, to be used for debug accesses.
Definition: port_proxy.hh:84
Status status() const
void setIntReg(int reg_idx, uint64_t val)
void syscall(int64_t callnum, Fault *fault)
Executes a syscall in SE mode.
void regStats(const std::string &name)
void pcStateNoRecord(const TheISA::PCState &val)
TheISA::CCReg CCReg
void copyArchRegs(ThreadContext *tc)
void copyState(ThreadContext *oldContext)
void initMemProxies(ThreadContext *tc)
Initialise the physical and virtual port proxies and tie them to the data port of the CPU...
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
void setContextId(ContextID id)
void suspend()
Set the status to Suspended.
void halt()
Set the status to Halted.
TheISA::TLB * getITBPtr()
PortProxy & getPhysProxy()
uint64_t readIntRegFlat(int idx)
Flat register interfaces.
void setCCReg(int reg_idx, CCReg val)
SimpleThread * checkerTC
The checker's own SimpleThread.
void recordPCChange(const TheISA::PCState &val)
Definition: cpu.hh:346
void clearArchRegs()
TheISA::TLB * getDTBPtr()
TheISA::Kernel::Statistics * getKernelStats()
void takeOverFrom(ThreadContext *oldContext)
void setMiscRegNoEffect(int misc_reg, const MiscReg &val)
Bitfield< 0 > p
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
Addr nextInstAddr()
Reads this thread's next PC.
MiscReg readMiscRegNoEffect(int misc_reg) const
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
void setNPC(Addr val)
FloatRegBits readFloatRegBitsFlat(int idx)
void connectMemPorts(ThreadContext *tc)

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