From aaf8aa7b2cd6e5ee533aa622d72391226069e0c3 Mon Sep 17 00:00:00 2001 From: Yingke Liu Date: Tue, 28 Jul 2015 05:53:08 +0000 Subject: [PATCH] BaseTools: Add a keyword FvNameString in FDF The keyword with value TRUE OR FALSE is used to indicate whether the FV UI name is included in FV EXT header as a entry or not. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yingke Liu Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18090 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Source/Python/CommonDataClass/FdfClass.py | 1 + BaseTools/Source/Python/GenFds/FdfParser.py | 20 +++++++++- BaseTools/Source/Python/GenFds/Fv.py | 39 ++++++++++--------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/BaseTools/Source/Python/CommonDataClass/FdfClass.py b/BaseTools/Source/Python/CommonDataClass/FdfClass.py index f758d35ba1..96a630f4d2 100644 --- a/BaseTools/Source/Python/CommonDataClass/FdfClass.py +++ b/BaseTools/Source/Python/CommonDataClass/FdfClass.py @@ -58,6 +58,7 @@ class FvClassObject: # FvAttributeDict[attribute] = TRUE/FALSE (1/0) self.FvAttributeDict = {} self.FvNameGuid = None + self.FvNameString = None self.AprioriSectionList = [] self.FfsList = [] self.BsBaseAddress = None diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index ffc54abc84..83d3e1935e 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2068,9 +2068,12 @@ class FdfParser: if not (self.__GetBlockStatement(FvObj) or self.__GetFvBaseAddress(FvObj) or self.__GetFvForceRebase(FvObj) or self.__GetFvAlignment(FvObj) or self.__GetFvAttributes(FvObj) or self.__GetFvNameGuid(FvObj) or - self.__GetFvExtEntryStatement(FvObj)): + self.__GetFvExtEntryStatement(FvObj) or self.__GetFvNameString(FvObj)): break + if FvObj.FvNameString == 'TRUE' and not FvObj.FvNameGuid: + raise Warning("FvNameString found but FvNameGuid was not found", self.FileName, self.CurrentLineNumber) + self.__GetAprioriSection(FvObj, FvObj.DefineVarDict.copy()) self.__GetAprioriSection(FvObj, FvObj.DefineVarDict.copy()) @@ -2225,6 +2228,21 @@ class FdfParser: return True + def __GetFvNameString(self, FvObj): + + if not self.__IsKeyword( "FvNameString"): + return False + + if not self.__IsToken( "="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + + if not self.__GetNextToken() or self.__Token not in ('TRUE', 'FALSE'): + raise Warning("expected TRUE or FALSE for FvNameString", self.FileName, self.CurrentLineNumber) + + FvObj.FvNameString = self.__Token + + return True + def __GetFvExtEntryStatement(self, FvObj): if not self.__IsKeyword( "FV_EXT_ENTRY"): diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 8f341d3bf1..d770582326 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -296,25 +296,26 @@ class FV (FvClassObject): if self.FvNameGuid <> None and self.FvNameGuid <> '': TotalSize = 16 + 4 Buffer = '' - # - # 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) + 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':