summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds/Fv.py
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-11-09 11:47:35 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-11-09 11:47:35 +0000
commitb303ea726e1c8ed240dad2bce54821318567eab3 (patch)
tree355db6226949afd1bfcc87d69e09a320ea9b7bb7 /BaseTools/Source/Python/GenFds/Fv.py
parent4c913fe619bd00861270cb0866feb34bcdc1592e (diff)
downloadedk2-platforms-b303ea726e1c8ed240dad2bce54821318567eab3.tar.xz
Sync tool code to BuildTools project r1739.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9397 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/GenFds/Fv.py')
-rw-r--r--BaseTools/Source/Python/GenFds/Fv.py83
1 files changed, 73 insertions, 10 deletions
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 23ec58200b..a9ff26e597 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -19,6 +19,7 @@ import os
import shutil
import subprocess
import StringIO
+from struct import *
import Ffs
import AprioriSection
@@ -70,8 +71,8 @@ class FV (FvClassObject):
# 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 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:
@@ -215,19 +216,81 @@ class FV (FvClassObject):
self.FvAlignment.strip() + \
" = TRUE" + \
T_CHAR_LF)
-
- if self.FvNameGuid != None:
- self.FvInfFile.writelines("EFI_FVNAME_GUID" + \
- " = %s" % self.FvNameGuid + \
- T_CHAR_LF)
+
#
- # Add [Files]
+ # 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 = open (FvExtHeaderFileName,'wb')
+ FvExtHeaderFile.write(Buffer)
+ FvExtHeaderFile.close()
+ 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)
-
-