X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFv.py;h=df97ccbab6484fd74d85b09c8429d11d26bd5055;hb=eadb60d96f3aec44ad58b31cb3c30b3e68e288c1;hp=6c7a0503cfa61ac1a31ffec2fc340a4dd614597c;hpb=9508d0fa4fb2cd2ff03604bc3b1b1abf8f69ccb6;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 6c7a0503cf..df97ccbab6 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -1,7 +1,7 @@ ## @file # process FV generation # -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -15,8 +15,7 @@ ## # Import Modules # -import os -import shutil +import Common.LongFilePathOs as os import subprocess import StringIO from struct import * @@ -27,8 +26,11 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable from GenFds import GenFds from CommonDataClass.FdfClass import FvClassObject from Common.Misc import SaveFileOnChange +from Common.LongFilePathSupport import CopyLongFilePath +from Common.LongFilePathSupport import OpenLongFilePath as open T_CHAR_LF = '\n' +FV_UI_EXT_ENTY_GUID = 'A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C' ## generate FV # @@ -86,6 +88,8 @@ class FV (FvClassObject): GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper())) GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvName) + GenFdsGlobalVariable.LargeFileInFvFlags.append(False) + FFSGuid = None if self.FvBaseAddress != None: BaseAddress = self.FvBaseAddress @@ -126,16 +130,19 @@ class FV (FvClassObject): FvOutputFile = self.CreateFileName FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf') - shutil.copy(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName) + CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName) OrigFvInfo = None if os.path.exists (FvInfoFileName): OrigFvInfo = open(FvInfoFileName, 'r').read() + if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: + FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID; GenFdsGlobalVariable.GenerateFirmwareVolume( FvOutputFile, [self.InfFileName], AddressFile=FvInfoFileName, FfsList=FfsFileList, - ForceRebase=self.FvForceRebase + ForceRebase=self.FvForceRebase, + FileSystemGuid=FFSGuid ) NewFvInfo = None @@ -159,43 +166,74 @@ class FV (FvClassObject): for FfsFile in self.FfsList : FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress) + if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: + FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID; #Update GenFv again GenFdsGlobalVariable.GenerateFirmwareVolume( FvOutputFile, [self.InfFileName], AddressFile=FvInfoFileName, FfsList=FfsFileList, - ForceRebase=self.FvForceRebase + ForceRebase=self.FvForceRebase, + FileSystemGuid=FFSGuid ) # # Write the Fv contents to Buffer # - FvFileObj = open ( FvOutputFile,'r+b') + if os.path.isfile(FvOutputFile): + FvFileObj = open ( FvOutputFile,'r+b') - GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName) - GenFdsGlobalVariable.SharpCounter = 0 + GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName) + GenFdsGlobalVariable.SharpCounter = 0 - Buffer.write(FvFileObj.read()) - 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.FvAlignment = "64K" + Buffer.write(FvFileObj.read()) + 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.FvAlignment = "64K" + else: + self.FvAlignment = str (FvAlignmentValue / 0x400) + "K" else: - self.FvAlignment = str (FvAlignmentValue / 0x400) + "K" + # FvAlignmentValue is less than 1K + self.FvAlignment = str (FvAlignmentValue) + FvFileObj.close() + GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile + GenFdsGlobalVariable.LargeFileInFvFlags.pop() else: - # FvAlignmentValue is less than 1K - self.FvAlignment = str (FvAlignmentValue) - FvFileObj.close() - GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile + GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName) return FvOutputFile + ## _GetBlockSize() + # + # Calculate FV's block size + # Inherit block size from FD if no block size specified in FV + # + def _GetBlockSize(self): + if self.BlockSizeList: + return True + + for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): + FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + for RegionObj in FdObj.RegionList: + if RegionObj.RegionType != 'FV': + continue + for RegionData in RegionObj.RegionDataList: + # + # Found the FD and region that contain this FV + # + if self.UiFvName.upper() == RegionData.upper(): + RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, self) + if self.BlockSizeList: + return True + return False + ## __InitializeInf__() # # Initilize the inf file to create FV @@ -234,8 +272,9 @@ class FV (FvClassObject): T_CHAR_LF) else: if self.BlockSizeList == []: - #set default block size is 1 - self.FvInfFile.writelines("EFI_BLOCK_SIZE = 0x1" + T_CHAR_LF) + if not self._GetBlockSize(): + #set default block size is 1 + self.FvInfFile.writelines("EFI_BLOCK_SIZE = 0x1" + T_CHAR_LF) for BlockSize in self.BlockSizeList : if BlockSize[0] != None: @@ -285,15 +324,36 @@ class FV (FvClassObject): if self.FvNameGuid <> None and self.FvNameGuid <> '': TotalSize = 16 + 4 Buffer = '' + if self.FvNameString == 'TRUE': + # + # Create EXT entry for FV UI name + # This GUID is used: A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C + # + FvUiLen = len(self.UiFvName) + TotalSize += (FvUiLen + 16 + 4) + Guid = FV_UI_EXT_ENTY_GUID.split('-') + # + # Layout: + # EFI_FIRMWARE_VOLUME_EXT_ENTRY : size 4 + # GUID : size 16 + # FV UI name + # + Buffer += (pack('HH', (FvUiLen + 16 + 4), 0x0002) + + pack('=LHHBBBBBBBB', int(Guid[0], 16), int(Guid[1], 16), int(Guid[2], 16), + int(Guid[3][-4:-2], 16), int(Guid[3][-2:], 16), int(Guid[4][-12:-10], 16), + int(Guid[4][-10:-8], 16), int(Guid[4][-8:-6], 16), int(Guid[4][-6:-4], 16), + int(Guid[4][-4:-2], 16), int(Guid[4][-2:], 16)) + + self.UiFvName) + for Index in range (0, len(self.FvExtEntryType)): if self.FvExtEntryType[Index] == 'FILE': - # check if the path is absolute or relative - if os.path.isabs(self.FvExtEntryData[Index]): - FileFullPath = os.path.normpath(self.FvExtEntryData[Index]) - else: - FileFullPath = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.FvExtEntryData[Index])) - # check if the file path exists or not - if not os.path.isfile(FileFullPath): + # check if the path is absolute or relative + if os.path.isabs(self.FvExtEntryData[Index]): + FileFullPath = os.path.normpath(self.FvExtEntryData[Index]) + else: + FileFullPath = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.FvExtEntryData[Index])) + # check if the file path exists or not + if not os.path.isfile(FileFullPath): GenFdsGlobalVariable.ErrorLogger("Error opening FV Extension Header Entry file %s." % (self.FvExtEntryData[Index])) FvExtFile = open (FileFullPath,'rb') FvExtFile.seek(0,2)