gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
system.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 2012-2013, 2015-2019 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  * Authors: Ali Saidi
41  */
42 
43 #ifndef __ARCH_ARM_SYSTEM_HH__
44 #define __ARCH_ARM_SYSTEM_HH__
45 
46 #include <memory>
47 #include <string>
48 #include <vector>
49 
50 #include "kern/linux/events.hh"
51 #include "params/ArmSystem.hh"
52 #include "params/GenericArmSystem.hh"
53 #include "sim/sim_object.hh"
54 #include "sim/system.hh"
55 
56 class GenericTimer;
57 class BaseGic;
58 class ThreadContext;
59 
60 class ArmSystem : public System
61 {
62  protected:
68 
71 
76 
80  const bool _haveSecurity;
81 
85  const bool _haveLPAE;
86 
90  const bool _haveVirtualization;
91 
95  const bool _haveCrypto;
96 
102 
107 
113 
118  const uint8_t _physAddrRange64;
119 
123  const bool _haveLargeAsid64;
124 
128  const bool _haveSVE;
129 
131  const unsigned _sveVL;
132 
136  const bool _haveLSE;
137 
139  const unsigned _havePAN;
140 
145 
146  protected:
154  ObjectFile *getBootLoader(ObjectFile *const obj);
155 
156  public:
157  typedef ArmSystemParams Params;
158  const Params *
159  params() const
160  {
161  return dynamic_cast<const Params *>(_params);
162  }
163 
164  ArmSystem(Params *p);
165  ~ArmSystem();
166 
170  virtual void initState();
171 
173  {
174  // Remove the low bit that thumb symbols have set
175  // but that aren't actually odd aligned
176  if (addr & 0x1)
177  return addr & ~1;
178  return addr;
179  }
180 
182  bool multiProc;
183 
185  bool haveSecurity() const { return _haveSecurity; }
186 
189  bool haveLPAE() const { return _haveLPAE; }
190 
194  bool haveVirtualization() const { return _haveVirtualization; }
195 
199  bool haveCrypto() const { return _haveCrypto; }
200 
202  void setGenericTimer(GenericTimer *generic_timer)
203  {
204  _genericTimer = generic_timer;
205  }
206 
209  {
210  _gic = gic;
211  }
212 
215 
217  BaseGic *getGIC() const { return _gic; }
218 
221  bool highestELIs64() const { return _highestELIs64; }
222 
225  {
226  if (_haveSecurity)
227  return EL3;
228  if (_haveVirtualization)
229  return EL2;
230  return EL1;
231  }
232 
235  Addr resetAddr() const { return _resetAddr; }
236 
238  bool haveLargeAsid64() const { return _haveLargeAsid64; }
239 
241  bool haveSVE() const { return _haveSVE; }
242 
244  unsigned sveVL() const { return _sveVL; }
245 
247  bool haveLSE() const { return _haveLSE; }
248 
250  bool havePAN() const { return _havePAN; }
251 
254  uint8_t physAddrRange64() const { return _physAddrRange64; }
255 
257  uint8_t physAddrRange() const
258  {
259  if (_highestELIs64)
260  return _physAddrRange64;
261  if (_haveLPAE)
262  return 40;
263  return 32;
264  }
265 
268  {
269  return mask(physAddrRange());
270  }
271 
273  bool haveSemihosting() const { return semihosting != nullptr; }
274 
280  static ArmSystem *getArmSystem(System *sys);
281 
286  static ArmSystem* getArmSystem(ThreadContext *tc);
287 
291  static bool haveSecurity(ThreadContext *tc);
292 
296  static bool haveVirtualization(ThreadContext *tc);
297 
301  static bool haveLPAE(ThreadContext *tc);
302 
306  static bool highestELIs64(ThreadContext *tc);
307 
312 
314  static bool haveEL(ThreadContext *tc, ExceptionLevel el);
315 
319  static Addr resetAddr(ThreadContext *tc);
320 
324  static uint8_t physAddrRange(ThreadContext *tc);
325 
329  static Addr physAddrMask(ThreadContext *tc);
330 
333  static bool haveLargeAsid64(ThreadContext *tc);
334 
336  static bool haveSemihosting(ThreadContext *tc);
337 
339  static uint64_t callSemihosting64(ThreadContext *tc,
340  uint32_t op, uint64_t param);
341 
343  static uint32_t callSemihosting32(ThreadContext *tc,
344  uint32_t op, uint32_t param);
345 };
346 
348 {
349  public:
350  typedef GenericArmSystemParams Params;
351  const Params *
352  params() const
353  {
354  return dynamic_cast<const Params *>(_params);
355  }
356 
357  GenericArmSystem(Params *p) : ArmSystem(p) {};
358  virtual ~GenericArmSystem() {};
359 
363  virtual void initState();
364 };
365 
366 #endif
ObjectFile * getBootLoader(ObjectFile *const obj)
Get a boot loader that matches the kernel.
Definition: system.cc:215
const uint8_t _physAddrRange64
Supported physical address range in bits if the highest implemented exception level is 64 bits (ARMv8...
Definition: system.hh:118
Addr physAddrMask() const
Returns the physical address mask.
Definition: system.hh:267
const unsigned _sveVL
SVE vector length at reset, in quadwords.
Definition: system.hh:131
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
Definition: system.hh:185
const bool _haveLargeAsid64
True if ASID is 16 bits in AArch64 (ARMv8)
Definition: system.hh:123
const bool _haveSVE
True if SVE is implemented (ARMv8)
Definition: system.hh:128
const unsigned _havePAN
True if Priviledge Access Never is implemented.
Definition: system.hh:139
bool havePAN() const
Returns true if Priviledge Access Never is implemented.
Definition: system.hh:250
GenericArmSystem(Params *p)
Definition: system.hh:357
ip6_addr_t addr
Definition: inet.hh:335
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8) ...
Definition: system.hh:221
const Addr _resetAddr
Reset address (ARMv8)
Definition: system.hh:106
static uint64_t callSemihosting64(ThreadContext *tc, uint32_t op, uint64_t param)
Make a Semihosting call from aarch64.
Definition: system.cc:297
Definition: system.hh:77
ThreadContext is the external interface to all thread state for anything outside of the CPU...
STL vector class.
Definition: stl.hh:40
void setGenericTimer(GenericTimer *generic_timer)
Sets the pointer to the Generic Timer.
Definition: system.hh:202
ObjectFile * bootldr
Pointer to the bootloader object.
Definition: system.hh:75
ExceptionLevel
Definition: types.hh:585
static bool haveEL(ThreadContext *tc, ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition: system.cc:250
bool haveSVE() const
Returns true if SVE is implemented (ARMv8)
Definition: system.hh:241
ArmSystem(Params *p)
Definition: system.cc:60
uint8_t physAddrRange64() const
Returns the supported physical address range in bits if the highest implemented exception level is 64...
Definition: system.hh:254
const Params * params() const
Definition: system.hh:352
Bitfield< 3, 2 > el
const bool _haveLSE
True if LSE is implemented (ARMv8.1)
Definition: system.hh:136
std::vector< std::unique_ptr< ObjectFile > > bootLoaders
Bootloaders.
Definition: system.hh:70
bool _highestELIs64
True if the register width of the highest implemented exception level is 64 bits (ARMv8) ...
Definition: system.hh:112
bool multiProc
true if this a multiprocessor system
Definition: system.hh:182
const bool _haveVirtualization
True if this system implements the virtualization Extensions.
Definition: system.hh:90
Semihosting for AArch32 and AArch64.
Definition: semihosting.hh:69
unsigned sveVL() const
Returns the SVE vector length at reset, in quadwords.
Definition: system.hh:244
static ArmSystem * getArmSystem(System *sys)
Casts the provided System object into a valid ArmSystem, it fails otherwise.
Definition: system.cc:186
virtual ~GenericArmSystem()
Definition: system.hh:358
BaseGic * getGIC() const
Get a pointer to the system&#39;s GIC.
Definition: system.hh:217
static uint32_t callSemihosting32(ThreadContext *tc, uint32_t op, uint32_t param)
Make a Semihosting call from aarch32.
Definition: system.cc:305
Linux::DebugPrintkEvent * debugPrintkEvent
PC based event to skip the dprink() call and emulate its functionality.
Definition: system.hh:67
GenericArmSystemParams Params
Definition: system.hh:350
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
Definition: system.hh:194
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
~ArmSystem()
Definition: system.cc:208
bool haveCrypto() const
Returns true if this system implements the Crypto Extension.
Definition: system.hh:199
Params * _params
Definition: system.hh:571
void setGIC(BaseGic *gic)
Sets the pointer to the GIC.
Definition: system.hh:208
uint8_t physAddrRange() const
Returns the supported physical address range in bits.
Definition: system.hh:257
ExceptionLevel highestEL() const
Returns the highest implemented exception level.
Definition: system.hh:224
ArmSemihosting *const semihosting
True if the Semihosting interface is enabled.
Definition: system.hh:144
ArmSystemParams Params
Definition: system.hh:157
virtual void initState()
Initialise the system.
Definition: system.cc:132
GenericTimer * _genericTimer
Pointer to the Generic Timer wrapper.
Definition: system.hh:100
virtual Addr fixFuncEventAddr(Addr addr)
Fix up an address used to match PCs for hooking simulator events on to target function executions...
Definition: system.hh:172
Bitfield< 27, 24 > gic
bool haveLSE() const
Returns true if LSE is implemented (ARMv8.1)
Definition: system.hh:247
GenericTimer * getGenericTimer() const
Get a pointer to the system&#39;s generic timer model.
Definition: system.hh:214
BaseGic * _gic
Definition: system.hh:101
const bool _haveLPAE
True if this system implements the Large Physical Address Extension.
Definition: system.hh:85
Bitfield< 3, 0 > mask
Definition: types.hh:64
const bool _haveCrypto
True if this system implements the Crypto Extension.
Definition: system.hh:95
Bitfield< 4 > op
Definition: types.hh:80
const bool _haveSecurity
True if this system implements the Security Extensions.
Definition: system.hh:80
bool haveLargeAsid64() const
Returns true if ASID is 16 bits in AArch64 (ARMv8)
Definition: system.hh:238
bool haveSemihosting() const
Is Arm Semihosting support enabled?
Definition: system.hh:273
Bitfield< 0 > p
const Params * params() const
Definition: system.hh:159
Addr resetAddr() const
Returns the reset address if the highest implemented exception level is 64 bits (ARMv8) ...
Definition: system.hh:235
bool haveLPAE() const
Returns true if this system implements the Large Physical Address Extension.
Definition: system.hh:189

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13