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) 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  */
43 
44 #ifndef __CPU_O3_THREAD_CONTEXT_HH__
45 #define __CPU_O3_THREAD_CONTEXT_HH__
46 
47 #include "config/the_isa.hh"
48 #include "cpu/o3/isa_specific.hh"
49 #include "cpu/thread_context.hh"
50 
51 class EndQuiesceEvent;
52 namespace Kernel {
53  class Statistics;
54 }
55 
69 template <class Impl>
70 class O3ThreadContext : public ThreadContext
71 {
72  public:
73  typedef typename Impl::O3CPU O3CPU;
74 
77 
80 
82  TheISA::TLB *getITBPtr() { return cpu->itb; }
83 
85  TheISA::TLB *getDTBPtr() { return cpu->dtb; }
86 
87  CheckerCPU *getCheckerCpuPtr() { return NULL; }
88 
89  TheISA::Decoder *
91  {
92  return cpu->fetch.decoder[thread->threadId()];
93  }
94 
96  virtual BaseCPU *getCpuPtr() { return cpu; }
97 
99  virtual int cpuId() const { return cpu->cpuId(); }
100 
102  virtual uint32_t socketId() const { return cpu->socketId(); }
103 
104  virtual ContextID contextId() const { return thread->contextId(); }
105 
106  virtual void setContextId(int id) { thread->setContextId(id); }
107 
109  virtual int threadId() const { return thread->threadId(); }
110  virtual void setThreadId(int id) { return thread->setThreadId(id); }
111 
113  virtual System *getSystemPtr() { return cpu->system; }
114 
116  virtual TheISA::Kernel::Statistics *getKernelStats()
117  { return thread->kernelStats; }
118 
120  virtual Process *getProcessPtr() { return thread->getProcessPtr(); }
121 
122  virtual void setProcessPtr(Process *p) { thread->setProcessPtr(p); }
123 
124  virtual PortProxy &getPhysProxy() { return thread->getPhysProxy(); }
125 
127 
128  virtual void initMemProxies(ThreadContext *tc)
129  { thread->initMemProxies(tc); }
130 
132  { return thread->getMemProxy(); }
133 
135  virtual Status status() const { return thread->status(); }
136 
138  virtual void setStatus(Status new_status)
139  { thread->setStatus(new_status); }
140 
142  virtual void activate();
143 
145  virtual void suspend();
146 
148  virtual void halt();
149 
153  virtual void dumpFuncProfile();
154 
156  virtual void takeOverFrom(ThreadContext *old_context);
157 
159  virtual void regStats(const std::string &name);
160 
162  virtual Tick readLastActivate();
164  virtual Tick readLastSuspend();
165 
167  virtual void profileClear();
169  virtual void profileSample();
170 
172  virtual void copyArchRegs(ThreadContext *tc);
173 
175  virtual void clearArchRegs();
176 
178  virtual uint64_t readIntReg(int reg_idx) {
179  return readIntRegFlat(flattenIntIndex(reg_idx));
180  }
181 
182  virtual FloatReg readFloatReg(int reg_idx) {
183  return readFloatRegFlat(flattenFloatIndex(reg_idx));
184  }
185 
186  virtual FloatRegBits readFloatRegBits(int reg_idx) {
187  return readFloatRegBitsFlat(flattenFloatIndex(reg_idx));
188  }
189 
190  virtual CCReg readCCReg(int reg_idx) {
191  return readCCRegFlat(flattenCCIndex(reg_idx));
192  }
193 
195  virtual void setIntReg(int reg_idx, uint64_t val) {
196  setIntRegFlat(flattenIntIndex(reg_idx), val);
197  }
198 
199  virtual void setFloatReg(int reg_idx, FloatReg val) {
200  setFloatRegFlat(flattenFloatIndex(reg_idx), val);
201  }
202 
203  virtual void setFloatRegBits(int reg_idx, FloatRegBits val) {
204  setFloatRegBitsFlat(flattenFloatIndex(reg_idx), val);
205  }
206 
207  virtual void setCCReg(int reg_idx, CCReg val) {
208  setCCRegFlat(flattenCCIndex(reg_idx), val);
209  }
210 
213  { return cpu->pcState(thread->threadId()); }
214 
216  virtual void pcState(const TheISA::PCState &val);
217 
218  virtual void pcStateNoRecord(const TheISA::PCState &val);
219 
221  virtual Addr instAddr()
222  { return cpu->instAddr(thread->threadId()); }
223 
225  virtual Addr nextInstAddr()
226  { return cpu->nextInstAddr(thread->threadId()); }
227 
229  virtual MicroPC microPC()
230  { return cpu->microPC(thread->threadId()); }
231 
233  virtual MiscReg readMiscRegNoEffect(int misc_reg) const
234  { return cpu->readMiscRegNoEffect(misc_reg, thread->threadId()); }
235 
238  virtual MiscReg readMiscReg(int misc_reg)
239  { return cpu->readMiscReg(misc_reg, thread->threadId()); }
240 
242  virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val);
243 
246  virtual void setMiscReg(int misc_reg, const MiscReg &val);
247 
248  virtual int flattenIntIndex(int reg);
249  virtual int flattenFloatIndex(int reg);
250  virtual int flattenCCIndex(int reg);
251  virtual int flattenMiscIndex(int reg);
252 
254  // @todo: Figure out where these store cond failures should go.
255  virtual unsigned readStCondFailures()
256  { return thread->storeCondFailures; }
257 
259  virtual void setStCondFailures(unsigned sc_failures)
260  { thread->storeCondFailures = sc_failures; }
261 
263  virtual void syscall(int64_t callnum, Fault *fault)
264  { return cpu->syscall(callnum, thread->threadId(), fault); }
265 
267  virtual Counter readFuncExeInst() { return thread->funcExeInst; }
268 
271  {
272  return this->thread->quiesceEvent;
273  }
279  inline void conditionalSquash()
280  {
282  cpu->squashFromTC(thread->threadId());
283  }
284 
285  virtual uint64_t readIntRegFlat(int idx);
286  virtual void setIntRegFlat(int idx, uint64_t val);
287 
288  virtual FloatReg readFloatRegFlat(int idx);
289  virtual void setFloatRegFlat(int idx, FloatReg val);
290 
291  virtual FloatRegBits readFloatRegBitsFlat(int idx);
292  virtual void setFloatRegBitsFlat(int idx, FloatRegBits val);
293 
294  virtual CCReg readCCRegFlat(int idx);
295  virtual void setCCRegFlat(int idx, CCReg val);
296 };
297 
298 #endif
virtual SETranslatingPortProxy & getMemProxy()
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
virtual MiscReg readMiscReg(int misc_reg)
Reads a misc.
virtual void copyArchRegs(ThreadContext *tc)
Copies the architectural registers from another TC into this TC.
bool trapPending
Whether or not the thread is currently waiting on a trap, and thus able to be externally updated with...
Definition: thread_state.hh:89
Bitfield< 5, 3 > reg
Definition: types.hh:89
virtual PortProxy & getPhysProxy()
const std::string & name()
Definition: trace.cc:49
CheckerCPU class.
Definition: cpu.hh:91
virtual void activate()
Set the status to Active.
virtual Addr nextInstAddr()
Reads this thread's next PC.
virtual int cpuId() const
Reads this CPU's ID.
PortProxy & getPhysProxy()
virtual TheISA::Kernel::Statistics * getKernelStats()
Returns a pointer to this thread's kernel statistics.
TheISA::MiscReg MiscReg
virtual void clearArchRegs()
Resets all architectural registers to 0.
virtual uint32_t socketId() const
Reads this CPU's Socket ID.
virtual void setStatus(Status new_status)
Sets this thread's status.
Counter funcExeInst
virtual CCReg readCCReg(int reg_idx)
virtual void setMiscReg(int misc_reg, const MiscReg &val)
Sets a misc.
virtual void dumpFuncProfile()
Dumps the function profiling information.
Definition: system.hh:83
void setThreadId(ThreadID id)
Definition: thread_state.hh:78
virtual MiscReg readMiscRegNoEffect(int misc_reg) const
Reads a miscellaneous register.
virtual void setThreadId(int id)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Status status() const
Returns the status of this thread.
virtual FloatReg readFloatRegFlat(int idx)
Event for timing out quiesce instruction.
EndQuiesceEvent * quiesceEvent
Bitfield< 63 > val
Definition: misc.hh:770
ThreadID threadId() const
Definition: thread_state.hh:80
void setStatus(Status new_status)
Sets the status of this thread.
virtual MicroPC microPC()
Reads this thread's next PC.
virtual void syscall(int64_t callnum, Fault *fault)
Executes a syscall in SE mode.
virtual void halt()
Set the status to Halted.
virtual FloatRegBits readFloatRegBitsFlat(int idx)
virtual void initMemProxies(ThreadContext *tc)
Initialise the physical and virtual port proxies and tie them to the data port of the CPU...
virtual Tick readLastSuspend()
Reads the last tick that this thread was suspended on.
void setProcessPtr(Process *p)
virtual int flattenCCIndex(int reg)
virtual void setFloatReg(int reg_idx, FloatReg val)
TheISA::TLB * getDTBPtr()
Returns a pointer to the DTB.
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 BaseCPU * getCpuPtr()
Returns a pointer to this CPU.
TheISA::Decoder * getDecoderPtr()
virtual void profileSample()
Samples the function profiling information.
virtual void setFloatRegBits(int reg_idx, FloatRegBits val)
virtual uint64_t readIntReg(int reg_idx)
Reads an integer register.
virtual void setCCReg(int reg_idx, CCReg val)
virtual void suspend()
Set the status to Suspended.
virtual FSTranslatingPortProxy & getVirtProxy()
uint16_t MicroPC
Definition: types.hh:144
CheckerCPU * getCheckerCpuPtr()
TheISA::FloatReg FloatReg
virtual void setContextId(int id)
virtual System * getSystemPtr()
Returns a pointer to the system.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
virtual int flattenMiscIndex(int reg)
int64_t Counter
Statistics counter type.
Definition: types.hh:58
virtual Status status() const
Returns this thread's status.
void initMemProxies(ThreadContext *tc)
Initialise the physical and virtual port proxies and tie them to the data port of the CPU...
TheISA::TLB * getITBPtr()
Returns a pointer to the ITB.
This object is a proxy for a structural port, to be used for debug accesses.
Definition: port_proxy.hh:84
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val)
Sets a misc.
TheISA::Kernel::Statistics * kernelStats
virtual void setStCondFailures(unsigned sc_failures)
Sets the number of consecutive store conditional failures.
O3CPU * cpu
Pointer to the CPU.
virtual Addr instAddr()
Reads this thread's PC.
virtual CCReg readCCRegFlat(int idx)
virtual Process * getProcessPtr()
Returns a pointer to this thread's process.
Process * getProcessPtr()
virtual int flattenFloatIndex(int reg)
virtual FloatReg readFloatReg(int reg_idx)
TheISA::CCReg CCReg
virtual int threadId() const
Returns this thread's ID number.
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.
O3ThreadState< Impl > * thread
Pointer to the thread state that this TC corrseponds to.
SETranslatingPortProxy & getMemProxy()
virtual uint64_t readIntRegFlat(int idx)
Flat register interfaces.
virtual unsigned readStCondFailures()
Returns the number of consecutive store conditional failures.
virtual void setProcessPtr(Process *p)
Impl::O3CPU O3CPU
virtual void pcStateNoRecord(const TheISA::PCState &val)
virtual void takeOverFrom(ThreadContext *old_context)
Takes over execution of a thread from another CPU.
Derived ThreadContext class for use with the O3CPU.
Definition: cpu.hh:75
unsigned storeCondFailures
virtual EndQuiesceEvent * getQuiesceEvent()
Returns pointer to the quiesce event.
virtual FloatRegBits readFloatRegBits(int reg_idx)
virtual int flattenIntIndex(int reg)
ContextID contextId() const
Definition: thread_state.hh:74
virtual void setIntReg(int reg_idx, uint64_t val)
Sets an integer register to a value.
Bitfield< 0 > p
virtual void setFloatRegFlat(int idx, FloatReg val)
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
virtual void setCCRegFlat(int idx, CCReg val)
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
virtual void setIntRegFlat(int idx, uint64_t val)
virtual Counter readFuncExeInst()
Reads the funcExeInst counter.
void conditionalSquash()
check if the cpu is currently in state update mode and squash if not.
virtual ContextID contextId() const

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