summaryrefslogtreecommitdiff
path: root/src/python/m5/SimObject.py
diff options
context:
space:
mode:
authorGlenn Bergmans <glenn.bergmans@arm.com>2015-12-16 15:43:42 +0000
committerCurtis Dunham <curtis.dunham@arm.com>2018-01-29 22:21:30 +0000
commit7c8662f54a6beb4c07da4b2b58f19e5b94909bc8 (patch)
tree9b7ff9b17903a6e795f6624c24739af81b3692d9 /src/python/m5/SimObject.py
parent3da05785813662f647b07400734337630a9f6f78 (diff)
downloadgem5-7c8662f54a6beb4c07da4b2b58f19e5b94909bc8.tar.xz
arm: DT autogeneration - Device Tree generation methods
This patch adds an extra layer to the pyfdt library such that usage gets easier and device tree nodes can be specified in less code, without limiting original usage. Note to not import both the pyfdt and fdthelper in the same namespace (but generally fdthelper is all you need, because it supplies the same classes even when they are not extended in any way) Also, this patch lays out the primary functionality for generating a device tree, where every SimObject gets an empty generateDeviceTree method and ArmSystems loop over their children in an effort to merge all the nodes. Devices are implemented in other patches. Change-Id: I4d0a0666827287fe42e18447f19acab4dc80cc49 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-on: https://gem5-review.googlesource.com/5962 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/python/m5/SimObject.py')
-rw-r--r--src/python/m5/SimObject.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index cff818c66..919c0e852 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -51,6 +51,9 @@ import inspect
import m5
from m5.util import *
from m5.util.pybind import *
+# Use the pyfdt and not the helper class, because the fdthelper
+# relies on the SimObject definition
+from m5.ext.pyfdt import pyfdt
# Have to import params up top since Param is referenced on initial
# load (when SimObject class references Param to create a class
@@ -1495,6 +1498,19 @@ class SimObject(object):
for (attr, portRef) in sorted(self._port_refs.iteritems()):
portRef.ccConnect()
+ # Default function for generating the device structure.
+ # Can be overloaded by the inheriting class
+ def generateDeviceTree(self, state):
+ return # return without yielding anything
+ yield # make this function a (null) generator
+
+ def recurseDeviceTree(self, state):
+ for child in [getattr(self, c) for c in self._children]:
+ for item in child: # For looping over SimObjectVectors
+ if isinstance(item, SimObject):
+ for dt in item.generateDeviceTree(state):
+ yield dt
+
# Function to provide to C++ so it can look up instances based on paths
def resolveSimObject(name):
obj = instanceDict[name]