X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFvImageSection.py;h=68f17c31e8be27207564e330435096b38b423b5c;hb=c46bced224b42d5a03bc8b207167829aa4e7bc5b;hp=c945ce9b9bdaff70fbc8933e41ea8b126646f65d;hpb=52302d4dee589a5df43a464420c9fe68ba83937d;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py index c945ce9b9b..68f17c31e8 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -1,9 +1,9 @@ ## @file # process FV image section generation # -# Copyright (c) 2007, Intel Corporation +# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# -# All rights reserved. This program and the accompanying materials +# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php @@ -20,7 +20,7 @@ import StringIO from Ffs import Ffs import subprocess from GenFdsGlobalVariable import GenFdsGlobalVariable -import os +import Common.LongFilePathOs as os from CommonDataClass.FdfClass import FvImageSectionClassObject from Common import EdkLogger from Common.BuildToolError import * @@ -60,10 +60,38 @@ 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,'rb') + 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 >= 0x100000: + #The max alignment supported by FFS is 16M. + if MaxFvAlignment >=1000000: + self.Alignment = "16M" + else: + self.Alignment = str(MaxFvAlignment / 0x100000) + "M" + else: + self.Alignment = str (MaxFvAlignment / 0x400) + "K" + else: + # MaxFvAlignment is less than 1K + self.Alignment = str (MaxFvAlignment) + return OutputFileList, self.Alignment # # Generate Fv @@ -83,6 +111,27 @@ class FvImageSection(FvImageSectionClassObject): else: if self.FvFileName != None: FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName) + if os.path.isfile(FvFileName): + FvFileObj = open (FvFileName,'rb') + 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 >= 0x100000: + #The max alignment supported by FFS is 16M. + if FvAlignmentValue >= 0x1000000: + self.Alignment = "16M" + else: + self.Alignment = str(FvAlignmentValue / 0x100000) + "M" + 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)