gem5  v20.1.0.0
system.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 2012-2013, 2015,2017-2020 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  _havePAN(p->have_pan),
75  _haveSecEL2(p->have_secel2),
76  semihosting(p->semihosting),
77  multiProc(p->multi_proc)
78 {
79  if (p->auto_reset_addr) {
81  } else {
82  _resetAddr = p->reset_addr;
84  "Workload entry point %#x and reset address %#x are different",
86  }
87 
88  bool wl_is_64 = (workload->getArch() == Loader::Arm64);
89  if (wl_is_64 != _highestELIs64) {
90  warn("Highest ARM exception-level set to AArch%d but the workload "
91  "is for AArch%d. Assuming you wanted these to match.",
92  _highestELIs64 ? 64 : 32, wl_is_64 ? 64 : 32);
93  _highestELIs64 = wl_is_64;
94  }
95 
96  if (_highestELIs64 && (
97  _physAddrRange64 < 32 ||
98  _physAddrRange64 > 48 ||
99  (_physAddrRange64 % 4 != 0 && _physAddrRange64 != 42))) {
100  fatal("Invalid physical address range (%d)\n", _physAddrRange64);
101  }
102 }
103 
104 bool
106 {
107  return FullSystem? getArmSystem(tc)->haveSecurity() : false;
108 }
109 
110 bool
112 {
113  return FullSystem? getArmSystem(tc)->haveLPAE() : false;
114 }
115 
116 bool
118 {
119  return FullSystem? getArmSystem(tc)->haveVirtualization() : false;
120 }
121 
122 bool
124 {
125  return FullSystem? getArmSystem(tc)->highestELIs64() : true;
126 }
127 
130 {
131  return FullSystem? getArmSystem(tc)->highestEL() : EL1;
132 }
133 
134 bool
136 {
137  switch (el) {
138  case EL0:
139  case EL1:
140  return true;
141  case EL2:
142  return haveVirtualization(tc);
143  case EL3:
144  return haveSecurity(tc);
145  default:
146  warn("Unimplemented Exception Level\n");
147  return false;
148  }
149 }
150 
151 bool
153 {
154  return getArmSystem(tc)->haveTME();
155 }
156 
157 Addr
159 {
160  return getArmSystem(tc)->resetAddr();
161 }
162 
163 uint8_t
165 {
166  return getArmSystem(tc)->physAddrRange();
167 }
168 
169 Addr
171 {
172  return getArmSystem(tc)->physAddrMask();
173 }
174 
175 bool
177 {
178  return getArmSystem(tc)->haveLargeAsid64();
179 }
180 
181 bool
183 {
184  return FullSystem && getArmSystem(tc)->haveSemihosting();
185 }
186 
187 bool
189 {
190  return getArmSystem(tc)->semihosting->call64(tc, gem5_ops);
191 }
192 
193 bool
195 {
196  return getArmSystem(tc)->semihosting->call32(tc, gem5_ops);
197 }
198 
199 bool
201 {
202  if (ArmISA::inAArch64(tc))
203  return callSemihosting64(tc, gem5_ops);
204  else
205  return callSemihosting32(tc, gem5_ops);
206 }
207 
208 void
210 {
211  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
212  pwr_ctrl->setStandByWfi(tc);
213 }
214 
215 void
217 {
218  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
219  pwr_ctrl->clearStandByWfi(tc);
220 }
221 
222 bool
224 {
225  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
226  return pwr_ctrl->setWakeRequest(tc);
227  else
228  return true;
229 }
230 
231 void
233 {
234  if (FVPBasePwrCtrl *pwr_ctrl = getArmSystem(tc)->getPowerController())
235  pwr_ctrl->clearWakeRequest(tc);
236 }
237 
238 ArmSystem *
239 ArmSystemParams::create()
240 {
241  return new ArmSystem(this);
242 }
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:194
ArmSystem::physAddrRange
uint8_t physAddrRange() const
Returns the supported physical address range in bits.
Definition: system.hh:251
ArmSystem::highestELIs64
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition: system.hh:204
ArmSystem::resetAddr
Addr resetAddr() const
Returns the reset address if the highest implemented exception level is 64 bits (ARMv8)
Definition: system.hh:219
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:261
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:200
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:200
ArmISA
Definition: ccregs.hh:41
ArmSystem::haveVirtualization
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
Definition: system.hh:170
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:209
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:271
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:161
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:165
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:188
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:216
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:208
physical.hh
ArmSystem::Params
ArmSystemParams Params
Definition: system.hh:148
ArmSystem::haveEL
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition: system.cc:135
Loader::Arm64
@ Arm64
Definition: object_file.hh:51
ArmSystem::semihosting
ArmSemihosting *const semihosting
True if the Semihosting interface is enabled.
Definition: system.hh:142
ArmSystem::haveSemihosting
bool haveSemihosting() const
Is Arm Semihosting support enabled?
Definition: system.hh:264
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:223
gic_v2.hh
ArmSystem::haveTME
bool haveTME() const
Returns true if this system implements the transactional memory extension (ARMv9)
Definition: system.hh:228
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:223
ArmSystem::callClearWakeRequest
static void callClearWakeRequest(ThreadContext *tc)
Notify the power controller of WAKEREQUEST deassertion.
Definition: system.cc:232

Generated on Wed Sep 30 2020 14:02:01 for gem5 by doxygen 1.8.17