gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
system.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010, 2012-2013, 2015,2017-2021 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-2006 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#include "arch/arm/system.hh"
42
43#include <iostream>
44
48#include "base/loader/symtab.hh"
49#include "cpu/thread_context.hh"
51#include "dev/arm/gic_v2.hh"
52#include "mem/physical.hh"
53#include "params/ArmRelease.hh"
54#include "params/ArmSystem.hh"
55
56namespace gem5
57{
58
59using namespace linux;
60using namespace ArmISA;
61
62ArmRelease::ArmRelease(const ArmReleaseParams &p)
63 : SimObject(p)
64{
65 for (auto ext : p.extensions) {
66 fatal_if(_extensions.find(ext) != _extensions.end(),
67 "Duplicated FEAT_\n");
68
69 _extensions[ext] = true;
70 }
71}
72
74 : System(p),
75 _genericTimer(nullptr),
76 _gic(nullptr),
77 _pwrCtrl(nullptr),
78 _highestELIs64(p.highest_el_is_64),
79 _physAddrRange64(p.phys_addr_range_64),
80 _haveLargeAsid64(p.have_large_asid_64),
81 _sveVL(p.sve_vl),
82 _smeVL(p.sme_vl),
85 multiProc(p.multi_proc)
86{
87 if (p.auto_reset_addr) {
88 _resetAddr = workload->getEntry();
89 } else {
90 _resetAddr = p.reset_addr;
91 warn_if(workload->getEntry() != _resetAddr,
92 "Workload entry point %#x and reset address %#x are different",
93 workload->getEntry(), _resetAddr);
94 }
95
96 bool wl_is_64 = (workload->getArch() == loader::Arm64);
97 if (wl_is_64 != _highestELIs64) {
98 warn("Highest ARM exception-level set to AArch%d but the workload "
99 "is for AArch%d. Assuming you wanted these to match.",
100 _highestELIs64 ? 64 : 32, wl_is_64 ? 64 : 32);
101 _highestELIs64 = wl_is_64;
102 }
103
104 if (_highestELIs64 && (
105 _physAddrRange64 < 32 ||
107 (_physAddrRange64 % 4 != 0 && _physAddrRange64 != 42) ||
108 (_physAddrRange64 == 52 && !release->has(ArmExtension::FEAT_LPA))))
109 {
110 fatal("Invalid physical address range (%d)\n", _physAddrRange64);
111 }
112}
113
114bool
116{
117 return FullSystem? getArmSystem(tc)->has(ext) : false;
118}
119
120bool
125
131
132bool
134{
135 switch (el) {
136 case EL0:
137 case EL1:
138 return true;
139 case EL2:
140 return has(ArmExtension::VIRTUALIZATION, tc);
141 case EL3:
142 return has(ArmExtension::SECURITY, tc);
143 default:
144 warn("Unimplemented Exception Level\n");
145 return false;
146 }
147}
148
149Addr
154
155uint8_t
160
161Addr
166
167bool
172
173bool
178
179bool
181{
182 return getArmSystem(tc)->semihosting->call64(tc, gem5_ops);
183}
184
185bool
187{
188 return getArmSystem(tc)->semihosting->call32(tc, gem5_ops);
189}
190
191bool
193{
194 if (ArmISA::inAArch64(tc))
195 return callSemihosting64(tc, gem5_ops);
196 else
197 return callSemihosting32(tc, gem5_ops);
198}
199
200void
202{
203 if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
204 pwr_ctrl->setStandByWfi(tc);
205}
206
207void
209{
210 if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
211 pwr_ctrl->clearStandByWfi(tc);
212}
213
214bool
216{
217 if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
218 return pwr_ctrl->setWakeRequest(tc);
219 else
220 return true;
221}
222
223void
225{
226 if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
227 pwr_ctrl->clearWakeRequest(tc);
228}
229
230} // namespace gem5
ArmRelease(const Params &p)
Definition system.cc:62
bool call32(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch32 code.
bool call64(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch64 code.
const bool _haveLargeAsid64
True if ASID is 16 bits in AArch64 (ARMv8)
Definition system.hh:127
FVPBasePwrCtrl * _pwrCtrl
Pointer to the Power Controller (if any)
Definition system.hh:105
BaseGic * _gic
Definition system.hh:100
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
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
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
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
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
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
GenericTimer * _genericTimer
Pointer to the Generic Timer wrapper.
Definition system.hh:99
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
Workload * workload
OS kernel.
Definition system.hh:331
ThreadContext is the external interface to all thread state for anything outside of the CPU.
This class implements the base power controller for FVP-based platforms.
Implementation of a GICv2.
SimObject(const Params &p)
Definition sim_object.cc:58
#define warn(...)
Definition logging.hh:288
const unsigned MaxPhysAddrRange
Definition pagetable.hh:77
Bitfield< 3, 2 > el
Definition misc_types.hh:73
bool inAArch64(ThreadContext *tc)
Definition utility.cc:127
Bitfield< 12 > ext
Bitfield< 0 > p
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