def __GetOptRomParams(self): if self.OverrideAttribs == None: self.OverrideAttribs = OptionRom.OverrideAttribs() if self.OverrideAttribs.NeedCompress == None: self.OverrideAttribs.NeedCompress = self.OptRomDefs.get( 'PCI_COMPRESS') if self.OverrideAttribs.NeedCompress is not None: if self.OverrideAttribs.NeedCompress.upper() not in ('TRUE', 'FALSE'): GenFdsGlobalVariable.ErrorLogger( "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.InfFileName) self.OverrideAttribs.NeedCompress = \ self.OverrideAttribs.NeedCompress.upper() == 'TRUE' if self.OverrideAttribs.PciVendorId == None: self.OverrideAttribs.PciVendorId = self.OptRomDefs.get( 'PCI_VENDOR_ID') if self.OverrideAttribs.PciClassCode == None: self.OverrideAttribs.PciClassCode = self.OptRomDefs.get( 'PCI_CLASS_CODE') if self.OverrideAttribs.PciDeviceId == None: self.OverrideAttribs.PciDeviceId = self.OptRomDefs.get( 'PCI_DEVICE_ID') if self.OverrideAttribs.PciRevision == None: self.OverrideAttribs.PciRevision = self.OptRomDefs.get( 'PCI_REVISION')
def AddToBuffer(self, Buffer, BaseAddress=None, BlockSize=None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict={}, Flag=False): if BaseAddress == None and self.UiFvName.upper( ) + 'fv' in GenFds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] # # Check whether FV in Capsule is in FD flash region. # If yes, return error. Doesn't support FV in Capsule image is also in FD flash region. # if self.CapsuleName != None: for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] for RegionObj in FdObj.RegionList: if RegionObj.RegionType == 'FV': for RegionData in RegionObj.RegionDataList: if RegionData.endswith(".fv"): continue 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())) if not Flag: GenFdsGlobalVariable.InfLogger("\nGenerating %s FV" % self.UiFvName) GenFdsGlobalVariable.LargeFileInFvFlags.append(False) FFSGuid = None if self.FvBaseAddress != None: BaseAddress = self.FvBaseAddress if not Flag: self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict) # # First Process the Apriori section # MacroDict.update(self.DefineVarDict) GenFdsGlobalVariable.VerboseLogger('First generate Apriori file !') FfsFileList = [] for AprSection in self.AprioriSectionList: FileName = AprSection.GenFfs(self.UiFvName, MacroDict, IsMakefile=Flag) FfsFileList.append(FileName) # Add Apriori file name to Inf file if not Flag: self.FvInfFile.writelines("EFI_FILE_NAME = " + \ FileName + \ T_CHAR_LF) # Process Modules in FfsList for FfsFile in self.FfsList: if Flag: if isinstance(FfsFile, FfsFileStatement.FileStatement): continue if GenFdsGlobalVariable.EnableGenfdsMultiThread and GenFdsGlobalVariable.ModuleFile and GenFdsGlobalVariable.ModuleFile.Path.find( os.path.normpath(FfsFile.InfFileName)) == -1: continue FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress, IsMakefile=Flag, FvName=self.UiFvName) FfsFileList.append(FileName) if not Flag: self.FvInfFile.writelines("EFI_FILE_NAME = " + \ FileName + \ T_CHAR_LF) if not Flag: SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), False) self.FvInfFile.close() # # Call GenFv tool # FvOutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName) FvOutputFile = FvOutputFile + '.Fv' # BUGBUG: FvOutputFile could be specified from FDF file (FV section, CreateFile statement) if self.CreateFileName != None: FvOutputFile = self.CreateFileName if Flag: GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile return FvOutputFile FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf') if not Flag: 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, FileSystemGuid=FFSGuid) 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, IsMakefile=Flag) 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, FileSystemGuid=FFSGuid) # # Write the Fv contents to Buffer # if os.path.isfile(FvOutputFile): FvFileObj = open(FvOutputFile, 'rb') 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) if FvAlignmentValue >= 0x400: if FvAlignmentValue >= 0x100000: if FvAlignmentValue >= 0x1000000: #The max alignment supported by FFS is 16M. self.FvAlignment = "16M" else: self.FvAlignment = str( FvAlignmentValue / 0x100000) + "M" 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 GenFdsGlobalVariable.LargeFileInFvFlags.pop() else: GenFdsGlobalVariable.ErrorLogger( "Failed to generate %s FV file." % self.UiFvName) return FvOutputFile
def __InitializeInf__(self, BaseAddress=None, BlockSize=None, BlockNum=None, ErasePloarity='1', VtfDict=None): # # Create FV inf file # self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName + '.inf') self.FvInfFile = StringIO.StringIO() # # Add [Options] # self.FvInfFile.writelines("[options]" + T_CHAR_LF) if BaseAddress != None: self.FvInfFile.writelines("EFI_BASE_ADDRESS = " + \ BaseAddress + \ T_CHAR_LF) if BlockSize != None: self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \ '0x%X' %BlockSize + \ T_CHAR_LF) if BlockNum != None: self.FvInfFile.writelines("EFI_NUM_BLOCKS = " + \ ' 0x%X' %BlockNum + \ T_CHAR_LF) else: if self.BlockSizeList == []: 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: self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \ '0x%X' %BlockSize[0] + \ T_CHAR_LF) if BlockSize[1] != None: self.FvInfFile.writelines("EFI_NUM_BLOCKS = " + \ ' 0x%X' %BlockSize[1] + \ T_CHAR_LF) if self.BsBaseAddress != None: self.FvInfFile.writelines('EFI_BOOT_DRIVER_BASE_ADDRESS = ' + \ '0x%X' %self.BsBaseAddress) if self.RtBaseAddress != None: self.FvInfFile.writelines('EFI_RUNTIME_DRIVER_BASE_ADDRESS = ' + \ '0x%X' %self.RtBaseAddress) # # Add attribute # self.FvInfFile.writelines("[attributes]" + T_CHAR_LF) self.FvInfFile.writelines("EFI_ERASE_POLARITY = " + \ ' %s' %ErasePloarity + \ T_CHAR_LF) if not (self.FvAttributeDict == None): for FvAttribute in self.FvAttributeDict.keys(): if FvAttribute == "FvUsedSizeEnable": if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1'): self.UsedSizeEnable = True continue self.FvInfFile.writelines("EFI_" + \ FvAttribute + \ ' = ' + \ self.FvAttributeDict[FvAttribute] + \ T_CHAR_LF ) if self.FvAlignment != None: self.FvInfFile.writelines("EFI_FVB2_ALIGNMENT_" + \ self.FvAlignment.strip() + \ " = TRUE" + \ T_CHAR_LF) # # Generate FV extension header file # if self.FvNameGuid == None or self.FvNameGuid == '': if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable: GenFdsGlobalVariable.ErrorLogger( "FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName)) if self.FvNameGuid <> None and self.FvNameGuid <> '': TotalSize = 16 + 4 Buffer = '' if self.UsedSizeEnable: TotalSize += (4 + 4) ## define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03 #typedef struct # { # EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr; # UINT32 UsedSize; # } EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE; Buffer += pack('HHL', 8, 3, 0) 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): GenFdsGlobalVariable.ErrorLogger( "Error opening FV Extension Header Entry file %s." % (self.FvExtEntryData[Index])) FvExtFile = open(FileFullPath, 'rb') FvExtFile.seek(0, 2) Size = FvExtFile.tell() if Size >= 0x10000: GenFdsGlobalVariable.ErrorLogger( "The size of FV Extension Header Entry file %s exceeds 0x10000." % (self.FvExtEntryData[Index])) TotalSize += (Size + 4) FvExtFile.seek(0) Buffer += pack('HH', (Size + 4), int(self.FvExtEntryTypeValue[Index], 16)) Buffer += FvExtFile.read() FvExtFile.close() if self.FvExtEntryType[Index] == 'DATA': ByteList = self.FvExtEntryData[Index].split(',') Size = len(ByteList) if Size >= 0x10000: GenFdsGlobalVariable.ErrorLogger( "The size of FV Extension Header Entry data %s exceeds 0x10000." % (self.FvExtEntryData[Index])) TotalSize += (Size + 4) Buffer += pack('HH', (Size + 4), int(self.FvExtEntryTypeValue[Index], 16)) for Index1 in range(0, Size): Buffer += pack('B', int(ByteList[Index1], 16)) Guid = self.FvNameGuid.split('-') Buffer = pack('=LHHBBBBBBBBL', 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), TotalSize) + Buffer # # Generate FV extension header file if the total size is not zero # if TotalSize > 0: FvExtHeaderFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName + '.ext') FvExtHeaderFile = StringIO.StringIO() FvExtHeaderFile.write(Buffer) Changed = SaveFileOnChange(FvExtHeaderFileName, FvExtHeaderFile.getvalue(), True) FvExtHeaderFile.close() if Changed: if os.path.exists(self.InfFileName): os.remove(self.InfFileName) self.FvInfFile.writelines("EFI_FV_EXT_HEADER_FILE_NAME = " + \ FvExtHeaderFileName + \ T_CHAR_LF) # # Add [Files] # self.FvInfFile.writelines("[files]" + T_CHAR_LF) if VtfDict != None and self.UiFvName in VtfDict.keys(): self.FvInfFile.writelines("EFI_FILE_NAME = " + \ VtfDict.get(self.UiFvName) + \ T_CHAR_LF)
def GenFfs(self, Dict={}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None): if self.NameGuid is not None and self.NameGuid.startswith('PCD('): PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid) if len(PcdValue) == 0: EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ % (self.NameGuid)) if PcdValue.startswith('{'): PcdValue = GuidStructureByteArrayToGuidString(PcdValue) RegistryGuidStr = PcdValue if len(RegistryGuidStr) == 0: EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \ % (self.NameGuid)) self.NameGuid = RegistryGuidStr Str = self.NameGuid if FvName: Str += FvName OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, Str) if not os.path.exists(OutputDir): os.makedirs(OutputDir) Dict.update(self.DefineVarDict) SectionAlignments = None if self.FvName is not None: Buffer = BytesIO('') if self.FvName.upper( ) not in GenFdsGlobalVariable.FdfParser.Profile.FvDict: EdkLogger.error( "GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName)) Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get( self.FvName.upper()) FileName = Fv.AddToBuffer(Buffer) SectionFiles = [FileName] elif self.FdName is not None: if self.FdName.upper( ) not in GenFdsGlobalVariable.FdfParser.Profile.FdDict: EdkLogger.error( "GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName)) Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get( self.FdName.upper()) FileName = Fd.GenFd() SectionFiles = [FileName] elif self.FileName is not None: if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW': if isinstance(self.FileName, list) and isinstance( self.SubAlignment, list) and len(self.FileName) == len( self.SubAlignment): FileContent = '' MaxAlignIndex = 0 MaxAlignValue = 1 for Index, File in enumerate(self.FileName): try: f = open(File, 'rb') except: GenFdsGlobalVariable.ErrorLogger( "Error opening RAW file %s." % (File)) Content = f.read() f.close() AlignValue = 1 if self.SubAlignment[Index] is not None: AlignValue = GenFdsGlobalVariable.GetAlignment( self.SubAlignment[Index]) if AlignValue > MaxAlignValue: MaxAlignIndex = Index MaxAlignValue = AlignValue FileContent += Content if len(FileContent) % AlignValue != 0: Size = AlignValue - len(FileContent) % AlignValue for i in range(0, Size): FileContent += pack('B', 0xFF) if FileContent: OutputRAWFile = os.path.join( GenFdsGlobalVariable.FfsDir, self.NameGuid, self.NameGuid + '.raw') SaveFileOnChange(OutputRAWFile, FileContent, True) self.FileName = OutputRAWFile self.SubAlignment = self.SubAlignment[MaxAlignIndex] if self.Alignment and self.SubAlignment: if GenFdsGlobalVariable.GetAlignment( self.Alignment ) < GenFdsGlobalVariable.GetAlignment(self.SubAlignment): self.Alignment = self.SubAlignment elif self.SubAlignment: self.Alignment = self.SubAlignment self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro( self.FileName) #Replace $(SAPCE) with real space self.FileName = self.FileName.replace('$(SPACE)', ' ') SectionFiles = [ GenFdsGlobalVariable.MacroExtend(self.FileName, Dict) ] else: SectionFiles = [] Index = 0 SectionAlignments = [] for section in self.SectionList: Index = Index + 1 SecIndex = '%d' % Index # process the inside FvImage from FvSection or GuidSection if FvChildAddr != []: if isinstance(section, FvImageSection): section.FvAddr = FvChildAddr.pop(0) elif isinstance(section, GuidSection): section.FvAddr = FvChildAddr if FvParentAddr is not None and isinstance( section, GuidSection): section.FvParentAddr = FvParentAddr if self.KeepReloc == False: section.KeepReloc = False sectList, align = section.GenSection(OutputDir, self.NameGuid, SecIndex, self.KeyStringList, None, Dict) if sectList != []: for sect in sectList: SectionFiles.append(sect) SectionAlignments.append(align) # # Prepare the parameter # FfsFileOutput = os.path.join(OutputDir, self.NameGuid + '.ffs') GenFdsGlobalVariable.GenerateFfs(FfsFileOutput, SectionFiles, Ffs.Ffs.FdfFvFileTypeToFileType.get( self.FvFileType), self.NameGuid, Fixed=self.Fixed, CheckSum=self.CheckSum, Align=self.Alignment, SectionAlign=SectionAlignments) return FfsFileOutput
def __InitializeInf__(self, BaseAddress=None, BlockSize=None, BlockNum=None, ErasePloarity='1', VtfDict=None): # # Create FV inf file # self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName + '.inf') self.FvInfFile = StringIO.StringIO() # # Add [Options] # self.FvInfFile.writelines("[options]" + T_CHAR_LF) if BaseAddress != None: self.FvInfFile.writelines("EFI_BASE_ADDRESS = " + \ BaseAddress + \ T_CHAR_LF) if BlockSize != None: self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \ '0x%X' %BlockSize + \ T_CHAR_LF) if BlockNum != None: self.FvInfFile.writelines("EFI_NUM_BLOCKS = " + \ ' 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 = " + \ '0x%X' %BlockSize[0] + \ T_CHAR_LF) if BlockSize[1] != None: self.FvInfFile.writelines("EFI_NUM_BLOCKS = " + \ ' 0x%X' %BlockSize[1] + \ T_CHAR_LF) if self.BsBaseAddress != None: self.FvInfFile.writelines('EFI_BOOT_DRIVER_BASE_ADDRESS = ' + \ '0x%X' %self.BsBaseAddress) if self.RtBaseAddress != None: self.FvInfFile.writelines('EFI_RUNTIME_DRIVER_BASE_ADDRESS = ' + \ '0x%X' %self.RtBaseAddress) # # Add attribute # self.FvInfFile.writelines("[attributes]" + T_CHAR_LF) self.FvInfFile.writelines("EFI_ERASE_POLARITY = " + \ ' %s' %ErasePloarity + \ T_CHAR_LF) if not (self.FvAttributeDict == None): for FvAttribute in self.FvAttributeDict.keys(): self.FvInfFile.writelines("EFI_" + \ FvAttribute + \ ' = ' + \ self.FvAttributeDict[FvAttribute] + \ T_CHAR_LF ) if self.FvAlignment != None: self.FvInfFile.writelines("EFI_FVB2_ALIGNMENT_" + \ self.FvAlignment.strip() + \ " = TRUE" + \ T_CHAR_LF) # # Generate FV extension header file # if self.FvNameGuid == None or self.FvNameGuid == '': if len(self.FvExtEntryType) > 0: GenFdsGlobalVariable.ErrorLogger( "FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName)) if self.FvNameGuid <> None and self.FvNameGuid <> '': TotalSize = 16 + 4 Buffer = '' 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): GenFdsGlobalVariable.ErrorLogger( "Error opening FV Extension Header Entry file %s." % (self.FvExtEntryData[Index])) FvExtFile = open(FileFullPath, 'rb') FvExtFile.seek(0, 2) Size = FvExtFile.tell() if Size >= 0x10000: GenFdsGlobalVariable.ErrorLogger( "The size of FV Extension Header Entry file %s exceeds 0x10000." % (self.FvExtEntryData[Index])) TotalSize += (Size + 4) FvExtFile.seek(0) Buffer += pack('HH', (Size + 4), int(self.FvExtEntryTypeValue[Index], 16)) Buffer += FvExtFile.read() FvExtFile.close() if self.FvExtEntryType[Index] == 'DATA': ByteList = self.FvExtEntryData[Index].split(',') Size = len(ByteList) if Size >= 0x10000: GenFdsGlobalVariable.ErrorLogger( "The size of FV Extension Header Entry data %s exceeds 0x10000." % (self.FvExtEntryData[Index])) TotalSize += (Size + 4) Buffer += pack('HH', (Size + 4), int(self.FvExtEntryTypeValue[Index], 16)) for Index1 in range(0, Size): Buffer += pack('B', int(ByteList[Index1], 16)) Guid = self.FvNameGuid.split('-') Buffer = pack('LHHBBBBBBBBL', 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), TotalSize) + Buffer # # Generate FV extension header file if the total size is not zero # if TotalSize > 0: FvExtHeaderFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName + '.ext') FvExtHeaderFile = StringIO.StringIO() FvExtHeaderFile.write(Buffer) Changed = SaveFileOnChange(FvExtHeaderFileName, FvExtHeaderFile.getvalue(), True) FvExtHeaderFile.close() if Changed: if os.path.exists(self.InfFileName): os.remove(self.InfFileName) self.FvInfFile.writelines("EFI_FV_EXT_HEADER_FILE_NAME = " + \ FvExtHeaderFileName + \ T_CHAR_LF) # # Add [Files] # self.FvInfFile.writelines("[files]" + T_CHAR_LF) if VtfDict != None and self.UiFvName in VtfDict.keys(): self.FvInfFile.writelines("EFI_FILE_NAME = " + \ VtfDict.get(self.UiFvName) + \ T_CHAR_LF)