From: Adrian Herrera Date: Fri, 25 Oct 2019 18:21:59 +0000 (+0100) Subject: arch-arm: generic method for getting an ArmSystem X-Git-Tag: v19.0.0.0~341 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3783d653690b654e40091f93392cecea93e15032;p=gem5.git arch-arm: generic method for getting an ArmSystem This patch provides a generic method for casting a System object into an ArmSystem object. This is specially useful in dev-arm, since devices by default obtain a generic System reference which needs to be casted to use ArmSystem-specific functionality. Change-Id: Ib100002413cb48cd93772dcf38f13be65badd1d3 Reviewed-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22426 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini Tested-by: kokoro --- diff --git a/src/arch/arm/system.cc b/src/arch/arm/system.cc index bf2881026..6add9c065 100644 --- a/src/arch/arm/system.cc +++ b/src/arch/arm/system.cc @@ -174,6 +174,14 @@ ArmSystem::initState() } } +ArmSystem * +ArmSystem::getArmSystem(System *sys) +{ + ArmSystem *a_sys = dynamic_cast(sys); + assert(a_sys); + return a_sys; +} + ArmSystem* ArmSystem::getArmSystem(ThreadContext *tc) { diff --git a/src/arch/arm/system.hh b/src/arch/arm/system.hh index 46c58e8a1..a9048051e 100644 --- a/src/arch/arm/system.hh +++ b/src/arch/arm/system.hh @@ -284,6 +284,13 @@ class ArmSystem : public System /** Is Arm Semihosting support enabled? */ bool haveSemihosting() const { return semihosting != nullptr; } + /** + * Casts the provided System object into a valid ArmSystem, it fails + * otherwise. + * @param sys System object to cast + */ + static ArmSystem *getArmSystem(System *sys); + /** * Returns a valid ArmSystem pointer if using ARM ISA, it fails * otherwise.