+ 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
+ else:\r
+ # FvAlignmentValue is less than 1K\r
+ self.FvAlignment = str (FvAlignmentValue)\r
+ FvFileObj.close()\r
+ GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile\r
+ GenFdsGlobalVariable.LargeFileInFvFlags.pop()\r
+ else:\r
+ GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName)\r