summaryrefslogtreecommitdiff
path: root/BaseTools/Source
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2016-03-23 17:55:50 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-13 09:31:03 +0800
commitd135538d7ab10b1d4e25bcfc5c5c4af1a6df0ee7 (patch)
treededc888583546b7b0fcb6694ca6ed8293d1bcf8b /BaseTools/Source
parenta7388528447f84acadb2c51cdf26ae77e03ffd98 (diff)
downloadedk2-platforms-d135538d7ab10b1d4e25bcfc5c5c4af1a6df0ee7.tar.xz
BaseTools: generate alignment when the FV content come from the filesystem
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> (cherry picked from commit 877c0a93be4317f5715347359cc78d41f4654748)
Diffstat (limited to 'BaseTools/Source')
-rw-r--r--BaseTools/Source/Python/GenFds/FvImageSection.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index caf8de11e5..b577de263c 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -1,7 +1,7 @@
## @file
# process FV image section generation
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -83,6 +83,24 @@ class FvImageSection(FvImageSectionClassObject):
else:
if self.FvFileName != None:
FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName)
+ if os.path.isfile(FvFileName):
+ FvFileObj = open (FvFileName,'r+b')
+ FvFileObj.seek(0)
+ # PI FvHeader is 0x48 byte
+ FvHeaderBuffer = FvFileObj.read(0x48)
+ # FV alignment position.
+ FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
+ # FvAlignmentValue is larger than or equal to 1K
+ if FvAlignmentValue >= 0x400:
+ if FvAlignmentValue >= 0x10000:
+ #The max alignment supported by FFS is 64K.
+ self.Alignment = "64K"
+ else:
+ self.Alignment = str (FvAlignmentValue / 0x400) + "K"
+ else:
+ # FvAlignmentValue is less than 1K
+ self.Alignment = str (FvAlignmentValue)
+ FvFileObj.close()
else:
EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSection Failed! %s NOT found in FDF" % self.FvName)