]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg/SplitFspBin.py: Support rebasing 1.x binary.
authorChasel Chiu <chasel.chiu@intel.com>
Tue, 28 May 2019 13:51:39 +0000 (21:51 +0800)
committerChasel Chiu <chasel.chiu@intel.com>
Fri, 31 May 2019 06:02:34 +0000 (14:02 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1308

Support rebasing FSP 1.x binary.
FSP 1.x has single component in binary so not supported
by split command and rebase can be done with the same
command for rebasing FSP-T component in FSP 2.x image.

Test: both FSP 2.x (Kabylake) and FSP 1.x (BroadwellDE) binary
      can be rebased successfully.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
IntelFsp2Pkg/Tools/SplitFspBin.py
IntelFsp2Pkg/Tools/UserManuals/SplitFspBinUserManual.md

index 2458231d090d07ae4ca2f7fa0f8a405e819c8ca0..15c8bebee27839731b73daaaadd20d99cd12fd9b 100644 (file)
@@ -1,6 +1,6 @@
 ## @ FspTool.py\r
 #\r
 ## @ FspTool.py\r
 #\r
-# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -14,12 +14,12 @@ import argparse
 from   ctypes import *\r
 \r
 """\r
 from   ctypes import *\r
 \r
 """\r
-This utility supports some operations for Intel FSP 2.0 image.\r
+This utility supports some operations for Intel FSP 1.x/2.x image.\r
 It supports:\r
 It supports:\r
-    - Display FSP 2.0 information header\r
-    - Split FSP 2.0 image into individual FSP-T/M/S/O component\r
-    - Rebase FSP 2.0 components to a different base address\r
-    - Generate FSP mapping C header file\r
+    - Display FSP 1.x/2.x information header\r
+    - Split FSP 2.x image into individual FSP-T/M/S/O component\r
+    - Rebase FSP 1.x/2.x components to a different base address\r
+    - Generate FSP 1.x/2.x mapping C header file\r
 """\r
 \r
 CopyRightHeaderFile = """/*\r
 """\r
 \r
 CopyRightHeaderFile = """/*\r
@@ -500,8 +500,6 @@ class FirmwareDevice:
 \r
         fih = None\r
         for fsp in self.FspList:\r
 \r
         fih = None\r
         for fsp in self.FspList:\r
-            if fsp.Fih.HeaderRevision < 3:\r
-                raise Exception("ERROR: FSP 1.x is not supported by this tool !")\r
             if not fih:\r
                 fih = fsp.Fih\r
             else:\r
             if not fih:\r
                 fih = fsp.Fih\r
             else:\r
@@ -713,6 +711,8 @@ def SplitFspBin (fspfile, outdir, nametemplate):
     fd.ParseFsp ()\r
 \r
     for fsp in fd.FspList:\r
     fd.ParseFsp ()\r
 \r
     for fsp in fd.FspList:\r
+        if fsp.Fih.HeaderRevision < 3:\r
+            raise Exception("ERROR: FSP 1.x is not supported by the split command !")\r
         ftype = fsp.Type\r
         if not nametemplate:\r
             nametemplate = fspfile\r
         ftype = fsp.Type\r
         if not nametemplate:\r
             nametemplate = fspfile\r
@@ -742,6 +742,11 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile):
 \r
         found = False\r
         for fsp in fd.FspList:\r
 \r
         found = False\r
         for fsp in fd.FspList:\r
+            # Is this FSP 1.x single binary?\r
+            if fsp.Fih.HeaderRevision < 3:\r
+                found = True\r
+                ftype = 'X'\r
+                break\r
             ftype = fsp.Type.lower()\r
             if ftype == fspcomp:\r
                 found = True\r
             ftype = fsp.Type.lower()\r
             if ftype == fspcomp:\r
                 found = True\r
index 064e0ac84529fb0dcc6fbb1dc44928addc07f3e4..06d87bbb2e1dcdfe60edc7d40c2718edbfda3687 100644 (file)
@@ -1,68 +1,71 @@
-# SplitFspBin.py is a python script to support some operations on Intel FSP 2.0 image.\r
+# SplitFspBin.py is a python script to support some operations on Intel FSP 1.x/2.x image.\r
 \r
 It supports:\r
 \r
 \r
 It supports:\r
 \r
-- Split Intel FSP 2.0 image into individual FSP-T/M/S/O component\r
+- Split Intel FSP 2.x image into individual FSP-T/M/S/O component\r
 \r
 \r
-- Rebase Intel FSP 2.0 components to different base addresses\r
+- Rebase Intel FSP 1.x/2.x components to different base addresses\r
 \r
 \r
-- Generate Intel FSP 2.0 C header file\r
+- Generate Intel FSP 1.x/2.x C header file\r
 \r
 \r
-- Display Intel FSP 2.0 information header for each FSP component\r
+- Display Intel FSP 1.x/2.x information header for each FSP component\r
 \r
 \r
-## Split Intel FSP 2.0 image\r
+## Split Intel FSP 2.x image\r
 \r
 \r
-To split individual FSP component in Intel FSP 2.0 image, the following\r
+FSP 1.x image is not supported by split command.\r
+To split individual FSP component in Intel FSP 2.x image, the following\r
 command can be used:\r
 \r
    **python SplitFspBin.py split [-h] -f FSPBINARY [-o OUTPUTDIR] [-n NAMETEMPLATE]**\r
 \r
 command can be used:\r
 \r
    **python SplitFspBin.py split [-h] -f FSPBINARY [-o OUTPUTDIR] [-n NAMETEMPLATE]**\r
 \r
-For example:  \r
+For example:\r
 \r
    `python SplitFspBin.py split -f FSP.bin`\r
 \r
    It will create FSP_T.bin, FSP_M.bin and FSP_S.bin in current directory.\r
 \r
 \r
    `python SplitFspBin.py split -f FSP.bin`\r
 \r
    It will create FSP_T.bin, FSP_M.bin and FSP_S.bin in current directory.\r
 \r
-## Rebase Intel FSP 2.0 components\r
+## Rebase Intel FSP 1.x/2.x components\r
 \r
 \r
-To rebase one or multiple FSP components in Intel FSP 2.0 image, the following\r
+To rebase one or multiple FSP components in Intel FSP 1.x/2.x image, the following\r
 command can be used:\r
 \r
    **python SplitFspBin.py rebase [-h] -f FSPBINARY -c {t,m,s,o} [{t,m,s,o} ...] -b FSPBASE [FSPBASE ...] [-o OUTPUTDIR] [-n OUTPUTFILE]**\r
 \r
 command can be used:\r
 \r
    **python SplitFspBin.py rebase [-h] -f FSPBINARY -c {t,m,s,o} [{t,m,s,o} ...] -b FSPBASE [FSPBASE ...] [-o OUTPUTDIR] [-n OUTPUTFILE]**\r
 \r
-For example:  \r
+For example:\r
 \r
 \r
-   `python SplitFspBin.py rebase -f FSP.bin –c t –b 0xFFF00000 –n FSP_new.bin`\r
+   `python SplitFspBin.py rebase -f FSP.bin -c t -b 0xFFF00000 -n FSP_new.bin`\r
 \r
    It will rebase FSP-T component inside FSP.bin to new base 0xFFF00000 and save the\r
 \r
    It will rebase FSP-T component inside FSP.bin to new base 0xFFF00000 and save the\r
-   rebased Intel FSP 2.0 image into file FSP_new.bin.\r
+   rebased Intel FSP 2.x image into file FSP_new.bin.\r
+   For FSP 1.x image there is only one component in binary so above command also\r
+   works for FSP 1.x image.\r
 \r
 \r
-   `python SplitFspBin.py rebase -f FSP.bin –c t m –b 0xFFF00000 0xFEF80000 –n FSP_new.bin`\r
+   `python SplitFspBin.py rebase -f FSP.bin -c t m -b 0xFFF00000 0xFEF80000 -n FSP_new.bin`\r
 \r
    It will rebase FSP-T and FSP-M components inside FSP.bin to new base 0xFFF00000\r
 \r
    It will rebase FSP-T and FSP-M components inside FSP.bin to new base 0xFFF00000\r
-   and 0xFEF80000 respectively, and save the rebased Intel FSP 2.0 image into file \r
+   and 0xFEF80000 respectively, and save the rebased Intel FSP 2.x image into file\r
    FSP_new.bin file.\r
 \r
    FSP_new.bin file.\r
 \r
-## Generate Intel FSP 2.0 C header file\r
+## Generate Intel FSP 1.x/2.x C header file\r
 \r
 \r
-To generate Intel FSP 2.0 C header file, the following command can be used:\r
+To generate Intel FSP 1.x/2.x C header file, the following command can be used:\r
 \r
    **Python SplitFspBin.py genhdr [-h] -f FSPBINARY [-o OUTPUTDIR] [-n HFILENAME]**\r
 \r
 \r
    **Python SplitFspBin.py genhdr [-h] -f FSPBINARY [-o OUTPUTDIR] [-n HFILENAME]**\r
 \r
-For example:  \r
+For example:\r
 \r
 \r
-   `python SplitFspBin.py genhdr -f FSP.bin n FSP.h`\r
+   `python SplitFspBin.py genhdr -f FSP.bin -n FSP.h`\r
 \r
    It will create the C header file FSP.h containing the image ID, revision, offset\r
    and size for each individual FSP component.\r
 \r
 \r
    It will create the C header file FSP.h containing the image ID, revision, offset\r
    and size for each individual FSP component.\r
 \r
-## Display Intel FSP 2.0 information header\r
+## Display Intel FSP 1.x/2.x information header\r
 \r
 \r
-To display Intel FSP 2.0 information headers, the following command can be used:\r
+To display Intel FSP 1.x/2.x information headers, the following command can be used:\r
 \r
    **Python SplitFspBin.py info [-h] -f FSPBINARY**\r
 \r
 \r
    **Python SplitFspBin.py info [-h] -f FSPBINARY**\r
 \r
-For example:  \r
+For example:\r
 \r
    `python SplitFspBin.py info -f FSP.bin`\r
 \r
 \r
    `python SplitFspBin.py info -f FSP.bin`\r
 \r