Re: [U-Boot] [PATCH v2 35/37] binman: Add support for Intel IFWI entries

2019-07-17 Thread sjg
An Integrated Firmware Image is used to hold various binaries used for
booting with Apollolake and some later devices. Add support for this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/etype/intel_descriptor.py|   6 +-
 tools/binman/etype/intel_ifwi.py  | 100 ++
 tools/binman/ftest.py |  55 ++
 tools/binman/test/111_x86-rom-ifwi.dts|  29 +
 tools/binman/test/112_x86-rom-ifwi-nodesc.dts |  28 +
 tools/binman/test/113_x86-rom-ifwi-nodata.dts |  29 +
 tools/binman/test/fitimage.bin.gz | Bin 0 -> 8418 bytes
 tools/binman/test/ifwi.bin.gz | Bin 0 -> 1884 bytes
 8 files changed, 245 insertions(+), 2 deletions(-)
 create mode 100644 tools/binman/etype/intel_ifwi.py
 create mode 100644 tools/binman/test/111_x86-rom-ifwi.dts
 create mode 100644 tools/binman/test/112_x86-rom-ifwi-nodesc.dts
 create mode 100644 tools/binman/test/113_x86-rom-ifwi-nodata.dts
 create mode 100644 tools/binman/test/fitimage.bin.gz
 create mode 100644 tools/binman/test/ifwi.bin.gz

Applied to u-boot-dm, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 35/37] binman: Add support for Intel IFWI entries

2019-07-08 Thread Simon Glass
An Integrated Firmware Image is used to hold various binaries used for
booting with Apollolake and some later devices. Add support for this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/etype/intel_descriptor.py|   6 +-
 tools/binman/etype/intel_ifwi.py  | 100 ++
 tools/binman/ftest.py |  55 ++
 tools/binman/test/111_x86-rom-ifwi.dts|  29 +
 tools/binman/test/112_x86-rom-ifwi-nodesc.dts |  28 +
 tools/binman/test/113_x86-rom-ifwi-nodata.dts |  29 +
 tools/binman/test/fitimage.bin.gz | Bin 0 -> 8418 bytes
 tools/binman/test/ifwi.bin.gz | Bin 0 -> 1884 bytes
 8 files changed, 245 insertions(+), 2 deletions(-)
 create mode 100644 tools/binman/etype/intel_ifwi.py
 create mode 100644 tools/binman/test/111_x86-rom-ifwi.dts
 create mode 100644 tools/binman/test/112_x86-rom-ifwi-nodesc.dts
 create mode 100644 tools/binman/test/113_x86-rom-ifwi-nodata.dts
 create mode 100644 tools/binman/test/fitimage.bin.gz
 create mode 100644 tools/binman/test/ifwi.bin.gz

diff --git a/tools/binman/etype/intel_descriptor.py 
b/tools/binman/etype/intel_descriptor.py
index 65ba2391e69..adea578080c 100644
--- a/tools/binman/etype/intel_descriptor.py
+++ b/tools/binman/etype/intel_descriptor.py
@@ -60,10 +60,12 @@ class Entry_intel_descriptor(Entry_blob):
 for i in range(MAX_REGIONS):
 self._regions.append(Region(self.data, frba, i))
 
-# Set the offset for ME (Management Engine) only, for now, since the
-# others are not used
+# Set the offset for ME (Management Engine) and IFWI (Integrated
+# Firmware Image), for now, since the others are not used.
 info = {}
 if self.HasSibling('intel-me'):
 info['intel-me'] = [self._regions[REGION_ME].base,
 self._regions[REGION_ME].size]
+if self.HasSibling('intel-ifwi'):
+info['intel-ifwi'] = [self._regions[REGION_BIOS].base, None]
 return info
diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py
new file mode 100644
index 000..8c79b2dd291
--- /dev/null
+++ b/tools/binman/etype/intel_ifwi.py
@@ -0,0 +1,100 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass 
+#
+# Entry-type module for Intel Management Engine binary blob
+#
+
+from collections import OrderedDict
+
+from entry import Entry
+from blob import Entry_blob
+import fdt_util
+import tools
+
+class Entry_intel_ifwi(Entry_blob):
+"""Entry containing an Intel Integrated Firmware Image (IFWI) file
+
+Properties / Entry arguments:
+- filename: Filename of file to read into entry. This is either the
+IFWI file itself, or a file that can be converted into one using a
+tool
+- convert-fit: If present this indicates that the ifwitool should be
+used to convert the provided file into a IFWI.
+
+This file contains code and data used by the SoC that is required to make
+it work. It includes U-Boot TPL, microcode, things related to the CSE
+(Converged Security Engine, the microcontroller that loads all the 
firmware)
+and other items beyond the wit of man.
+
+A typical filename is 'ifwi.bin' for an IFWI file, or 'fitimage.bin' for a
+file that will be converted to an IFWI.
+
+The position of this entry is generally set by the intel-descriptor entry.
+
+The contents of the IFWI are specified by the subnodes of the IFWI node.
+Each subnode describes an entry which is placed into the IFWFI with a given
+sub-partition (and optional entry name).
+
+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)
+
+# Create the IFWI file if needed
+if self._convert_fit:
+inname = self._pathname
+outname = tools.GetOutputFilename('ifwi.bin')
+tools.RunIfwiTool(inname, tools.CMD_CREATE, outname)
+