X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFv.py;h=fd5ad0e9ac382f104a8a249bec7529dc940ca52f;hb=0d2711a69397d2971079121df4326d84736c181e;hp=6190bceba88d439a2969f679a71a15363710541a;hpb=a709adfaf0bebbaf3d989f56b500e3985687d0e3;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 6190bceba8..fd5ad0e9ac 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -1,9 +1,9 @@ ## @file # process FV generation # -# Copyright (c) 2007, Intel Corporation +# Copyright (c) 2007 - 2010, 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 @@ -46,7 +46,9 @@ class FV (FvClassObject): self.InfFileName = None self.FvAddressFileName = None self.CapsuleName = None - + self.FvBaseAddress = None + self.FvForceRebase = None + ## AddToBuffer() # # Generate Fv and add it to the Buffer @@ -63,7 +65,7 @@ class FV (FvClassObject): # def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}) : - if self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys(): + if BaseAddress == None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] # @@ -81,9 +83,12 @@ class FV (FvClassObject): elif RegionData.upper() + 'fv' in GenFds.ImageBinDict.keys(): continue elif self.UiFvName.upper() == RegionData.upper(): - GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper())) + 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) + + if self.FvBaseAddress != None: + BaseAddress = self.FvBaseAddress self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict) # @@ -103,7 +108,7 @@ class FV (FvClassObject): # Process Modules in FfsList for FfsFile in self.FfsList : - FileName = FfsFile.GenFfs(MacroDict) + FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress) FfsFileList.append(FileName) self.FvInfFile.writelines("EFI_FILE_NAME = " + \ FileName + \ @@ -122,13 +127,47 @@ class FV (FvClassObject): FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf') shutil.copy(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName) + OrigFvInfo = None + if os.path.exists (FvInfoFileName): + OrigFvInfo = open(FvInfoFileName, 'r').read() GenFdsGlobalVariable.GenerateFirmwareVolume( FvOutputFile, [self.InfFileName], AddressFile=FvInfoFileName, - FfsList=FfsFileList + FfsList=FfsFileList, + ForceRebase=self.FvForceRebase ) + NewFvInfo = None + if os.path.exists (FvInfoFileName): + NewFvInfo = open(FvInfoFileName, 'r').read() + if NewFvInfo != None and NewFvInfo != OrigFvInfo: + FvChildAddr = [] + AddFileObj = open(FvInfoFileName, 'r') + AddrStrings = AddFileObj.readlines() + AddrKeyFound = False + for AddrString in AddrStrings: + if AddrKeyFound: + #get base address for the inside FvImage + FvChildAddr.append (AddrString) + elif AddrString.find ("[FV_BASE_ADDRESS]") != -1: + AddrKeyFound = True + AddFileObj.close() + + if FvChildAddr != []: + # Update Ffs again + for FfsFile in self.FfsList : + FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress) + + #Update GenFv again + GenFdsGlobalVariable.GenerateFirmwareVolume( + FvOutputFile, + [self.InfFileName], + AddressFile=FvInfoFileName, + FfsList=FfsFileList, + ForceRebase=self.FvForceRebase + ) + # # Write the Fv contents to Buffer # @@ -138,6 +177,21 @@ class FV (FvClassObject): 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" + else: + self.FvAlignment = str (FvAlignmentValue / 0x400) + "K" + else: + # FvAlignmentValue is less than 1K + self.FvAlignment = str (FvAlignmentValue) FvFileObj.close() GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile return FvOutputFile @@ -179,6 +233,10 @@ class FV (FvClassObject): ' 0x%X' %BlockNum + \ T_CHAR_LF) else: + if self.BlockSizeList == []: + #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: self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \