gem5  v22.1.0.0
thread_context.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012, 2016-2018, 2020 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 
42 #ifndef __CPU_O3_THREAD_CONTEXT_HH__
43 #define __CPU_O3_THREAD_CONTEXT_HH__
44 
45 #include "cpu/o3/cpu.hh"
46 #include "cpu/thread_context.hh"
47 
48 namespace gem5
49 {
50 
51 namespace o3
52 {
53 
68 {
69  public:
71  CPU *cpu;
72 
73  bool
74  schedule(PCEvent *e) override
75  {
76  return thread->pcEventQueue.schedule(e);
77  }
78  bool
79  remove(PCEvent *e) override
80  {
81  return thread->pcEventQueue.remove(e);
82  }
83 
84  void
86  {
88  }
89  void
91  {
93  }
94  Tick
96  {
98  }
99 
102 
104  BaseMMU *getMMUPtr() override { return cpu->mmu; }
105 
106  CheckerCPU *getCheckerCpuPtr() override { return NULL; }
107 
108  BaseISA *
109  getIsaPtr() const override
110  {
111  return cpu->isa[thread->threadId()];
112  }
113 
114  InstDecoder *
115  getDecoderPtr() override
116  {
117  return cpu->fetch.decoder[thread->threadId()];
118  }
119 
121  BaseCPU *getCpuPtr() override { return cpu; }
122 
124  int cpuId() const override { return cpu->cpuId(); }
125 
127  uint32_t socketId() const override { return cpu->socketId(); }
128 
129  ContextID contextId() const override { return thread->contextId(); }
130 
131  void setContextId(ContextID id) override { thread->setContextId(id); }
132 
134  int threadId() const override { return thread->threadId(); }
135  void setThreadId(int id) override { return thread->setThreadId(id); }
136 
138  System *getSystemPtr() override { return cpu->system; }
139 
141  Process *getProcessPtr() override { return thread->getProcessPtr(); }
142 
143  void setProcessPtr(Process *p) override { thread->setProcessPtr(p); }
144 
146  Status status() const override { return thread->status(); }
147 
149  void
150  setStatus(Status new_status) override
151  {
152  thread->setStatus(new_status);
153  }
154 
156  void activate() override;
157 
159  void suspend() override;
160 
162  void halt() override;
163 
165  void takeOverFrom(gem5::ThreadContext *old_context) override;
166 
168  Tick readLastActivate() override;
170  Tick readLastSuspend() override;
171 
173  void copyArchRegs(gem5::ThreadContext *tc) override;
174 
176  void clearArchRegs() override;
177 
179  const PCStateBase &
180  pcState() const override
181  {
182  return cpu->pcState(thread->threadId());
183  }
184 
186  void pcState(const PCStateBase &val) override;
187 
188  void pcStateNoRecord(const PCStateBase &val) override;
189 
191  RegVal
192  readMiscRegNoEffect(RegIndex misc_reg) const override
193  {
194  return cpu->readMiscRegNoEffect(misc_reg, thread->threadId());
195  }
196 
199  RegVal
200  readMiscReg(RegIndex misc_reg) override
201  {
202  return cpu->readMiscReg(misc_reg, thread->threadId());
203  }
204 
206  void setMiscRegNoEffect(RegIndex misc_reg, RegVal val) override;
207 
210  void setMiscReg(RegIndex misc_reg, RegVal val) override;
211 
213  // @todo: Figure out where these store cond failures should go.
214  unsigned
215  readStCondFailures() const override
216  {
217  return thread->storeCondFailures;
218  }
219 
221  void
222  setStCondFailures(unsigned sc_failures) override
223  {
224  thread->storeCondFailures = sc_failures;
225  }
226 
232  void
234  {
237  }
238 
239  RegVal getReg(const RegId &reg) const override;
240  void getReg(const RegId &reg, void *val) const override;
241  void *getWritableReg(const RegId &reg) override;
242 
243  void setReg(const RegId &reg, RegVal val) override;
244  void setReg(const RegId &reg, const void *val) override;
245 
246  // hardware transactional memory
247  void htmAbortTransaction(uint64_t htm_uid,
248  HtmFailureFaultCause cause) override;
250  void setHtmCheckpointPtr(BaseHTMCheckpointPtr new_cpt) override;
251 };
252 
253 } // namespace o3
254 } // namespace gem5
255 
256 #endif
uint32_t socketId() const
Reads this CPU's Socket ID.
Definition: base.hh:186
int cpuId() const
Reads this CPU's ID.
Definition: base.hh:183
CheckerCPU class.
Definition: cpu.hh:85
bool remove(PCEvent *event) override
Definition: pc_event.cc:51
bool schedule(PCEvent *event) override
Definition: pc_event.cc:71
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:91
ThreadContext is the external interface to all thread state for anything outside of the CPU.
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition: cpu.hh:94
std::vector< BaseISA * > isa
Definition: cpu.hh:444
void squashFromTC(ThreadID tid)
Initiates a squash of all in-flight instructions for a given thread.
Definition: cpu.cc:1209
BaseMMU * mmu
Definition: cpu.hh:110
System * system
Pointer to the system.
Definition: cpu.hh:527
RegVal readMiscRegNoEffect(int misc_reg, ThreadID tid) const
Register accessors.
Definition: cpu.cc:1011
Fetch fetch
The fetch stage.
Definition: cpu.hh:402
void pcState(const PCStateBase &new_pc_state, ThreadID tid)
Sets the commit PC state of a specific thread.
Definition: cpu.cc:1203
RegVal readMiscReg(int misc_reg, ThreadID tid)
Reads a misc.
Definition: cpu.cc:1017
InstDecoder * decoder[MaxThreads]
The decoder.
Definition: fetch.hh:358
Derived ThreadContext class for use with the O3CPU.
InstDecoder * getDecoderPtr() override
void setHtmCheckpointPtr(BaseHTMCheckpointPtr new_cpt) override
void conditionalSquash()
check if the cpu is currently in state update mode and squash if not.
ThreadState * thread
Pointer to the thread state that this TC corrseponds to.
void pcStateNoRecord(const PCStateBase &val) override
bool remove(PCEvent *e) override
void clearArchRegs() override
Resets all architectural registers to 0.
uint32_t socketId() const override
Reads this CPU's Socket ID.
void setThreadId(int id) override
void setContextId(ContextID id) override
void setProcessPtr(Process *p) override
Status status() const override
Returns this thread's status.
BaseISA * getIsaPtr() const override
void htmAbortTransaction(uint64_t htm_uid, HtmFailureFaultCause cause) override
BaseMMU * getMMUPtr() override
Returns a pointer to the MMU.
Tick readLastActivate() override
Reads the last tick that this thread was activated on.
void scheduleInstCountEvent(Event *event, Tick count) override
void * getWritableReg(const RegId &reg) override
void setMiscReg(RegIndex misc_reg, RegVal val) override
Sets a misc.
int cpuId() const override
Reads this CPU's ID.
void activate() override
Set the status to Active.
void suspend() override
Set the status to Suspended.
int threadId() const override
Returns this thread's ID number.
Process * getProcessPtr() override
Returns a pointer to this thread's process.
void halt() override
Set the status to Halted.
void setStCondFailures(unsigned sc_failures) override
Sets the number of consecutive store conditional failures.
void takeOverFrom(gem5::ThreadContext *old_context) override
Takes over execution of a thread from another CPU.
Tick getCurrentInstCount() override
void setStatus(Status new_status) override
Sets this thread's status.
unsigned readStCondFailures() const override
Returns the number of consecutive store conditional failures.
Tick readLastSuspend() override
Reads the last tick that this thread was suspended on.
System * getSystemPtr() override
Returns a pointer to the system.
CPU * cpu
Pointer to the CPU.
void descheduleInstCountEvent(Event *event) override
void setReg(const RegId &reg, RegVal val) override
RegVal getReg(const RegId &reg) const override
BaseHTMCheckpointPtr & getHtmCheckpointPtr() override
void setMiscRegNoEffect(RegIndex misc_reg, RegVal val) override
Sets a misc.
bool schedule(PCEvent *e) override
RegVal readMiscReg(RegIndex misc_reg) override
Reads a misc.
CheckerCPU * getCheckerCpuPtr() override
const PCStateBase & pcState() const override
Reads this thread's PC state.
void copyArchRegs(gem5::ThreadContext *tc) override
Copies the architectural registers from another TC into this TC.
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
Reads a miscellaneous register.
BaseCPU * getCpuPtr() override
Returns a pointer to this CPU.
ContextID contextId() const override
Class that has various thread state, such as the status, the current instruction being processed,...
Definition: thread_state.hh:67
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
EventQueue comInstEventQueue
An instruction-based event queue.
Definition: thread_state.hh:74
PCEventQueue pcEventQueue
Definition: thread_state.hh:69
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
Definition: eventq.hh:764
void deschedule(Event *event)
Deschedule the specified event.
Definition: eventq.hh:797
Tick getCurTick() const
While curTick() is useful for any object assigned to this event queue, if an object that is assigned ...
Definition: eventq.hh:857
Bitfield< 9 > e
Definition: misc_types.hh:65
Bitfield< 10, 5 > event
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 5, 3 > reg
Definition: types.hh:92
Bitfield< 63 > val
Definition: misc.hh:776
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint16_t RegIndex
Definition: types.hh:176
uint64_t Tick
Tick count type.
Definition: types.hh:58
int ContextID
Globally unique thread context ID.
Definition: types.hh:239
uint64_t RegVal
Definition: types.hh:173
std::unique_ptr< BaseHTMCheckpoint > BaseHTMCheckpointPtr
Definition: htm.hh:125
HtmFailureFaultCause
Definition: htm.hh:48
ThreadID threadId() const
Definition: thread_state.hh:69
void setStatus(Status new_status)
Sets the status of this thread.
Definition: thread_state.hh:83
Process * getProcessPtr()
Definition: thread_state.hh:75
unsigned storeCondFailures
void setProcessPtr(Process *p)
Definition: thread_state.hh:77
ContextID contextId() const
Definition: thread_state.hh:63
void setContextId(ContextID id)
Definition: thread_state.hh:65
Status status() const
Returns the status of this thread.
Definition: thread_state.hh:80
void setThreadId(ThreadID id)
Definition: thread_state.hh:67

Generated on Wed Dec 21 2022 10:22:24 for gem5 by doxygen 1.9.1