- #\r
- # Write the Fv contents to Buffer\r
- #\r
- if os.path.isfile(FvOutputFile):\r
- FvFileObj = open ( FvOutputFile,'r+b')\r
-\r
- GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName)\r
- GenFdsGlobalVariable.SharpCounter = 0\r
-\r
- Buffer.write(FvFileObj.read())\r
- FvFileObj.seek(0)\r
- # PI FvHeader is 0x48 byte\r
- FvHeaderBuffer = FvFileObj.read(0x48)\r
- # FV alignment position.\r
- FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
- # FvAlignmentValue is larger than or equal to 1K\r
- if FvAlignmentValue >= 0x400:\r
- if FvAlignmentValue >= 0x10000:\r
- #The max alignment supported by FFS is 64K.\r
- self.FvAlignment = "64K"\r
+ NewFvInfo = None\r
+ if os.path.exists (FvInfoFileName):\r
+ NewFvInfo = open(FvInfoFileName, 'r').read()\r
+ if NewFvInfo is not None and NewFvInfo != OrigFvInfo:\r
+ FvChildAddr = []\r
+ AddFileObj = open(FvInfoFileName, 'r')\r
+ AddrStrings = AddFileObj.readlines()\r
+ AddrKeyFound = False\r
+ for AddrString in AddrStrings:\r
+ if AddrKeyFound:\r
+ #get base address for the inside FvImage\r
+ FvChildAddr.append (AddrString)\r
+ elif AddrString.find ("[FV_BASE_ADDRESS]") != -1:\r
+ AddrKeyFound = True\r
+ AddFileObj.close()\r
+\r
+ if FvChildAddr != []:\r
+ # Update Ffs again\r
+ for FfsFile in self.FfsList :\r
+ FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress, IsMakefile=Flag, FvName=self.UiFvName)\r
+\r
+ if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
+ FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;\r
+ #Update GenFv again\r
+ GenFdsGlobalVariable.GenerateFirmwareVolume(\r
+ FvOutputFile,\r
+ [self.InfFileName],\r
+ AddressFile=FvInfoFileName,\r
+ FfsList=FfsFileList,\r
+ ForceRebase=self.FvForceRebase,\r
+ FileSystemGuid=FFSGuid\r
+ )\r
+\r
+ #\r
+ # Write the Fv contents to Buffer\r
+ #\r
+ if os.path.isfile(FvOutputFile):\r
+ FvFileObj = open(FvOutputFile, 'rb')\r
+ GenFdsGlobalVariable.VerboseLogger("\nGenerate %s FV Successfully" % self.UiFvName)\r
+ GenFdsGlobalVariable.SharpCounter = 0\r
+\r
+ Buffer.write(FvFileObj.read())\r
+ FvFileObj.seek(0)\r
+ # PI FvHeader is 0x48 byte\r
+ FvHeaderBuffer = FvFileObj.read(0x48)\r
+ # FV alignment position.\r
+ FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
+ if FvAlignmentValue >= 0x400:\r
+ if FvAlignmentValue >= 0x100000:\r
+ if FvAlignmentValue >= 0x1000000:\r
+ #The max alignment supported by FFS is 16M.\r
+ self.FvAlignment = "16M"\r
+ else:\r
+ self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"\r
+ else:\r
+ self.FvAlignment = str(FvAlignmentValue / 0x400) + "K"\r