configs: Produce list of workload types in workloads.py
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Tue, 21 Apr 2020 16:27:06 +0000 (17:27 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Thu, 23 Apr 2020 09:23:08 +0000 (09:23 +0000)
Change-Id: I3f585e006704e671775af8d66d241e555d34cb08
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27970
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Tested-by: kokoro <noreply+kokoro@google.com>
configs/example/arm/workloads.py

index 61e57f6a9046bb6a4c5832143d353bf1e8a65207..6952a4a80b176e9d83bb98ed57fc54c9eb9f09b9 100644 (file)
 from __future__ import print_function
 from __future__ import absolute_import
 
+import inspect
 import m5
 from m5.objects import *
 from m5.options import *
 
+from common.ObjectList import ObjectList
 from common.SysPaths import binary, disk
 
 class ArmBaremetal(ArmFsWorkload):
@@ -83,3 +85,12 @@ class ArmTrustedFirmware(ArmFsWorkload):
 
         # Arm Trusted Firmware will provide a PSCI implementation
         system._have_psci = True
+
+class _WorkloadList(ObjectList):
+    def _add_objects(self):
+        """Add all sub-classes of the base class in the object hierarchy."""
+        modname = sys.modules[__name__]
+        for name, cls in inspect.getmembers(modname, self._is_obj_class):
+            self._sub_classes[name] = cls
+
+workload_list = _WorkloadList(getattr(m5.objects, 'ArmFsWorkload', None))