gem5  v20.1.0.5
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
45 #include "arch/arm/fs_workload.hh"
46 #include "arch/arm/semihosting.hh"
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 
54 using namespace std;
55 using namespace Linux;
56 using namespace ArmISA;
57 
59  : System(p),
60  _haveSecurity(p->have_security),
61  _haveLPAE(p->have_lpae),
62  _haveVirtualization(p->have_virtualization),
63  _haveCrypto(p->have_crypto),
64  _genericTimer(nullptr),
65  _gic(nullptr),
66  _pwrCtrl(nullptr),
67  _highestELIs64(p->highest_el_is_64),
68  _physAddrRange64(p->phys_addr_range_64),
69  _haveLargeAsid64(p->have_large_asid_64),
70  _haveTME(p->have_tme),
71  _haveSVE(p->have_sve),
72  _sveVL(p->sve_vl),
73  _haveLSE(p->have_lse),
74  _haveVHE(p->have_vhe),
75  _havePAN(p->have_pan),
76  _haveSecEL2(p->have_secel2),
77  semihosting(p->semihosting),
78  multiProc(p->multi_proc)
79 {
80  if (p->auto_reset_addr) {
82  } else {
83  _resetAddr = p->reset_addr;
85  "Workload entry point %#x and reset address %#x are different",
87  }
88 
89  bool wl_is_64 = (workload->getArch() == Loader::Arm64);
90  if (wl_is_64 != _highestELIs64) {
91  warn("Highest ARM exception-level set to AArch%d but the workload "
92  "is for AArch%d. Assuming you wanted these to match.",
93  _highestELIs64 ? 64 : 32, wl_is_64 ? 64 : 32);
94  _highestELIs64 = wl_is_64;
95  }
96 
97  if (_highestELIs64 && (
98  _physAddrRange64 < 32 ||
99  _physAddrRange64 > 48 ||
100  (_physAddrRange64 % 4 != 0 && _physAddrRange64 != 42))) {
101  fatal("Invalid physical address range (%d)\n", _physAddrRange64);
102  }
103 }
104 
105 bool
107 {
108  return FullSystem? getArmSystem(tc)->haveSecurity() : false;
109 }
110 
111 bool
113 {
114  return FullSystem? getArmSystem(tc)->haveLPAE() : false;
115 }
116 
117 bool
119 {
120  return FullSystem? getArmSystem(tc)->haveVirtualization() : false;
121 }
122 
123 bool
125 {
126  return FullSystem? getArmSystem(tc)->highestELIs64() : true;
127 }
128 
131 {
132  return FullSystem? getArmSystem(tc)->highestEL() : EL1;
133 }
134 
135 bool
137 {
138  switch (el) {
139  case EL0:
140  case EL1:
141  return true;
142  case EL2:
143  return haveVirtualization(tc);
144  case EL3:
145  return haveSecurity(tc);
146  default:
147  warn("Unimplemented Exception Level\n");
148  return false;
149  }
150 }
151 
152 bool
154 {
155  return getArmSystem(tc)->haveTME();
156 }
157 
158 Addr
160 {
161  return getArmSystem(tc)->resetAddr();
162 }
163 
164 uint8_t
166 {
167  return getArmSystem(tc)->physAddrRange();
168 }
169 
170 Addr
172 {
173  return getArmSystem(tc)->physAddrMask();
174 }
175 
176 bool
178 {
179  return getArmSystem(tc)->haveLargeAsid64();
180 }
181 
182 bool
184 {
185  return FullSystem && getArmSystem(tc)->haveSemihosting();
186 }
187 
188 bool
190 {
191  return getArmSystem(tc)->semihosting->call64(tc, gem5_ops);
192 }
193 
194 bool
196 {
197  return getArmSystem(tc)->semihosting->call32(tc, gem5_ops);
198 }
199 
200 bool
202 {
203  if (ArmISA::inAArch64(tc))
204  return callSemihosting64(tc, gem5_ops);
205  else
206  return callSemihosting32(tc, gem5_ops);
207 }
208 
209 void
211 {
212  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
213  pwr_ctrl->setStandByWfi(tc);
214 }
215 
216 void
218 {
219  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
220  pwr_ctrl->clearStandByWfi(tc);
221 }
222 
223 bool
225 {
226  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
227  return pwr_ctrl->setWakeRequest(tc);
228  else
229  return true;
230 }
231 
232 void
234 {
235  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
236  pwr_ctrl->clearWakeRequest(tc);
237 }
238 
239 ArmSystem *
240 ArmSystemParams::create()
241 {
242  return new ArmSystem(this);
243 }
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:183
warn
#define warn(...)
Definition: logging.hh:239
ArmISA::EL2
@ EL2
Definition: types.hh:624
ArmSystem::callSemihosting32
static bool callSemihosting32(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from aarch32.
Definition: system.cc:195
ArmSystem::physAddrRange
uint8_t physAddrRange() const
Returns the supported physical address range in bits.
Definition: system.hh:257
ArmSystem::highestELIs64
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition: system.hh:207
ArmSystem::resetAddr
Addr resetAddr() const
Returns the reset address if the highest implemented exception level is 64 bits (ARMv8)
Definition: system.hh:222
ArmSystem::_resetAddr
Addr _resetAddr
Reset address (ARMv8)
Definition: system.hh:96
ArmISA::EL0
@ EL0
Definition: types.hh:622
fs_workload.hh
ArmSystem::physAddrMask
Addr physAddrMask() const
Returns the physical address mask.
Definition: system.hh:267
ArmISA::EL3
@ EL3
Definition: types.hh:625
ArmSemihosting::call32
bool call32(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch32 code.
Definition: semihosting.cc:189
FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:132
ArmSystem::getPowerController
FVPBasePwrCtrl * getPowerController() const
Get a pointer to the system's power controller.
Definition: system.hh:203
system.hh
ArmSystem::callSemihosting
static bool callSemihosting(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from either aarch64 or aarch32.
Definition: system.cc:201
ArmISA
Definition: ccregs.hh:41
ArmSystem::haveVirtualization
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
Definition: system.hh:173
Workload::getEntry
virtual Addr getEntry() const =0
ArmSystem::callSetStandByWfi
static void callSetStandByWfi(ThreadContext *tc)
Make a call to notify the power controller of STANDBYWFI assertion.
Definition: system.cc:210
FVPBasePwrCtrl
Definition: fvp_base_pwr_ctrl.hh:55
ArmSystem::getArmSystem
static ArmSystem * getArmSystem(ThreadContext *tc)
Returns a valid ArmSystem pointer if using ARM ISA, it fails otherwise.
Definition: system.hh:277
System::workload
Workload * workload
OS kernel.
Definition: system.hh:327
ArmSystem::haveSecurity
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
Definition: system.hh:164
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ArmSystem::haveLPAE
bool haveLPAE() const
Returns true if this system implements the Large Physical Address Extension.
Definition: system.hh:168
System
Definition: system.hh:73
ArmSemihosting::call64
bool call64(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch64 code.
Definition: semihosting.cc:163
ArmSystem::callSemihosting64
static bool callSemihosting64(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from aarch64.
Definition: system.cc:189
ArmISA::ExceptionLevel
ExceptionLevel
Definition: types.hh:621
ArmSystem::_highestELIs64
bool _highestELIs64
True if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition: system.hh:102
ArmISA::el
Bitfield< 3, 2 > el
Definition: miscregs_types.hh:69
ArmSystem::ArmSystem
ArmSystem(Params *p)
Definition: system.cc:58
ArmISA::EL1
@ EL1
Definition: types.hh:623
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
fvp_base_pwr_ctrl.hh
Workload::getArch
virtual Loader::Arch getArch() const =0
ArmSystem
Definition: system.hh:59
warn_if
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
Definition: logging.hh:263
ArmSystem::callClearStandByWfi
static void callClearStandByWfi(ThreadContext *tc)
Make a call to notify the power controller of STANDBYWFI deassertion.
Definition: system.cc:217
semihosting.hh
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
ArmSystem::highestEL
ArmISA::ExceptionLevel highestEL() const
Returns the highest implemented exception level.
Definition: system.hh:211
physical.hh
ArmSystem::Params
ArmSystemParams Params
Definition: system.hh:151
ArmSystem::haveEL
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition: system.cc:136
Loader::Arm64
@ Arm64
Definition: object_file.hh:51
ArmSystem::semihosting
ArmSemihosting *const semihosting
True if the Semihosting interface is enabled.
Definition: system.hh:145
ArmSystem::haveSemihosting
bool haveSemihosting() const
Is Arm Semihosting support enabled?
Definition: system.hh:270
symtab.hh
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
ArmISA::inAArch64
bool inAArch64(ThreadContext *tc)
Definition: utility.cc:222
ArmSystem::callSetWakeRequest
static bool callSetWakeRequest(ThreadContext *tc)
Notify the power controller of WAKEREQUEST assertion.
Definition: system.cc:224
gic_v2.hh
ArmSystem::haveTME
bool haveTME() const
Returns true if this system implements the transactional memory extension (ARMv9)
Definition: system.hh:231
Linux
Definition: threadinfo.hh:35
object_file.hh
thread_context.hh
ArmSystem::_physAddrRange64
const uint8_t _physAddrRange64
Supported physical address range in bits if the highest implemented exception level is 64 bits (ARMv8...
Definition: system.hh:108
ArmSystem::haveLargeAsid64
bool haveLargeAsid64() const
Returns true if ASID is 16 bits in AArch64 (ARMv8)
Definition: system.hh:226
ArmSystem::callClearWakeRequest
static void callClearWakeRequest(ThreadContext *tc)
Notify the power controller of WAKEREQUEST deassertion.
Definition: system.cc:233

Generated on Thu Mar 18 2021 12:09:10 for gem5 by doxygen 1.8.17