gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
system.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010, 2012-2013, 2015-2022 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2002-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef __ARCH_ARM_SYSTEM_HH__
42#define __ARCH_ARM_SYSTEM_HH__
43
44#include <memory>
45#include <string>
46#include <unordered_map>
47#include <vector>
48
49#include "arch/arm/page_size.hh"
50#include "arch/arm/types.hh"
51#include "enums/ArmExtension.hh"
52#include "kern/linux/events.hh"
53#include "sim/full_system.hh"
54#include "sim/sim_object.hh"
55#include "sim/system.hh"
56
57namespace gem5
58{
59
60struct ArmSystemParams;
61
62class GenericTimer;
63class BaseGic;
64class FVPBasePwrCtrl;
65class ThreadContext;
66
67struct ArmReleaseParams;
68class ArmSemihosting;
69
70class ArmRelease : public SimObject
71{
72 public:
74 ArmRelease(const Params &p);
75
76 bool
77 has(ArmExtension ext) const
78 {
79 if (auto it = _extensions.find(ext); it != _extensions.end()) {
80 return it->second;
81 } else {
82 return false;
83 }
84 }
85
86 protected:
90 std::unordered_map<ArmExtension, bool> _extensions;
91};
92
93class ArmSystem : public System
94{
95 protected:
101
106
111
117
122 const uint8_t _physAddrRange64;
123
128
130 const unsigned _sveVL;
131
133 const unsigned _smeVL;
134
139
145
146 public:
147 static constexpr Addr PageBytes = ArmISA::PageBytes;
148 static constexpr Addr PageShift = ArmISA::PageShift;
149
151
152 ArmSystem(const Params &p);
153
156
157 const ArmRelease* releaseFS() const { return release; }
158
159 bool has(ArmExtension ext) const { return release->has(ext); }
160
162 void
164 {
165 _genericTimer = generic_timer;
166 }
167
169 void setGIC(BaseGic *gic) { _gic = gic; }
170
173 {
174 _pwrCtrl = pwr_ctrl;
175 }
176
179
181 BaseGic *getGIC() const { return _gic; }
182
185
188 bool highestELIs64() const { return _highestELIs64; }
189
192 highestEL() const
193 {
194 if (has(ArmExtension::SECURITY))
195 return ArmISA::EL3;
196 if (has(ArmExtension::VIRTUALIZATION))
197 return ArmISA::EL2;
198 return ArmISA::EL1;
199 }
200
203 Addr resetAddr() const { return _resetAddr; }
205
207 bool haveLargeAsid64() const { return _haveLargeAsid64; }
208
210 unsigned sveVL() const { return _sveVL; }
211
213 unsigned smeVL() const { return _smeVL; }
214
217 uint8_t physAddrRange64() const { return _physAddrRange64; }
218
220 uint8_t
222 {
223 if (_highestELIs64)
224 return _physAddrRange64;
225 if (has(ArmExtension::LPAE))
226 return 40;
227 return 32;
228 }
229
231 Addr physAddrMask() const { return mask(physAddrRange()); }
232
234 bool haveSemihosting() const { return semihosting != nullptr; }
235
240 static ArmSystem*
242 {
243 assert(FullSystem);
244 return static_cast<ArmSystem *>(tc->getSystemPtr());
245 }
246
247 static bool has(ArmExtension ext, ThreadContext *tc);
248
249 static bool highestELIs64(ThreadContext *tc);
250
255
258
262 static Addr resetAddr(ThreadContext *tc);
263
267 static uint8_t physAddrRange(ThreadContext *tc);
268
272 static Addr physAddrMask(ThreadContext *tc);
273
276 static bool haveLargeAsid64(ThreadContext *tc);
277
279 static bool haveSemihosting(ThreadContext *tc);
280
282 static bool callSemihosting64(ThreadContext *tc, bool gem5_ops=false);
283
285 static bool callSemihosting32(ThreadContext *tc, bool gem5_ops=false);
286
288 static bool callSemihosting(ThreadContext *tc, bool gem5_ops=false);
289
291 static void callSetStandByWfi(ThreadContext *tc);
292
294 static void callClearStandByWfi(ThreadContext *tc);
295
301 static bool callSetWakeRequest(ThreadContext *tc);
302
304 static void callClearWakeRequest(ThreadContext *tc);
305};
306
307} // namespace gem5
308
309#endif
bool has(ArmExtension ext) const
Definition system.hh:77
ArmRelease(const Params &p)
Definition system.cc:62
std::unordered_map< ArmExtension, bool > _extensions
List of implemented extensions.
Definition system.hh:90
PARAMS(ArmRelease)
Semihosting for AArch32 and AArch64.
const bool _haveLargeAsid64
True if ASID is 16 bits in AArch64 (ARMv8)
Definition system.hh:127
static constexpr Addr PageShift
Definition system.hh:148
void setGenericTimer(GenericTimer *generic_timer)
Sets the pointer to the Generic Timer.
Definition system.hh:163
FVPBasePwrCtrl * _pwrCtrl
Pointer to the Power Controller (if any)
Definition system.hh:105
BaseGic * _gic
Definition system.hh:100
uint8_t physAddrRange64() const
Returns the supported physical address range in bits if the highest implemented exception level is 64...
Definition system.hh:217
GenericTimer * getGenericTimer() const
Get a pointer to the system's generic timer model.
Definition system.hh:178
static ArmSystem * getArmSystem(ThreadContext *tc)
Returns a valid ArmSystem pointer if using ARM ISA, it fails otherwise.
Definition system.hh:241
Addr physAddrMask() const
Returns the physical address mask.
Definition system.hh:231
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition system.hh:188
static constexpr Addr PageBytes
Definition system.hh:147
ArmISA::ExceptionLevel highestEL() const
Returns the highest implemented exception level.
Definition system.hh:192
const unsigned _smeVL
SME vector length at reset, in quadwords.
Definition system.hh:133
unsigned smeVL() const
Returns the SME vector length at reset, in quadwords.
Definition system.hh:213
static bool callSemihosting32(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from aarch32.
Definition system.cc:186
bool haveSemihosting() const
Is Arm Semihosting support enabled?
Definition system.hh:234
const uint8_t _physAddrRange64
Supported physical address range in bits if the highest implemented exception level is 64 bits (ARMv8...
Definition system.hh:122
FVPBasePwrCtrl * getPowerController() const
Get a pointer to the system's power controller.
Definition system.hh:184
static void callClearStandByWfi(ThreadContext *tc)
Make a call to notify the power controller of STANDBYWFI deassertion.
Definition system.cc:208
static void callSetStandByWfi(ThreadContext *tc)
Make a call to notify the power controller of STANDBYWFI assertion.
Definition system.cc:201
ArmSemihosting *const semihosting
True if the Semihosting interface is enabled.
Definition system.hh:138
Addr _resetAddr
Reset address (ARMv8)
Definition system.hh:110
BaseGic * getGIC() const
Get a pointer to the system's GIC.
Definition system.hh:181
static bool callSemihosting(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from either aarch64 or aarch32.
Definition system.cc:192
uint8_t physAddrRange() const
Returns the supported physical address range in bits.
Definition system.hh:221
static bool callSetWakeRequest(ThreadContext *tc)
Notify the power controller of WAKEREQUEST assertion.
Definition system.cc:215
void setResetAddr(Addr addr)
Definition system.hh:204
PARAMS(ArmSystem)
void setPowerController(FVPBasePwrCtrl *pwr_ctrl)
Sets the pointer to the Power Controller.
Definition system.hh:172
bool has(ArmExtension ext) const
Definition system.hh:159
bool haveLargeAsid64() const
Returns true if ASID is 16 bits in AArch64 (ARMv8)
Definition system.hh:207
Addr resetAddr() const
Returns the reset address if the highest implemented exception level is 64 bits (ARMv8)
Definition system.hh:203
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition system.cc:133
const unsigned _sveVL
SVE vector length at reset, in quadwords.
Definition system.hh:130
void setGIC(BaseGic *gic)
Sets the pointer to the GIC.
Definition system.hh:169
static void callClearWakeRequest(ThreadContext *tc)
Notify the power controller of WAKEREQUEST deassertion.
Definition system.cc:224
bool multiProc
true if this a multiprocessor system
Definition system.hh:155
const ArmRelease * releaseFS() const
Definition system.hh:157
GenericTimer * _genericTimer
Pointer to the Generic Timer wrapper.
Definition system.hh:99
unsigned sveVL() const
Returns the SVE vector length at reset, in quadwords.
Definition system.hh:210
ArmSystem(const Params &p)
Definition system.cc:73
bool _highestELIs64
True if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition system.hh:116
static bool callSemihosting64(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from aarch64.
Definition system.cc:180
const ArmRelease * release
Arm Release object: contains a list of implemented features.
Definition system.hh:144
SimObjectParams Params
System(const Params &p)
Definition system.cc:167
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual System * getSystemPtr()=0
SimObject(const Params &p)
Definition sim_object.cc:58
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 27, 24 > gic
const Addr PageShift
Definition page_size.hh:52
Bitfield< 3, 2 > el
Definition misc_types.hh:73
const Addr PageBytes
Definition page_size.hh:53
Bitfield< 12 > ext
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition root.cc:220

Generated on Mon Oct 27 2025 04:12:55 for gem5 by doxygen 1.14.0