]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: generate alignment when the FV content come from the filesystem
authorYonghong Zhu <yonghong.zhu@intel.com>
Wed, 23 Mar 2016 09:55:50 +0000 (17:55 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Sun, 27 Mar 2016 07:12:50 +0000 (15:12 +0800)
when the FV contents come from the filesystem instead of from a named FDF
section, the build tool missed to generate alignment for this FV. The fix
is get the alignment value from FV header and use this value to generate
alignment.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/GenFds/FvImageSection.py

index caf8de11e5ba2cae6d44f2e90b53d5650c5cd99e..b577de263c533ac6dc9b6c4c50cea58fc2213d37 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FV image section generation\r
 #\r
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -83,6 +83,24 @@ class FvImageSection(FvImageSectionClassObject):
             else:\r
                 if self.FvFileName != None:\r
                     FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName)\r
+                    if os.path.isfile(FvFileName):\r
+                        FvFileObj = open (FvFileName,'r+b')\r
+                        FvFileObj.seek(0)\r
+                        # PI FvHeader is 0x48 byte\r
+                        FvHeaderBuffer = FvFileObj.read(0x48)\r
+                        # FV alignment position.\r
+                        FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
+                        # FvAlignmentValue is larger than or equal to 1K\r
+                        if FvAlignmentValue >= 0x400:\r
+                            if FvAlignmentValue >= 0x10000:\r
+                                #The max alignment supported by FFS is 64K.\r
+                                self.Alignment = "64K"\r
+                            else:\r
+                                self.Alignment = str (FvAlignmentValue / 0x400) + "K"\r
+                        else:\r
+                            # FvAlignmentValue is less than 1K\r
+                            self.Alignment = str (FvAlignmentValue)\r
+                        FvFileObj.close()\r
                 else:\r
                     EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSection Failed! %s NOT found in FDF" % self.FvName)\r
 \r