diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2016-05-06 17:14:26 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-13 09:32:56 +0800 |
commit | 5f6184c9617b079722771368d85c63b1721673e3 (patch) | |
tree | 1adfe78c31eebdb6d846b1b5c61dc14e876d5317 /BaseTools | |
parent | 929802742646fa73a8f495eb5fd63545f2d9cf10 (diff) | |
download | edk2-5f6184c9617b079722771368d85c63b1721673e3.tar.gz edk2-5f6184c9617b079722771368d85c63b1721673e3.tar.bz2 edk2-5f6184c9617b079722771368d85c63b1721673e3.zip |
BaseTools: Fix bug in GenFds to handle FV image alignment
Cover the case that .fv file in the [Binaries] section.
Cc: Liming Gao <liming.gao@intel.com>
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 321151fedb3013fe3a588ee7a4fe6639ceb29c7e)
Diffstat (limited to 'BaseTools')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FvImageSection.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py index b577de263c..748d02f700 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -60,10 +60,35 @@ class FvImageSection(FvImageSectionClassObject): Num = SecNum
- for FileName in FileList:
+ MaxFvAlignment = 0
+ for FvFileName in FileList:
+ FvAlignmentValue = 0
+ 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)
+ FvFileObj.close()
+ if FvAlignmentValue > MaxFvAlignment:
+ MaxFvAlignment = FvAlignmentValue
+
OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
OutputFileList.append(OutputFile)
+
+ # MaxFvAlignment is larger than or equal to 1K
+ if MaxFvAlignment >= 0x400:
+ if MaxFvAlignment >= 0x10000:
+ #The max alignment supported by FFS is 64K.
+ self.Alignment = "64K"
+ else:
+ self.Alignment = str (MaxFvAlignment / 0x400) + "K"
+ else:
+ # MaxFvAlignment is less than 1K
+ self.Alignment = str (MaxFvAlignment)
+
return OutputFileList, self.Alignment
#
# Generate Fv
|