## @file
# process FV generation
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
#
# 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import os
import shutil
import subprocess
import StringIO
from struct import *
import Ffs
import AprioriSection
## generate FV
#
#
## The constructor
#
# @param self The object pointer
#
self.FvAddressFile = None
self.BaseAddress = None
self.InfFileName = None
self.FvAddressFileName = None
self.CapsuleName = None
self.FvBaseAddress = None
self.FvForceRebase = None
## AddToBuffer()
#
# Generate Fv and add it to the Buffer
#
# @param self The object pointer
# @param Buffer The buffer generated FV data will be put
# @param BaseAddress base address of FV
# @param BlockSize block size of FV
# @param BlockNum How many blocks in FV
# @param ErasePolarity Flash erase polarity
# @param VtfDict VTF objects
# @param MacroDict macro value pair
# @retval string Generated FV file path
#
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}) :
#
# 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:
continue
continue
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
if self.FvBaseAddress != None:
#
# First Process the Apriori section
#
FfsFileList = []
# Add Apriori file name to Inf file
FileName + \
# Process Modules in FfsList
FileName + \
#
# Call GenFv tool
#
# BUGBUG: FvOutputFile could be specified from FDF file (FV section, CreateFile statement)
if self.CreateFileName != None:
OrigFvInfo = None
[self.InfFileName],
)
NewFvInfo = None
FvChildAddr = []
for AddrString in AddrStrings:
if AddrKeyFound:
#get base address for the inside FvImage
if FvChildAddr != []:
# Update Ffs again
#Update GenFv again
[self.InfFileName],
)
#
# Write the Fv contents to Buffer
#
# PI FvHeader is 0x48 byte
# FV alignment position.
# FvAlignmentValue is larger than or equal to 1K
if FvAlignmentValue >= 0x400:
if FvAlignmentValue >= 0x10000:
#The max alignment supported by FFS is 64K.
else:
else:
# FvAlignmentValue is less than 1K
return FvOutputFile
## __InitializeInf__()
#
# Initilize the inf file to create FV
#
# @param self The object pointer
# @param BaseAddress base address of FV
# @param BlockSize block size of FV
# @param BlockNum How many blocks in FV
# @param ErasePolarity Flash erase polarity
# @param VtfDict VTF objects
#
def __InitializeInf__ (self, BaseAddress = None, BlockSize= None, BlockNum = None, ErasePloarity='1', VtfDict=None) :
#
# Create FV inf file
#
#
# Add [Options]
#
if BaseAddress != None :
BaseAddress + \
if BlockSize != None:
'0x%X' %BlockSize + \
if BlockNum != None:
' 0x%X' %BlockNum + \
else:
if self.BlockSizeList == []:
#set default block size is 1
if BlockSize[0] != None:
if BlockSize[1] != None:
if self.BsBaseAddress != None:
if self.RtBaseAddress != None:
#
# Add attribute
#
' %s' %ErasePloarity + \
if not (self.FvAttributeDict == None):
FvAttribute + \
' = ' + \
if self.FvAlignment != None:
" = TRUE" + \
#
# Generate FV extension header file
#
GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName))
Buffer = ''
# check if the path is absolute or relative
else:
FileFullPath = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.FvExtEntryData[Index]))
# check if the file path exists or not
GenFdsGlobalVariable.ErrorLogger("Error opening FV Extension Header Entry file %s." % (self.FvExtEntryData[Index]))
if Size >= 0x10000:
GenFdsGlobalVariable.ErrorLogger("The size of FV Extension Header Entry file %s exceeds 0x10000." % (self.FvExtEntryData[Index]))
if Size >= 0x10000:
GenFdsGlobalVariable.ErrorLogger("The size of FV Extension Header Entry data %s exceeds 0x10000." % (self.FvExtEntryData[Index]))
) + Buffer
#
# Generate FV extension header file if the total size is not zero
#
if TotalSize > 0:
if Changed:
#
# Add [Files]
#