gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
gem5::o3::ThreadContext::remove
bool remove(PCEvent *e) override
Definition: thread_context.hh:79
gem5::o3::ThreadContext::getCpuPtr
BaseCPU * getCpuPtr() override
Returns a pointer to this CPU.
Definition: thread_context.hh:121
gem5::o3::ThreadContext::thread
ThreadState * thread
Pointer to the thread state that this TC corrseponds to.
Definition: thread_context.hh:101
gem5::BaseHTMCheckpointPtr
std::unique_ptr< BaseHTMCheckpoint > BaseHTMCheckpointPtr
Definition: htm.hh:125
gem5::o3::ThreadContext::htmAbortTransaction
void htmAbortTransaction(uint64_t htm_uid, HtmFailureFaultCause cause) override
Definition: thread_context.cc:216
gem5::o3::ThreadContext::activate
void activate() override
Set the status to Active.
Definition: thread_context.cc:68
gem5::o3::ThreadContext::takeOverFrom
void takeOverFrom(gem5::ThreadContext *old_context) override
Takes over execution of a thread from another CPU.
Definition: thread_context.cc:53
gem5::o3::ThreadContext::socketId
uint32_t socketId() const override
Reads this CPU's Socket ID.
Definition: thread_context.hh:127
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::o3::ThreadContext::getHtmCheckpointPtr
BaseHTMCheckpointPtr & getHtmCheckpointPtr() override
Definition: thread_context.cc:225
gem5::o3::CPU::mmu
BaseMMU * mmu
Definition: cpu.hh:110
gem5::HtmFailureFaultCause
HtmFailureFaultCause
Definition: htm.hh:47
gem5::o3::ThreadContext::getIsaPtr
BaseISA * getIsaPtr() const override
Definition: thread_context.hh:109
gem5::o3::ThreadContext::threadId
int threadId() const override
Returns this thread's ID number.
Definition: thread_context.hh:134
gem5::MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:300
gem5::o3::ThreadContext::setStatus
void setStatus(Status new_status) override
Sets this thread's status.
Definition: thread_context.hh:150
gem5::o3::ThreadState::pcEventQueue
PCEventQueue pcEventQueue
Definition: thread_state.hh:69
gem5::o3::ThreadContext::readMiscRegNoEffect
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
Reads a miscellaneous register.
Definition: thread_context.hh:192
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:65
gem5::PCEventQueue::remove
bool remove(PCEvent *event) override
Definition: pc_event.cc:51
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:776
gem5::ThreadContext::Status
Status
Definition: thread_context.hh:99
gem5::o3::ThreadContext::getWritableReg
void * getWritableReg(const RegId &reg) override
Definition: thread_context.cc:157
gem5::PCEventQueue::schedule
bool schedule(PCEvent *event) override
Definition: pc_event.cc:71
gem5::o3::ThreadContext::getProcessPtr
Process * getProcessPtr() override
Returns a pointer to this thread's process.
Definition: thread_context.hh:141
gem5::o3::ThreadContext::getCheckerCpuPtr
CheckerCPU * getCheckerCpuPtr() override
Definition: thread_context.hh:106
gem5::BaseCPU::socketId
uint32_t socketId() const
Reads this CPU's Socket ID.
Definition: base.hh:190
gem5::o3::ThreadContext::getSystemPtr
System * getSystemPtr() override
Returns a pointer to the system.
Definition: thread_context.hh:138
gem5::o3::ThreadContext::schedule
bool schedule(PCEvent *e) override
Definition: thread_context.hh:74
gem5::o3::ThreadContext::setReg
void setReg(const RegId &reg, RegVal val) override
Definition: thread_context.cc:169
gem5::o3::ThreadContext::conditionalSquash
void conditionalSquash()
check if the cpu is currently in state update mode and squash if not.
Definition: thread_context.hh:233
gem5::o3::Fetch::decoder
InstDecoder * decoder[MaxThreads]
The decoder.
Definition: fetch.hh:358
gem5::BaseMMU
Definition: mmu.hh:53
gem5::o3::ThreadContext::getDecoderPtr
InstDecoder * getDecoderPtr() override
Definition: thread_context.hh:115
gem5::o3::ThreadContext
Derived ThreadContext class for use with the O3CPU.
Definition: thread_context.hh:67
gem5::o3::ThreadContext::readStCondFailures
unsigned readStCondFailures() const override
Returns the number of consecutive store conditional failures.
Definition: thread_context.hh:215
gem5::System
Definition: system.hh:74
gem5::o3::CPU
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition: cpu.hh:93
gem5::o3::ThreadContext::suspend
void suspend() override
Set the status to Suspended.
Definition: thread_context.cc:84
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::o3::ThreadContext::readMiscReg
RegVal readMiscReg(RegIndex misc_reg) override
Reads a misc.
Definition: thread_context.hh:200
gem5::InstDecoder
Definition: decoder.hh:42
gem5::Event
Definition: eventq.hh:254
gem5::o3::CPU::fetch
Fetch fetch
The fetch stage.
Definition: cpu.hh:402
gem5::X86ISA::count
count
Definition: misc.hh:710
gem5::EventQueue::deschedule
void deschedule(Event *event)
Deschedule the specified event.
Definition: eventq.hh:790
gem5::ThreadState::storeCondFailures
unsigned storeCondFailures
Definition: thread_state.hh:138
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::PCEvent
Definition: pc_event.hh:45
gem5::CheckerCPU
CheckerCPU class.
Definition: cpu.hh:84
gem5::o3::CPU::pcState
void pcState(const PCStateBase &new_pc_state, ThreadID tid)
Sets the commit PC state of a specific thread.
Definition: cpu.cc:1102
gem5::o3::ThreadContext::getMMUPtr
BaseMMU * getMMUPtr() override
Returns a pointer to the MMU.
Definition: thread_context.hh:104
gem5::o3::CPU::squashFromTC
void squashFromTC(ThreadID tid)
Initiates a squash of all in-flight instructions for a given thread.
Definition: cpu.cc:1108
gem5::o3::ThreadContext::setMiscRegNoEffect
void setMiscRegNoEffect(RegIndex misc_reg, RegVal val) override
Sets a misc.
Definition: thread_context.cc:199
gem5::o3::CPU::readMiscRegNoEffect
RegVal readMiscRegNoEffect(int misc_reg, ThreadID tid) const
Register accessors.
Definition: cpu.cc:910
gem5::o3::ThreadContext::cpuId
int cpuId() const override
Reads this CPU's ID.
Definition: thread_context.hh:124
gem5::ThreadState::setThreadId
void setThreadId(ThreadID id)
Definition: thread_state.hh:67
gem5::o3::ThreadContext::setHtmCheckpointPtr
void setHtmCheckpointPtr(BaseHTMCheckpointPtr new_cpt) override
Definition: thread_context.cc:231
gem5::BaseCPU
Definition: base.hh:104
gem5::ThreadState::threadId
ThreadID threadId() const
Definition: thread_state.hh:69
gem5::o3::ThreadContext::getReg
RegVal getReg(const RegId &reg) const override
Definition: thread_context.cc:151
gem5::o3::ThreadState::comInstEventQueue
EventQueue comInstEventQueue
An instruction-based event queue.
Definition: thread_state.hh:74
gem5::o3::ThreadContext::getCurrentInstCount
Tick getCurrentInstCount() override
Definition: thread_context.hh:95
gem5::EventQueue::getCurTick
Tick getCurTick() const
While curTick() is useful for any object assigned to this event queue, if an object that is assigned ...
Definition: eventq.hh:850
gem5::ThreadState::setStatus
void setStatus(Status new_status)
Sets the status of this thread.
Definition: thread_state.hh:83
gem5::ThreadState::contextId
ContextID contextId() const
Definition: thread_state.hh:63
gem5::o3::ThreadContext::setStCondFailures
void setStCondFailures(unsigned sc_failures) override
Sets the number of consecutive store conditional failures.
Definition: thread_context.hh:222
gem5::ThreadState::setContextId
void setContextId(ContextID id)
Definition: thread_state.hh:65
gem5::o3::ThreadContext::setContextId
void setContextId(ContextID id) override
Definition: thread_context.hh:131
gem5::X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:92
gem5::Process
Definition: process.hh:67
gem5::o3::CPU::system
System * system
Pointer to the system.
Definition: cpu.hh:527
gem5::o3::ThreadState::noSquashFromTC
bool noSquashFromTC
Definition: thread_state.hh:84
gem5::o3::ThreadContext::status
Status status() const override
Returns this thread's status.
Definition: thread_context.hh:146
gem5::o3::ThreadState
Class that has various thread state, such as the status, the current instruction being processed,...
Definition: thread_state.hh:66
gem5::o3::ThreadContext::halt
void halt() override
Set the status to Halted.
Definition: thread_context.cc:105
gem5::o3::ThreadContext::clearArchRegs
void clearArchRegs() override
Resets all architectural registers to 0.
Definition: thread_context.cc:145
gem5::ThreadState::setProcessPtr
void setProcessPtr(Process *p)
Definition: thread_state.hh:77
gem5::o3::ThreadContext::scheduleInstCountEvent
void scheduleInstCountEvent(Event *event, Tick count) override
Definition: thread_context.hh:85
gem5::o3::ThreadContext::copyArchRegs
void copyArchRegs(gem5::ThreadContext *tc) override
Copies the architectural registers from another TC into this TC.
Definition: thread_context.cc:136
gem5::o3::ThreadContext::readLastSuspend
Tick readLastSuspend() override
Reads the last tick that this thread was suspended on.
Definition: thread_context.cc:130
gem5::BaseCPU::cpuId
int cpuId() const
Reads this CPU's ID.
Definition: base.hh:187
gem5::o3::ThreadContext::setProcessPtr
void setProcessPtr(Process *p) override
Definition: thread_context.hh:143
gem5::ThreadState::status
Status status() const
Returns the status of this thread.
Definition: thread_state.hh:80
gem5::ContextID
int ContextID
Globally unique thread context ID.
Definition: types.hh:239
gem5::o3::CPU::readMiscReg
RegVal readMiscReg(int misc_reg, ThreadID tid)
Reads a misc.
Definition: cpu.cc:916
gem5::EventQueue::schedule
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
Definition: eventq.hh:757
gem5::o3::ThreadContext::pcState
const PCStateBase & pcState() const override
Reads this thread's PC state.
Definition: thread_context.hh:180
gem5::o3::ThreadContext::descheduleInstCountEvent
void descheduleInstCountEvent(Event *event) override
Definition: thread_context.hh:90
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::o3::ThreadContext::cpu
CPU * cpu
Pointer to the CPU.
Definition: thread_context.hh:71
gem5::BaseISA
Definition: isa.hh:58
gem5::RegIndex
uint16_t RegIndex
Definition: types.hh:176
cpu.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::o3::ThreadContext::pcStateNoRecord
void pcStateNoRecord(const PCStateBase &val) override
Definition: thread_context.cc:191
gem5::o3::CPU::isa
std::vector< BaseISA * > isa
Definition: cpu.hh:444
gem5::o3::ThreadContext::readLastActivate
Tick readLastActivate() override
Reads the last tick that this thread was activated on.
Definition: thread_context.cc:124
gem5::o3::ThreadContext::setThreadId
void setThreadId(int id) override
Definition: thread_context.hh:135
gem5::o3::ThreadState::trapPending
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
gem5::o3::ThreadContext::setMiscReg
void setMiscReg(RegIndex misc_reg, RegVal val) override
Sets a misc.
Definition: thread_context.cc:207
thread_context.hh
gem5::RegId
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:92
gem5::o3::ThreadContext::contextId
ContextID contextId() const override
Definition: thread_context.hh:129
gem5::ThreadState::getProcessPtr
Process * getProcessPtr()
Definition: thread_state.hh:75

Generated on Sun Jul 30 2023 01:56:47 for gem5 by doxygen 1.8.17