gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
48namespace gem5
49{
50
51namespace o3
52{
53
68{
69 public:
72
73 bool
74 schedule(PCEvent *e) override
75 {
77 }
78 bool
79 remove(PCEvent *e) override
80 {
81 return thread->pcEventQueue.remove(e);
82 }
83
84 void
89 void
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
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
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 {
218 }
219
221 void
222 setStCondFailures(unsigned sc_failures) override
223 {
224 thread->storeCondFailures = sc_failures;
225 }
226
232 void
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:190
int cpuId() const
Reads this CPU's ID.
Definition base.hh:187
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:94
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:447
void squashFromTC(ThreadID tid)
Initiates a squash of all in-flight instructions for a given thread.
Definition cpu.cc:1126
BaseMMU * mmu
Definition cpu.hh:110
System * system
Pointer to the system.
Definition cpu.hh:530
RegVal readMiscRegNoEffect(int misc_reg, ThreadID tid) const
Register accessors.
Definition cpu.cc:928
Fetch fetch
The fetch stage.
Definition cpu.hh:405
void pcState(const PCStateBase &new_pc_state, ThreadID tid)
Sets the commit PC state of a specific thread.
Definition cpu.cc:1120
RegVal readMiscReg(int misc_reg, ThreadID tid)
Reads a misc.
Definition cpu.cc:934
InstDecoder * decoder[MaxThreads]
The decoder.
Definition fetch.hh:358
Derived ThreadContext class for use with the O3CPU.
void setHtmCheckpointPtr(BaseHTMCheckpointPtr new_cpt) override
void conditionalSquash()
check if the cpu is currently in state update mode and squash if not.
BaseCPU * getCpuPtr() override
Returns a pointer to this CPU.
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
BaseMMU * getMMUPtr() override
Returns a pointer to the MMU.
void setProcessPtr(Process *p) override
Status status() const override
Returns this thread's status.
void htmAbortTransaction(uint64_t htm_uid, HtmFailureFaultCause cause) override
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.
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.
const PCStateBase & pcState() const override
Reads this thread's PC state.
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.
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
CheckerCPU * getCheckerCpuPtr() override
BaseHTMCheckpointPtr & getHtmCheckpointPtr() override
Process * getProcessPtr() override
Returns a pointer to this thread's process.
void setMiscRegNoEffect(RegIndex misc_reg, RegVal val) override
Sets a misc.
BaseISA * getIsaPtr() const override
System * getSystemPtr() override
Returns a pointer to the system.
bool schedule(PCEvent *e) override
RegVal readMiscReg(RegIndex misc_reg) override
Reads a misc.
InstDecoder * getDecoderPtr() override
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.
ContextID contextId() const override
Class that has various thread state, such as the status, the current instruction being processed,...
bool trapPending
Whether or not the thread is currently waiting on a trap, and thus able to be externally updated with...
EventQueue comInstEventQueue
An instruction-based event queue.
PCEventQueue pcEventQueue
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
Definition eventq.hh:757
void deschedule(Event *event)
Deschedule the specified event.
Definition eventq.hh:790
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
Bitfield< 9 > e
Definition misc_types.hh:65
Bitfield< 10, 5 > event
Bitfield< 0 > p
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 63 > val
Definition misc.hh:804
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint16_t RegIndex
Definition types.hh:176
uint64_t RegVal
Definition types.hh:173
uint64_t Tick
Tick count type.
Definition types.hh:58
int ContextID
Globally unique thread context ID.
Definition types.hh:239
std::unique_ptr< BaseHTMCheckpoint > BaseHTMCheckpointPtr
Definition htm.hh:127
HtmFailureFaultCause
Definition htm.hh:48
ThreadID threadId() const
void setStatus(Status new_status)
Sets the status of this thread.
unsigned storeCondFailures
void setProcessPtr(Process *p)
ContextID contextId() const
void setContextId(ContextID id)
Process * getProcessPtr()
Status status() const
Returns the status of this thread.
void setThreadId(ThreadID id)

Generated on Tue Jun 18 2024 16:24:01 for gem5 by doxygen 1.11.0