From 3783d653690b654e40091f93392cecea93e15032 Mon Sep 17 00:00:00 2001 From: Adrian Herrera Date: Fri, 25 Oct 2019 19:21:59 +0100 Subject: 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 --- src/arch/arm/system.cc | 8 ++++++++ src/arch/arm/system.hh | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'src/arch') 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. -- cgit v1.2.3