## @file
# process FD Region 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
#
from struct import *
import StringIO
import os
from stat import *
from Common.BuildToolError import *
## generate Region
#
#
## The constructor
#
# @param self The object pointer
#
## AddToBuffer()
#
# Add region data to the Buffer
#
# @param self The object pointer
# @param Buffer The buffer generated region data will be put
# @param BaseAddress base address of region
# @param BlockSize block size of region
# @param BlockNum How many blocks in region
# @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, BlockSizeList, ErasePolarity, ImageBinDict, vtfDict = None, MacroDict = {}):
#
# Get Fv from FvDict
#
FvOffset = 0
FileName = None
else:
#
# Generate FvImage.
#
FvObj = None
if FvObj != None :
#
# Call GenFv tool
#
BlockSize = None
BlockNum = None
#
# Put the generated image into FD buffer.
#
continue
else:
#
# Add the exist Fv image into FD buffer
#
if FileName != None:
if FileLength > Size:
"Size of FV File (%s) is larger than Region Size 0x%X specified." \
% (RegionData, Size))
#
# Pad the left buffer
#
if Size > 0:
if (ErasePolarity == '1') :
PadData = 0xFF
else :
PadData = 0
#
# Get Capsule from Capsule Dict
#
else:
#
# Generate Capsule image and Put it into FD buffer
#
CapsuleObj = None
if CapsuleObj != None :
#
# Call GenFv tool to generate Capsule Image
#
CapsuleObj.CapsuleName = None
else:
EdkLogger.error("GenFds", GENFDS_ERROR, "Capsule (%s) is NOT described in FDF file!" % (RegionData))
#
# Add the capsule image into FD buffer
#
if FileLength > Size:
"Size 0x%X of Capsule File (%s) is larger than Region Size 0x%X specified." \
#
# Pad the left buffer
#
if Size > 0:
if (ErasePolarity == '1') :
PadData = 0xFF
else :
PadData = 0
#
# Add the file image into FD buffer
#
if FileLength > Size:
"Size of File (%s) is larger than Region Size 0x%X specified." \
% (RegionData, Size))
#
# Pad the left buffer
#
if Size > 0:
if (ErasePolarity == '1') :
PadData = 0xFF
else :
PadData = 0
DataSize = 0
else:
#
# Pad the left buffer
#
if Size > 0:
if (ErasePolarity == '1') :
PadData = 0xFF
else :
PadData = 0
if self.RegionType == None:
if (ErasePolarity == '1') :
PadData = 0xFF
else :
PadData = 0
AlignValue = 1
Granu = 1
Granu = 1024
else:
pass
return AlignValue
## BlockSizeOfRegion()
#
# @param BlockSizeList List of block information
# @param FvObj The object for FV
#
Start = 0
End = 0
ExpectedList = []
# region not started yet
continue
# region located in current blocks
else:
# region ended within current blocks
break
# region not ended yet
else:
# region not started in middle of current blocks
# region started in middle of current blocks
else:
if FvObj.BlockSizeList == []:
else:
# first check whether FvObj.BlockSizeList items have only "BlockSize" or "NumBlocks",
# if so, use ExpectedList
break
# make sure region size is no smaller than the summed block size in FV
Sum = 0
# check whether the BlockStatements in FV section is appropriate
ExpectedListData = ''
for Item in ExpectedList:
Index = 0
EdkLogger.error("GenFds", GENFDS_ERROR, "BlockStatements of FV %s are not align with FD's, suggested FV BlockStatement"
break;
else:
EdkLogger.error("GenFds", GENFDS_ERROR, "BlockStatements of FV %s are not align with FD's, suggested FV BlockStatement"
else:
Index += 1