arch-arm: Add assertions when extracting an ArmSystem from a TC
We sometimes need to cast the System pointer stored in a ThreadContext to an ArmSystem pointer to query global system setting. Add an assertion to make sure that the cast resulted in a valid pointer. Change-Id: Id382d0c1dceefee8f74d070c205c7b43b83ab215 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/6161 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2012-2013, 2015 ARM Limited
|
||||
* Copyright (c) 2010, 2012-2013, 2015,2017 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
@@ -169,15 +169,18 @@ ArmSystem::initState()
|
||||
}
|
||||
}
|
||||
|
||||
ArmSystem*
|
||||
ArmSystem::getArmSystem(ThreadContext *tc)
|
||||
{
|
||||
ArmSystem *a_sys = dynamic_cast<ArmSystem *>(tc->getSystemPtr());
|
||||
assert(a_sys);
|
||||
return a_sys;
|
||||
}
|
||||
|
||||
bool
|
||||
ArmSystem::haveSecurity(ThreadContext *tc)
|
||||
{
|
||||
if (!FullSystem)
|
||||
return false;
|
||||
|
||||
ArmSystem *a_sys = dynamic_cast<ArmSystem *>(tc->getSystemPtr());
|
||||
assert(a_sys);
|
||||
return a_sys->haveSecurity();
|
||||
return FullSystem? getArmSystem(tc)->haveSecurity() : false;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,63 +204,49 @@ ArmSystem::getBootLoader(ObjectFile *const obj)
|
||||
bool
|
||||
ArmSystem::haveLPAE(ThreadContext *tc)
|
||||
{
|
||||
if (!FullSystem)
|
||||
return false;
|
||||
|
||||
ArmSystem *a_sys = dynamic_cast<ArmSystem *>(tc->getSystemPtr());
|
||||
assert(a_sys);
|
||||
return a_sys->haveLPAE();
|
||||
return FullSystem? getArmSystem(tc)->haveLPAE() : false;
|
||||
}
|
||||
|
||||
bool
|
||||
ArmSystem::haveVirtualization(ThreadContext *tc)
|
||||
{
|
||||
if (!FullSystem)
|
||||
return false;
|
||||
|
||||
ArmSystem *a_sys = dynamic_cast<ArmSystem *>(tc->getSystemPtr());
|
||||
assert(a_sys);
|
||||
return a_sys->haveVirtualization();
|
||||
return FullSystem? getArmSystem(tc)->haveVirtualization() : false;
|
||||
}
|
||||
|
||||
bool
|
||||
ArmSystem::highestELIs64(ThreadContext *tc)
|
||||
{
|
||||
return FullSystem ?
|
||||
dynamic_cast<ArmSystem *>(tc->getSystemPtr())->highestELIs64() :
|
||||
true;
|
||||
return FullSystem? getArmSystem(tc)->highestELIs64() : true;
|
||||
}
|
||||
|
||||
ExceptionLevel
|
||||
ArmSystem::highestEL(ThreadContext *tc)
|
||||
{
|
||||
return FullSystem ?
|
||||
dynamic_cast<ArmSystem *>(tc->getSystemPtr())->highestEL() :
|
||||
EL1;
|
||||
return FullSystem? getArmSystem(tc)->highestEL() : EL1;
|
||||
}
|
||||
|
||||
Addr
|
||||
ArmSystem::resetAddr64(ThreadContext *tc)
|
||||
{
|
||||
return dynamic_cast<ArmSystem *>(tc->getSystemPtr())->resetAddr64();
|
||||
return getArmSystem(tc)->resetAddr64();
|
||||
}
|
||||
|
||||
uint8_t
|
||||
ArmSystem::physAddrRange(ThreadContext *tc)
|
||||
{
|
||||
return dynamic_cast<ArmSystem *>(tc->getSystemPtr())->physAddrRange();
|
||||
return getArmSystem(tc)->physAddrRange();
|
||||
}
|
||||
|
||||
Addr
|
||||
ArmSystem::physAddrMask(ThreadContext *tc)
|
||||
{
|
||||
return dynamic_cast<ArmSystem *>(tc->getSystemPtr())->physAddrMask();
|
||||
return getArmSystem(tc)->physAddrMask();
|
||||
}
|
||||
|
||||
bool
|
||||
ArmSystem::haveLargeAsid64(ThreadContext *tc)
|
||||
{
|
||||
return dynamic_cast<ArmSystem *>(tc->getSystemPtr())->haveLargeAsid64();
|
||||
return getArmSystem(tc)->haveLargeAsid64();
|
||||
}
|
||||
|
||||
ArmSystem *
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2012-2013, 2015-2016 ARM Limited
|
||||
* Copyright (c) 2010, 2012-2013, 2015-2017 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
@@ -228,6 +228,12 @@ class ArmSystem : public System
|
||||
*/
|
||||
const AddrRange &m5opRange() const { return _m5opRange; }
|
||||
|
||||
/**
|
||||
* Returns a valid ArmSystem pointer if using ARM ISA, it fails
|
||||
* otherwise.
|
||||
*/
|
||||
static ArmSystem* getArmSystem(ThreadContext *tc);
|
||||
|
||||
/** Returns true if the system of a specific thread context implements the
|
||||
* Security Extensions
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user