Curtis Dunham has submitted this change and it was merged. ( https://gem5-review.googlesource.com/5968 )

Change subject: config: Embed Device Tree generation in fs.py config
......................................................................

config: Embed Device Tree generation in fs.py config

Equips the fs.py config routine with an extra commandline option
--generate-dtb that will generate a dtb file automatically before
running the simulation. Only works with ARM systems and gives a warning
if the simulated system is not of --machine-type VExpress_GEM5_V1.

Change-Id: I7766e5459fd9bec2245de83cef103091ebaf7229
Reviewed-by: Curtis Dunham <[email protected]>
Reviewed-by: Andreas Sandberg <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/5968
Maintainer: Andreas Sandberg <[email protected]>
---
M configs/common/FSConfig.py
M configs/common/Options.py
M configs/example/fs.py
3 files changed, 41 insertions(+), 5 deletions(-)

Approvals:
  Andreas Sandberg: Looks good to me, approved; Looks good to me, approved



diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py
index c08353a..fc8765b 100644
--- a/configs/common/FSConfig.py
+++ b/configs/common/FSConfig.py
@@ -204,7 +204,8 @@

 def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None,
                   dtb_filename=None, bare_metal=False, cmdline=None,
-                  external_memory="", ruby=False, security=False):
+                  external_memory="", ruby=False, security=False,
+                  ignore_dtb=False):
     assert machine_type

     default_dtbs = {
@@ -249,7 +250,7 @@
     machine_type = platform_class.__name__
     self.realview = platform_class()

-    if not dtb_filename and not bare_metal:
+    if not dtb_filename and not (bare_metal or ignore_dtb):
         try:
             dtb_filename = default_dtbs[machine_type]
         except KeyError:
@@ -305,7 +306,7 @@
         if machine_type in default_kernels:
             self.kernel = binary(default_kernels[machine_type])

-        if dtb_filename:
+        if dtb_filename and not ignore_dtb:
             self.dtb_filename = binary(dtb_filename)

self.machine_type = machine_type if machine_type in ArmMachineType.map \
diff --git a/configs/common/Options.py b/configs/common/Options.py
index ea7c75b..29ef74c 100644
--- a/configs/common/Options.py
+++ b/configs/common/Options.py
@@ -343,6 +343,8 @@
         parser.add_option("--enable-context-switch-stats-dump", \
                 action="store_true", help="Enable stats dump at context "\
                 "switches and dump tasks file (required for Streamline)")
+ parser.add_option("--generate-dtb", action="store_true", default=False,
+                    help="Automatically generate a dtb file")

     # Benchmark options
     parser.add_option("--dual", action="store_true",
diff --git a/configs/example/fs.py b/configs/example/fs.py
index 351d1c0..031457c 100644
--- a/configs/example/fs.py
+++ b/configs/example/fs.py
@@ -48,6 +48,7 @@
 from m5.defines import buildEnv
 from m5.objects import *
 from m5.util import addToPath, fatal, warn
+from m5.util.fdthelper import *

 addToPath('../')

@@ -99,7 +100,9 @@
options.num_cpus, bm[0], options.dtb_filename,
                                  bare_metal=options.bare_metal,
                                  cmdline=cmdline,
- external_memory=options.external_memory_system,
+                                 ignore_dtb=options.generate_dtb,
+                                 external_memory=
+                                   options.external_memory_system,
                                  ruby=options.ruby,
security=options.enable_security_extensions)
         if options.enable_context_switch_stats_dump:
@@ -248,7 +251,8 @@
                                        cmdline=cmdline)
     elif buildEnv['TARGET_ISA'] == 'arm':
         drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, np,
- bm[1], options.dtb_filename, cmdline=cmdline) + bm[1], options.dtb_filename, cmdline=cmdline,
+                                  ignore_dtb=options.generate_dtb)

     # Create a top-level voltage domain
     drive_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
@@ -362,5 +366,34 @@
 if options.frame_capture:
     VncServer.frame_capture = True

+if buildEnv['TARGET_ISA'] == "arm" and options.generate_dtb:
+    # Sanity checks
+    if options.dtb_filename:
+ fatal("--generate-dtb and --dtb-filename cannot be specified at the"\
+             "same time.")
+
+    if options.machine_type not in ["VExpress_GEM5", "VExpress_GEM5_V1"]:
+        warn("Can only correctly generate a dtb for VExpress_GEM5_V1 " \
+ "platforms, unless custom hardware models have been equipped "\
+             "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)
+
+elif buildEnv['TARGET_ISA'] != "arm" and options.generate_dtb:
+    fatal("Can only generate dtb files for ARM systems.")
+
 Simulation.setWorkCountOptions(test_sys, options)
 Simulation.run(options, root, test_sys, FutureClass)

--
To view, visit https://gem5-review.googlesource.com/5968
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7766e5459fd9bec2245de83cef103091ebaf7229
Gerrit-Change-Number: 5968
Gerrit-PatchSet: 3
Gerrit-Owner: Curtis Dunham <[email protected]>
Gerrit-Assignee: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Curtis Dunham <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to