arch-arm: generic method for getting an ArmSystem
authorAdrian Herrera <adrian.herrera@arm.com>
Fri, 25 Oct 2019 18:21:59 +0000 (19:21 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 1 Nov 2019 09:41:44 +0000 (09:41 +0000)
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 <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22426
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/system.cc
src/arch/arm/system.hh

index bf2881026fe8a1fbdd9134e10d4a3a6a2a9f15b7..6add9c065ca8c3dc58a91a1e29d2a5568ad84f14 100644 (file)
@@ -174,6 +174,14 @@ ArmSystem::initState()
     }
 }
 
+ArmSystem *
+ArmSystem::getArmSystem(System *sys)
+{
+    ArmSystem *a_sys = dynamic_cast<ArmSystem *>(sys);
+    assert(a_sys);
+    return a_sys;
+}
+
 ArmSystem*
 ArmSystem::getArmSystem(ThreadContext *tc)
 {
index 46c58e8a16869ad1c10a969e177b499d78980b54..a9048051eaed9660c5368979f761241f57c68680 100644 (file)
@@ -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.