rockchip: rk3399: Add Nanopi M4 2GB board support
[platform/kernel/u-boot.git] / tools / binman / etype / intel_ifwi.py
index 9cbdf36..36aadc2 100644 (file)
@@ -36,30 +36,25 @@ class Entry_intel_ifwi(Entry_blob):
     Each subnode describes an entry which is placed into the IFWFI with a given
     sub-partition (and optional entry name).
 
+    Properties for subnodes:
+        ifwi-subpart - sub-parition to put this entry into, e.g. "IBBP"
+        ifwi-entry - entry name t use, e.g. "IBBL"
+        ifwi-replace - if present, indicates that the item should be replaced
+            in the IFWI. Otherwise it is added.
+
     See README.x86 for information about x86 binary blobs.
     """
     def __init__(self, section, etype, node):
         Entry_blob.__init__(self, section, etype, node)
         self._convert_fit = fdt_util.GetBool(self._node, 'convert-fit')
         self._ifwi_entries = OrderedDict()
-        self._ReadSubnodes()
-
-    def ObtainContents(self):
-        """Get the contects for the IFWI
-
-        Unfortunately we cannot create anything from scratch here, as Intel has
-        tools which create precursor binaries with lots of data and settings,
-        and these are not incorporated into binman.
-
-        The first step is to get a file in the IFWI format. This is either
-        supplied directly or is extracted from a fitimage using the 'create'
-        subcommand.
 
-        After that we delete the OBBP sub-partition and add each of the files
-        that we want in the IFWI file, one for each sub-entry of the IWFI node.
-        """
-        self._pathname = tools.GetInputFilename(self._filename)
+    def ReadNode(self):
+        self._ReadSubnodes()
+        Entry_blob.ReadNode(self)
 
+    def _BuildIfwi(self):
+        """Build the contents of the IFWI and write it to the 'data' property"""
         # Create the IFWI file if needed
         if self._convert_fit:
             inname = self._pathname
@@ -69,33 +64,62 @@ class Entry_intel_ifwi(Entry_blob):
             self._pathname = outname
         else:
             # Provide a different code path here to ensure we have test coverage
-            inname = self._pathname
+            outname = self._pathname
 
         # Delete OBBP if it is there, then add the required new items.
-        tools.RunIfwiTool(inname, tools.CMD_DELETE, subpart='OBBP')
+        tools.RunIfwiTool(outname, tools.CMD_DELETE, subpart='OBBP')
 
         for entry in self._ifwi_entries.values():
             # First get the input data and put it in a file
-            if not entry.ObtainContents():
-                return False
             data = entry.GetData()
             uniq = self.GetUniqueName()
             input_fname = tools.GetOutputFilename('input.%s' % uniq)
             tools.WriteFile(input_fname, data)
 
-            tools.RunIfwiTool(inname,
+            tools.RunIfwiTool(outname,
                 tools.CMD_REPLACE if entry._ifwi_replace else tools.CMD_ADD,
                 input_fname, entry._ifwi_subpart, entry._ifwi_entry_name)
 
         self.ReadBlobContents()
         return True
 
+    def ObtainContents(self):
+        """Get the contects for the IFWI
+
+        Unfortunately we cannot create anything from scratch here, as Intel has
+        tools which create precursor binaries with lots of data and settings,
+        and these are not incorporated into binman.
+
+        The first step is to get a file in the IFWI format. This is either
+        supplied directly or is extracted from a fitimage using the 'create'
+        subcommand.
+
+        After that we delete the OBBP sub-partition and add each of the files
+        that we want in the IFWI file, one for each sub-entry of the IWFI node.
+        """
+        self._pathname = tools.GetInputFilename(self._filename)
+        for entry in self._ifwi_entries.values():
+            if not entry.ObtainContents():
+                return False
+        return self._BuildIfwi()
+
+    def ProcessContents(self):
+        orig_data = self.data
+        self._BuildIfwi()
+        same = orig_data == self.data
+        return same
+
     def _ReadSubnodes(self):
         """Read the subnodes to find out what should go in this IFWI"""
         for node in self._node.subnodes:
             entry = Entry.Create(self.section, node)
             entry.ReadNode()
-            entry._ifwi_replace = fdt_util.GetBool(node, 'replace')
+            entry._ifwi_replace = fdt_util.GetBool(node, 'ifwi-replace')
             entry._ifwi_subpart = fdt_util.GetString(node, 'ifwi-subpart')
             entry._ifwi_entry_name = fdt_util.GetString(node, 'ifwi-entry')
             self._ifwi_entries[entry._ifwi_subpart] = entry
+
+    def WriteSymbols(self, section):
+        """Write symbol values into binary files for access at run time"""
+        for entry in self._ifwi_entries.values():
+            entry.WriteSymbols(self)