gem5 v24.0.0.0
Loading...
Searching...
No Matches
exec_context.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2014, 2016-2018, 2020-2021 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) 2002-2005 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
48#ifndef __CPU_MINOR_EXEC_CONTEXT_HH__
49#define __CPU_MINOR_EXEC_CONTEXT_HH__
50
51#include "cpu/exec_context.hh"
52#include "cpu/minor/execute.hh"
53#include "cpu/minor/pipeline.hh"
54#include "cpu/base.hh"
55#include "cpu/simple_thread.hh"
56#include "mem/request.hh"
57#include "debug/MinorExecute.hh"
58
59namespace gem5
60{
61
62namespace minor
63{
64
65/* Forward declaration of Execute */
66class Execute;
67
73{
74 public:
76
79
82
85
87 MinorCPU &cpu_,
88 SimpleThread &thread_, Execute &execute_,
89 MinorDynInstPtr inst_) :
90 cpu(cpu_),
91 thread(thread_),
92 execute(execute_),
93 inst(inst_)
94 {
95 DPRINTF(MinorExecute, "ExecContext setting PC: %s\n", *inst->pc);
96 pcState(*inst->pc);
97 setPredicate(inst->readPredicate());
98 setMemAccPredicate(inst->readMemAccPredicate());
99 }
100
102 {
103 inst->setPredicate(readPredicate());
104 inst->setMemAccPredicate(readMemAccPredicate());
105 }
106
107 Fault
108 initiateMemRead(Addr addr, unsigned int size,
110 const std::vector<bool>& byte_enable) override
111 {
112 assert(byte_enable.size() == size);
113 return execute.getLSQ().pushRequest(inst, true /* load */, nullptr,
114 size, addr, flags, nullptr, nullptr, byte_enable);
115 }
116
117 Fault
119 {
120 panic("ExecContext::initiateMemMgmtCmd() not implemented "
121 " on MinorCPU\n");
122 return NoFault;
123 }
124
125 Fault
126 writeMem(uint8_t *data, unsigned int size, Addr addr,
127 Request::Flags flags, uint64_t *res,
128 const std::vector<bool>& byte_enable)
129 override
130 {
131 assert(byte_enable.size() == size);
132 return execute.getLSQ().pushRequest(inst, false /* store */, data,
133 size, addr, flags, res, nullptr, byte_enable);
134 }
135
136 Fault
138 AtomicOpFunctorPtr amo_op) override
139 {
140 // AMO requests are pushed through the store path
141 return execute.getLSQ().pushRequest(inst, false /* amo */, nullptr,
142 size, addr, flags, nullptr, std::move(amo_op),
143 std::vector<bool>(size, true));
144 }
145
146 RegVal
147 getRegOperand(const StaticInst *si, int idx) override
148 {
149 const RegId &reg = si->srcRegIdx(idx);
150 if (reg.is(InvalidRegClass))
151 return 0;
152 return thread.getReg(reg);
153 }
154
155 void
156 getRegOperand(const StaticInst *si, int idx, void *val) override
157 {
158 thread.getReg(si->srcRegIdx(idx), val);
159 }
160
161 void *
162 getWritableRegOperand(const StaticInst *si, int idx) override
163 {
164 return thread.getWritableReg(si->destRegIdx(idx));
165 }
166
167 void
168 setRegOperand(const StaticInst *si, int idx, RegVal val) override
169 {
170 const RegId &reg = si->destRegIdx(idx);
171 if (reg.is(InvalidRegClass))
172 return;
173 thread.setReg(si->destRegIdx(idx), val);
174 }
175
176 void
177 setRegOperand(const StaticInst *si, int idx, const void *val) override
178 {
179 thread.setReg(si->destRegIdx(idx), val);
180 }
181
182 bool
183 readPredicate() const override
184 {
185 return thread.readPredicate();
186 }
187
188 void
189 setPredicate(bool val) override
190 {
192 }
193
194 bool
195 readMemAccPredicate() const override
196 {
198 }
199
200 void
201 setMemAccPredicate(bool val) override
202 {
204 }
205
206 // hardware transactional memory
207 uint64_t
208 getHtmTransactionUid() const override
209 {
210 panic("ExecContext::getHtmTransactionUid() not"
211 "implemented on MinorCPU\n");
212 return 0;
213 }
214
215 uint64_t
216 newHtmTransactionUid() const override
217 {
218 panic("ExecContext::newHtmTransactionUid() not"
219 "implemented on MinorCPU\n");
220 return 0;
221 }
222
223 bool
224 inHtmTransactionalState() const override
225 {
226 // ExecContext::inHtmTransactionalState() not
227 // implemented on MinorCPU
228 return false;
229 }
230
231 uint64_t
233 {
234 panic("ExecContext::getHtmTransactionalDepth() not"
235 "implemented on MinorCPU\n");
236 return 0;
237 }
238
239 const PCStateBase &
240 pcState() const override
241 {
242 return thread.pcState();
243 }
244
245 void
246 pcState(const PCStateBase &val) override
247 {
249 }
250
251 RegVal
252 readMiscRegNoEffect(int misc_reg) const
253 {
254 return thread.readMiscRegNoEffect(misc_reg);
255 }
256
257 RegVal
258 readMiscReg(int misc_reg) override
259 {
260 return thread.readMiscReg(misc_reg);
261 }
262
263 void
264 setMiscReg(int misc_reg, RegVal val) override
265 {
266 thread.setMiscReg(misc_reg, val);
267 }
268
269 RegVal
270 readMiscRegOperand(const StaticInst *si, int idx) override
271 {
272 const RegId& reg = si->srcRegIdx(idx);
273 assert(reg.is(MiscRegClass));
274 return thread.readMiscReg(reg.index());
275 }
276
277 void
278 setMiscRegOperand(const StaticInst *si, int idx, RegVal val) override
279 {
280 const RegId& reg = si->destRegIdx(idx);
281 assert(reg.is(MiscRegClass));
282 return thread.setMiscReg(reg.index(), val);
283 }
284
285 ThreadContext *tcBase() const override { return thread.getTC(); }
286
287 /* @todo, should make stCondFailures persistent somewhere */
288 unsigned int readStCondFailures() const override { return 0; }
289 void setStCondFailures(unsigned int st_cond_failures) override {}
290
292 /* ISA-specific (or at least currently ISA singleton) functions */
293
294 /* X86: TLB twiddling */
295 void
296 demapPage(Addr vaddr, uint64_t asn) override
297 {
299 }
300
301 BaseCPU *getCpuPtr() { return &cpu; }
302
303 public:
304 // monitor/mwait funtions
305 void
306 armMonitor(Addr address) override
307 {
308 getCpuPtr()->armMonitor(inst->id.threadId, address);
309 }
310
311 bool
312 mwait(PacketPtr pkt) override
313 {
314 return getCpuPtr()->mwait(inst->id.threadId, pkt);
315 }
316
317 void
319 {
320 return getCpuPtr()->mwaitAtomic(inst->id.threadId, tc, thread.mmu);
321 }
322
324 getAddrMonitor() override
325 {
326 return getCpuPtr()->getCpuAddrMonitor(inst->id.threadId);
327 }
328};
329
330} // namespace minor
331} // namespace gem5
332
333#endif /* __CPU_MINOR_EXEC_CONTEXT_HH__ */
#define DPRINTF(x,...)
Definition trace.hh:210
const char data[]
void mwaitAtomic(ThreadID tid, ThreadContext *tc, BaseMMU *mmu)
Definition base.cc:277
AddressMonitor * getCpuAddrMonitor(ThreadID tid)
Definition base.hh:656
bool mwait(ThreadID tid, PacketPtr pkt)
Definition base.cc:254
void armMonitor(ThreadID tid, Addr address)
Definition base.cc:242
void demapPage(Addr vaddr, uint64_t asn)
Definition mmu.cc:97
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition cpu.hh:85
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Register ID: describe an architectural register with its class and index.
Definition reg_class.hh:94
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
bool readPredicate() const
void setPredicate(bool val)
const PCStateBase & pcState() const override
void setMiscReg(RegIndex misc_reg, RegVal val) override
void * getWritableReg(const RegId &arch_reg) override
ContextID contextId() const override
void setReg(const RegId &arch_reg, RegVal val) override
ThreadContext * getTC()
Returns the pointer to this SimpleThread's ThreadContext.
BaseMMU * getMMUPtr() override
RegVal readMiscReg(RegIndex misc_reg) override
void setMemAccPredicate(bool val)
RegVal getReg(const RegId &arch_reg) const override
Base, ISA-independent static instruction class.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
ExecContext bears the exec_context interface for Minor.
ExecContext(MinorCPU &cpu_, SimpleThread &thread_, Execute &execute_, MinorDynInstPtr inst_)
ThreadContext * tcBase() const override
Returns a pointer to the ThreadContext.
uint64_t getHtmTransactionalDepth() const override
void armMonitor(Addr address) override
void setStCondFailures(unsigned int st_cond_failures) override
Sets the number of consecutive store conditional failures.
Fault initiateMemAMO(Addr addr, unsigned int size, Request::Flags flags, AtomicOpFunctorPtr amo_op) override
For timing-mode contexts, initiate an atomic AMO (atomic read-modify-write memory operation)
void setMiscReg(int misc_reg, RegVal val) override
Sets a miscellaneous register, handling any architectural side effects due to writing that register.
RegVal readMiscRegOperand(const StaticInst *si, int idx) override
RegVal readMiscReg(int misc_reg) override
Reads a miscellaneous register, handling any architectural side effects due to reading that register.
bool inHtmTransactionalState() const override
RegVal getRegOperand(const StaticInst *si, int idx) override
Fault initiateMemRead(Addr addr, unsigned int size, Request::Flags flags, const std::vector< bool > &byte_enable) override
Initiate a timing memory read operation.
void setRegOperand(const StaticInst *si, int idx, RegVal val) override
RegVal readMiscRegNoEffect(int misc_reg) const
const PCStateBase & pcState() const override
uint64_t getHtmTransactionUid() const override
bool mwait(PacketPtr pkt) override
bool readMemAccPredicate() const override
unsigned int readStCondFailures() const override
Returns the number of consecutive store conditional failures.
uint64_t newHtmTransactionUid() const override
Fault initiateMemMgmtCmd(Request::Flags flags) override
Initiate a memory management command with no valid address.
void getRegOperand(const StaticInst *si, int idx, void *val) override
Fault writeMem(uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable) override
For atomic-mode contexts, perform an atomic memory write operation.
void pcState(const PCStateBase &val) override
void demapPage(Addr vaddr, uint64_t asn) override
Invalidate a page in the DTLB and ITLB.
void setMemAccPredicate(bool val) override
void setRegOperand(const StaticInst *si, int idx, const void *val) override
void setPredicate(bool val) override
MinorDynInstPtr inst
Instruction for the benefit of memory operations and for PC.
void * getWritableRegOperand(const StaticInst *si, int idx) override
void setMiscRegOperand(const StaticInst *si, int idx, RegVal val) override
void mwaitAtomic(ThreadContext *tc) override
SimpleThread & thread
ThreadState object, provides all the architectural state.
bool readPredicate() const override
Execute & execute
The execute stage so we can peek at its contents.
AddressMonitor * getAddrMonitor() override
Execute stage.
Definition execute.hh:68
LSQ & getLSQ()
To allow ExecContext to find the LSQ.
Definition execute.hh:337
Fault pushRequest(MinorDynInstPtr inst, bool isLoad, uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, AtomicOpFunctorPtr amo_op, const std::vector< bool > &byte_enable=std::vector< bool >())
Single interface for readMem/writeMem/amoMem to issue requests into the LSQ.
Definition lsq.cc:1583
STL vector class.
Definition stl.hh:37
All the fun of executing instructions from Decode and sending branch/new instruction stream info.
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition amo.hh:269
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
uint8_t flags
Definition helpers.cc:87
Bitfield< 6 > si
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 63 > val
Definition misc.hh:804
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
uint64_t RegVal
Definition types.hh:173
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
int ContextID
Globally unique thread context ID.
Definition types.hh:239
constexpr decltype(nullptr) NoFault
Definition types.hh:253
@ InvalidRegClass
Definition reg_class.hh:71
@ MiscRegClass
Control (misc) register.
Definition reg_class.hh:70
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
The constructed pipeline.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...

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