arch-arm, configs: Create single instance of DTB autogeneration
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 25 Jan 2019 14:29:24 +0000 (14:29 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 30 Jan 2019 12:14:00 +0000 (12:14 +0000)
This patch is rewriting the DTB autogeneration functions available in
fs_bigLITTLE.py and fs.py as a single method in the GenericArmSystem
so that other configuration scripts can make use of it.

Change-Id: I492bbf77e6b0ac5c5fbdbc75c0eecba29bd63bda
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/15958
Reviewed-by: Ciro Santilli <ciro.santilli@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

configs/example/arm/fs_bigLITTLE.py
configs/example/fs.py
src/arch/arm/ArmSystem.py

index 8cf89e3c782efde28453947936054e11391dcb4d..f363872a3c4aeab5617e0e408994fe3a100cf9fa 100644 (file)
@@ -261,16 +261,7 @@ def build(options):
     if options.dtb is not None:
         system.dtb_filename = SysPaths.binary(options.dtb)
     else:
-        def create_dtb_for_system(system, filename):
-            state = FdtState(addr_cells=2, size_cells=2, cpu_cells=1)
-            rootNode = system.generateDeviceTree(state)
-
-            fdt = Fdt()
-            fdt.add_rootnode(rootNode)
-            dtb_filename = os.path.join(m5.options.outdir, filename)
-            return fdt.writeDtbFile(dtb_filename)
-
-        system.dtb_filename = create_dtb_for_system(system, 'system.dtb')
+        system.generateDtb(m5.options.outdir, 'system.dtb')
 
     return root
 
index 4d216588404fd95afc5509d80c6cbefecceba7ad..05eca87fb4cfddc66965690bcbb49103222d73ce 100644 (file)
@@ -360,19 +360,10 @@ if buildEnv['TARGET_ISA'] == "arm" and not options.bare_metal \
              "with generation functionality.")
 
     # Generate a Device Tree
-    def create_dtb_for_system(system, filename):
-        state = FdtState(addr_cells=2, size_cells=2, cpu_cells=1)
-        rootNode = system.generateDeviceTree(state)
-
-        fdt = Fdt()
-        fdt.add_rootnode(rootNode)
-        dtb_filename = os.path.join(m5.options.outdir, filename)
-        return fdt.writeDtbFile(dtb_filename)
-
     for sysname in ('system', 'testsys', 'drivesys'):
         if hasattr(root, sysname):
             sys = getattr(root, sysname)
-            sys.dtb_filename = create_dtb_for_system(sys, '%s.dtb' % sysname)
+            sys.generateDtb(m5.options.outdir, '%s.dtb' % sysname)
 
 Simulation.setWorkCountOptions(test_sys, options)
 Simulation.run(options, root, test_sys, FutureClass)
index bee38a41c0880b76196fcdb0253b7a18babfc8a9..98ff9591884226e90ce2fba53964645c85a1f52a 100644 (file)
@@ -37,6 +37,7 @@
 #          Glenn Bergmans
 
 from m5.params import *
+from m5.options import *
 from m5.SimObject import *
 from m5.util.fdthelper import *
 
@@ -138,6 +139,19 @@ class GenericArmSystem(ArmSystem):
     panic_on_oops = Param.Bool(False, "Trigger a gem5 panic if the " \
                                    "guest kernel oopses")
 
+    def generateDtb(self, outdir, filename):
+        """
+        Autogenerate DTB. Arguments are the folder where the DTB
+        will be stored, and the name of the DTB file.
+        """
+        state = FdtState(addr_cells=2, size_cells=2, cpu_cells=1)
+        rootNode = self.generateDeviceTree(state)
+
+        fdt = Fdt()
+        fdt.add_rootnode(rootNode)
+        dtb_filename = os.path.join(outdir, filename)
+        self.dtb_filename = fdt.writeDtbFile(dtb_filename)
+
 class LinuxArmSystem(GenericArmSystem):
     type = 'LinuxArmSystem'
     cxx_header = "arch/arm/linux/system.hh"