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>
This commit is contained in:
Glenn Bergmans
2015-12-16 15:43:42 +00:00
committed by Curtis Dunham
parent 3da0578581
commit 7c8662f54a
5 changed files with 298 additions and 1 deletions

View File

@@ -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]