Giacomo Travaglini has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/34376 )

Change subject: dev-arm: Define a ParentMem object for DTB autogen
......................................................................

dev-arm: Define a ParentMem object for DTB autogen

A memory willing to autogenerate child nodes can do that directly in
the generateDeviceTree method.  However sometimes portions of memory
(child nodes) are tagged for specific applications. Hardcoding the
child node in the parent memory class is not flexible, so we delegate
this to the application model, which is registering the generator
helper via the ParentMem interface

JIRA: https://gem5.atlassian.net/browse/GEM5-768

Change-Id: I5fa5bac0decf5399dbaa3804569998dc5e6d7bc0
Signed-off-by: Giacomo Travaglini <[email protected]>
---
M src/dev/arm/RealView.py
1 file changed, 36 insertions(+), 1 deletion(-)



diff --git a/src/dev/arm/RealView.py b/src/dev/arm/RealView.py
index cc03900..4750be8 100644
--- a/src/dev/arm/RealView.py
+++ b/src/dev/arm/RealView.py
@@ -542,7 +542,40 @@

         yield node

-class MmioSRAM(SimpleMemory):
+class ParentMem(SimpleMemory):
+    """
+    This is a base abstract class for child node generation
+    A memory willing to autogenerate child nodes can do that
+    directly in the generateDeviceTree method.
+    However sometimes portions of memory (child nodes) are tagged
+    for specific applications. Hardcoding the child node in the
+    parent memory class is not flexible, so we delegate this
+    to the application model, which is registering the generator
+    helper via the ParentMem interface.
+    """
+    def __init__(self, *args, **kwargs):
+        super(ParentMem, self).__init__(**kwargs)
+        self._sub_nodes = []
+
+    def addSubnodeGenerator(self, gen):
+        """
+        This is the method a client application would use to
+        register a child generator in the memory object.
+        """
+        self._sub_nodes.append(gen)
+
+    def generateSubnodes(self, node, state):
+        """
+        This is the method the memory would use to instantiate
+        the child nodes via the previously registered generators.
+        """
+        for subnode_gen in self._sub_nodes:
+            node.append(subnode_gen(state))
+
+class MmioSRAM(ParentMem):
+    def __init__(self, *args, **kwargs):
+        super(MmioSRAM, self).__init__(**kwargs)
+
     def generateDeviceTree(self, state):
         node = FdtNode("sram@%x" % long(self.range.start))
         node.appendCompatible(["mmio-sram"])
@@ -558,6 +591,8 @@
             state.addrCells(self.range.start) +
             state.sizeCells(self.range.size()) ))

+        self.generateSubnodes(node, state)
+
         yield node

 class FVPBasePwrCtrl(BasicPioDevice):

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

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I5fa5bac0decf5399dbaa3804569998dc5e6d7bc0
Gerrit-Change-Number: 34376
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to