From 2b8a6c44e0deb508f79804dd5ff7156bc7e25493 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Fri, 22 Dec 2017 20:04:04 +0800 Subject: [PATCH] BaseTools: PcdDataBase Optimization for multiple SkuIds https://bugzilla.tianocore.org/show_bug.cgi?id=546 BaseTools will generate the optimized PCD database to save the image size at build time for multiple SKUs. The optimized PCD database layout will be like below, the PCD database will be composed of the full default SKU data (PCD_DATABASE_INIT) and the non-default SKU delta data(PCD_DATABASE_SKU_DELTA). PCD driver will build HOB to store the full default SKU data, and patch HOB data based on non-default SKU delta data for the SKU set by SetSku(), it can save memory resource at boot time. // // PCD database layout: // +---------------------------------+ // | PCD_DATABASE_INIT (DEFAULT SKU) | // +---------------------------------+ // | PCD_DATABASE_SKU_DELTA (SKU A) | // +---------------------------------+ // | PCD_DATABASE_SKU_DELTA (SKU B) | // +---------------------------------+ // | ...... | // +---------------------------------+ // BaseTools, PCD database and driver updates are needed for this proposal. For single SKU (default) case, this proposal is expected to have no impact. For multi-SKU case, PCD database format will be changed. So, PcdDataBase Version is also updated from 6 to 7. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Feng Bob C Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 14 +- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 227 +++++++++--------- BaseTools/Source/Python/AutoGen/GenVar.py | 27 ++- .../Source/Python/Common/BuildToolError.py | 1 + BaseTools/Source/Python/Common/Misc.py | 5 +- BaseTools/Source/Python/Common/VpdInfoFile.py | 5 +- .../Source/Python/Workspace/DscBuildData.py | 143 +++++++---- .../Python/Workspace/WorkspaceCommon.py | 4 +- 8 files changed, 254 insertions(+), 172 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index be6fecd9f3..5d6cce0dbb 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1607,11 +1607,14 @@ class PlatformAutoGen(AutoGen): if PcdNvStoreDfBuffer: var_info = self.CollectVariables(self._DynamicPcdList) default_skuobj = PcdNvStoreDfBuffer.SkuInfoList.get("DEFAULT") - default_skuobj.DefaultValue = var_info.dump() + vardump = var_info.dump() + if vardump: + default_skuobj.DefaultValue = vardump + PcdNvStoreDfBuffer.DefaultValue = vardump if default_skuobj: PcdNvStoreDfBuffer.SkuInfoList.clear() PcdNvStoreDfBuffer.SkuInfoList['DEFAULT'] = default_skuobj - PcdNvStoreDfBuffer.MaxDatumSize = len(default_skuobj.DefaultValue.split(",")) + PcdNvStoreDfBuffer.MaxDatumSize = str(len(default_skuobj.DefaultValue.split(","))) PlatformPcds = self._PlatformPcds.keys() PlatformPcds.sort() @@ -1789,6 +1792,13 @@ class PlatformAutoGen(AutoGen): self._DynamicPcdList.extend(UnicodePcdArray) self._DynamicPcdList.extend(HiiPcdArray) self._DynamicPcdList.extend(OtherPcdArray) + allskuset = [(SkuName,Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName,Sku) in pcd.SkuInfoList.items()] + for pcd in self._DynamicPcdList: + if len(pcd.SkuInfoList) == 1: + for (SkuName,SkuId) in allskuset: + if type(SkuId) in (str,unicode) and eval(SkuId) == 0 or SkuId == 0: + continue + pcd.SkuInfoList[SkuName] = pcd.SkuInfoList['DEFAULT'] self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList ## Return the platform build data object diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 3d9bfd7666..e3ab027501 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -18,8 +18,10 @@ from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY from Common.VariableAttributes import VariableAttributes +import copy +from struct import unpack -DATABASE_VERSION = 6 +DATABASE_VERSION = 7 gPcdDatabaseAutoGenC = TemplateString(""" // @@ -114,7 +116,6 @@ gPcdDatabaseAutoGenH = TemplateString(""" #define ${PHASE}_EXMAPPING_TABLE_SIZE ${EXMAPPING_TABLE_SIZE} #define ${PHASE}_EX_TOKEN_NUMBER ${EX_TOKEN_NUMBER} #define ${PHASE}_SIZE_TABLE_SIZE ${SIZE_TABLE_SIZE} -#define ${PHASE}_SKU_HEAD_SIZE ${SKU_HEAD_SIZE} #define ${PHASE}_GUID_TABLE_EMPTY ${GUID_TABLE_EMPTY} #define ${PHASE}_STRING_TABLE_EMPTY ${STRING_TABLE_EMPTY} #define ${PHASE}_SKUID_TABLE_EMPTY ${SKUID_TABLE_EMPTY} @@ -139,9 +140,6 @@ ${END} ${BEGIN} STRING_HEAD ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}]; ${END} ${BEGIN} VARIABLE_HEAD ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}]; -${END} -${BEGIN} SKU_HEAD SkuHead[${PHASE}_SKU_HEAD_SIZE]; -${END} ${BEGIN} UINT8 StringTable${STRING_TABLE_INDEX}[${STRING_TABLE_LENGTH}]; /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */ ${END} SIZE_INFO SizeTable[${PHASE}_SIZE_TABLE_SIZE]; @@ -653,7 +651,7 @@ def GetTokenTypeValue(TokenType): "PCD_TYPE_DATA":(0x0 << 28), "PCD_TYPE_HII":(0x8 << 28), "PCD_TYPE_VPD":(0x4 << 28), - "PCD_TYPE_SKU_ENABLED":(0x2 << 28), +# "PCD_TYPE_SKU_ENABLED":(0x2 << 28), "PCD_TYPE_STRING":(0x1 << 28), "PCD_DATUM_TYPE_SHIFT":24, @@ -698,9 +696,7 @@ def BuildExDataBase(Dict): VariableTable = Dict['VARIABLE_DB_VALUE'] DbVariableTable = DbVariableTableItemList(20, RawDataList = VariableTable) NumberOfSkuEnabledPcd = GetIntegerValue(Dict['SKU_HEAD_SIZE']) - Dict['SKUHEAD_TABLE_VALUE'] = [(0,0) for i in xrange(NumberOfSkuEnabledPcd)] - SkuTable = Dict['SKUHEAD_TABLE_VALUE'] # Generated later - DbSkuTable = DbSkuHeadTableItemList(8, RawDataList = SkuTable) + Dict['STRING_TABLE_DB_VALUE'] = [StringArrayToList(x) for x in Dict['STRING_TABLE_VALUE']] StringTableValue = Dict['STRING_TABLE_DB_VALUE'] @@ -738,8 +734,8 @@ def BuildExDataBase(Dict): DbVardefValueBoolean = DbItemList(1, RawDataList = VardefValueBoolean) SkuidValue = Dict['SKUID_VALUE'] DbSkuidValue = DbItemList(8, RawDataList = SkuidValue) - SkuIndexValue = Dict['SKU_INDEX_VALUE'] - DbSkuIndexValue = DbItemList(8,RawDataList = SkuIndexValue) + + # Unit Db Items UnInitValueUint64 = Dict['UNINIT_GUID_DECL_UINT64'] @@ -754,24 +750,24 @@ def BuildExDataBase(Dict): DbUnInitValueBoolean = DbItemList(1, RawDataList = UnInitValueBoolean) PcdTokenNumberMap = Dict['PCD_ORDER_TOKEN_NUMBER_MAP'] - DbNameTotle = ["SkuidValue", "SkuIndexValue", "InitValueUint64", "VardefValueUint64", "InitValueUint32", "VardefValueUint32", "VpdHeadValue", "ExMapTable", - "LocalTokenNumberTable", "GuidTable", "StringHeadValue", "PcdNameOffsetTable","VariableTable","SkuTable", "StringTableLen", "PcdTokenTable", "PcdCNameTable", + DbNameTotle = ["SkuidValue", "InitValueUint64", "VardefValueUint64", "InitValueUint32", "VardefValueUint32", "VpdHeadValue", "ExMapTable", + "LocalTokenNumberTable", "GuidTable", "StringHeadValue", "PcdNameOffsetTable","VariableTable", "StringTableLen", "PcdTokenTable", "PcdCNameTable", "SizeTableValue", "InitValueUint16", "VardefValueUint16", "InitValueUint8", "VardefValueUint8", "InitValueBoolean", "VardefValueBoolean", "UnInitValueUint64", "UnInitValueUint32", "UnInitValueUint16", "UnInitValueUint8", "UnInitValueBoolean"] - DbTotal = [SkuidValue, SkuIndexValue, InitValueUint64, VardefValueUint64, InitValueUint32, VardefValueUint32, VpdHeadValue, ExMapTable, - LocalTokenNumberTable, GuidTable, StringHeadValue, PcdNameOffsetTable,VariableTable,SkuTable, StringTableLen, PcdTokenTable,PcdCNameTable, + DbTotal = [SkuidValue, InitValueUint64, VardefValueUint64, InitValueUint32, VardefValueUint32, VpdHeadValue, ExMapTable, + LocalTokenNumberTable, GuidTable, StringHeadValue, PcdNameOffsetTable,VariableTable, StringTableLen, PcdTokenTable,PcdCNameTable, SizeTableValue, InitValueUint16, VardefValueUint16, InitValueUint8, VardefValueUint8, InitValueBoolean, VardefValueBoolean, UnInitValueUint64, UnInitValueUint32, UnInitValueUint16, UnInitValueUint8, UnInitValueBoolean] - DbItemTotal = [DbSkuidValue, DbSkuIndexValue, DbInitValueUint64, DbVardefValueUint64, DbInitValueUint32, DbVardefValueUint32, DbVpdHeadValue, DbExMapTable, - DbLocalTokenNumberTable, DbGuidTable, DbStringHeadValue, DbPcdNameOffsetTable,DbVariableTable,DbSkuTable, DbStringTableLen, DbPcdTokenTable, DbPcdCNameTable, + DbItemTotal = [DbSkuidValue, DbInitValueUint64, DbVardefValueUint64, DbInitValueUint32, DbVardefValueUint32, DbVpdHeadValue, DbExMapTable, + DbLocalTokenNumberTable, DbGuidTable, DbStringHeadValue, DbPcdNameOffsetTable,DbVariableTable, DbStringTableLen, DbPcdTokenTable, DbPcdCNameTable, DbSizeTableValue, DbInitValueUint16, DbVardefValueUint16, DbInitValueUint8, DbVardefValueUint8, DbInitValueBoolean, DbVardefValueBoolean, DbUnInitValueUint64, DbUnInitValueUint32, DbUnInitValueUint16, DbUnInitValueUint8, DbUnInitValueBoolean] # VardefValueBoolean is the last table in the init table items InitTableNum = DbNameTotle.index("VardefValueBoolean") + 1 # The FixedHeader length of the PCD_DATABASE_INIT, from Signature to Pad - FixedHeaderLen = 72 + FixedHeaderLen = 76 # Get offset of SkuId table in the database SkuIdTableOffset = FixedHeaderLen @@ -782,26 +778,8 @@ def BuildExDataBase(Dict): # Get offset of SkuValue table in the database - SkuTableOffset = FixedHeaderLen - for DbIndex in xrange(len(DbTotal)): - if DbTotal[DbIndex] is SkuTable: - break - elif DbItemTotal[DbIndex] is DbSkuIndexValue: - if DbItemTotal[DbIndex].RawDataList: - Count = 0 - for item in DbItemTotal[DbIndex].RawDataList: - Count += len(item) - SkuTableOffset += DbItemTotal[DbIndex].ItemSize * Count - continue - SkuTableOffset += DbItemTotal[DbIndex].GetListSize() # Fix up the LocalTokenNumberTable, SkuHeader table - SkuHeaderIndex = 0 - if len(Dict['SKU_INDEX_VALUE']) > 0: - SkuIndexIndexTable = [(0) for i in xrange(len(Dict['SKU_INDEX_VALUE']))] - SkuIndexIndexTable[0] = 0 #Dict['SKU_INDEX_VALUE'][0][0] - for i in range(1,len(Dict['SKU_INDEX_VALUE'])): - SkuIndexIndexTable[i] = SkuIndexIndexTable[i-1]+Dict['SKU_INDEX_VALUE'][i-1][0] + 1 for (LocalTokenNumberTableIndex, (Offset, Table)) in enumerate(LocalTokenNumberTable): DbIndex = 0 DbOffset = FixedHeaderLen @@ -809,13 +787,6 @@ def BuildExDataBase(Dict): if DbTotal[DbIndex] is Table: DbOffset += DbItemTotal[DbIndex].GetInterOffset(Offset) break - elif DbItemTotal[DbIndex] is DbSkuIndexValue: - if DbItemTotal[DbIndex].RawDataList: - Count = 0 - for item in DbItemTotal[DbIndex].RawDataList: - Count += len(item) - DbOffset += DbItemTotal[DbIndex].ItemSize * Count - continue DbOffset += DbItemTotal[DbIndex].GetListSize() if DbIndex + 1 == InitTableNum: if DbOffset % 8: @@ -828,16 +799,8 @@ def BuildExDataBase(Dict): LocalTokenNumberTable[LocalTokenNumberTableIndex] = DbOffset|int(TokenTypeValue) # if PCD_TYPE_SKU_ENABLED, then we need to fix up the SkuTable - SkuIndexTabalOffset = SkuIdTableOffset + len(Dict['SKUID_VALUE']) * 8 - if (TokenTypeValue & (0x2 << 28)): - SkuTable[SkuHeaderIndex] = (DbOffset|int(TokenTypeValue & ~(0x2<<28)), SkuIndexTabalOffset + SkuIndexIndexTable[PcdTokenNumberMap[LocalTokenNumberTableIndex]] * 8) - LocalTokenNumberTable[LocalTokenNumberTableIndex] = (SkuTableOffset + SkuHeaderIndex * 8) | int(TokenTypeValue) - SkuHeaderIndex += 1 - if SkuHeaderIndex == 0: - SkuHeaderIndex = 1 - assert(SkuHeaderIndex == NumberOfSkuEnabledPcd) # resolve variable table offset for VariableEntries in VariableTable: @@ -850,13 +813,6 @@ def BuildExDataBase(Dict): if DbTotal[DbIndex] is VariableRefTable: DbOffset += DbItemTotal[DbIndex].GetInterOffset(VariableOffset) break - elif DbItemTotal[DbIndex] is DbSkuIndexValue: - if DbItemTotal[DbIndex].RawDataList: - Count = 0 - for item in DbItemTotal[DbIndex].RawDataList: - Count += len(item) - DbOffset += DbItemTotal[DbIndex].ItemSize * Count - continue DbOffset += DbItemTotal[DbIndex].GetListSize() if DbIndex + 1 == InitTableNum: if DbOffset % 8: @@ -888,13 +844,7 @@ def BuildExDataBase(Dict): SkuIdTableOffset = DbTotalLength elif DbItemTotal[DbIndex] is DbPcdNameOffsetTable: DbPcdNameOffset = DbTotalLength - elif DbItemTotal[DbIndex] is DbSkuIndexValue: - if DbItemTotal[DbIndex].RawDataList: - Count = 0 - for item in DbItemTotal[DbIndex].RawDataList: - Count += len(item) - DbTotalLength += DbItemTotal[DbIndex].ItemSize * Count - continue + DbTotalLength += DbItemTotal[DbIndex].GetListSize() if not Dict['PCD_INFO_FLAG']: @@ -936,6 +886,9 @@ def BuildExDataBase(Dict): Buffer += b b = pack('=Q', SystemSkuId) + Buffer += b + b = pack('=L', 0) + Buffer += b b = pack('=L', UninitDataBaseSize) @@ -1003,7 +956,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): EdkLogger.error("build", AUTOGEN_ERROR, "Not supported PcdIsDriver type:%s" % Info.PcdIsDriver, ExtraData="[%s]" % str(Info)) - AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI') + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = NewCreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI') AutoGenH.Append(AdditionalAutoGenH.String) Phase = gPcdPhaseMap[Info.PcdIsDriver] @@ -1011,7 +964,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): AutoGenC.Append(AdditionalAutoGenC.String) if Phase == 'DXE': - AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase) + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = NewCreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase) AutoGenH.Append(AdditionalAutoGenH.String) AutoGenC.Append(AdditionalAutoGenC.String) @@ -1022,14 +975,83 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): DbFile = StringIO() DbFile.write(PcdDbBuffer) Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True) +def CreatePcdDataBase(PcdDBData): + delta = {} + basedata = {} + if not PcdDBData: + return "" + for skuname,skuid in PcdDBData: + if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[("DEFAULT","0")][1]): + EdkLogger.ERROR("The size of each sku in one pcd are not same") + for skuname,skuid in PcdDBData: + if skuname == "DEFAULT": + continue + delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[("DEFAULT","0")][1][index]] + basedata[(skuname,skuid)] = [(index,PcdDBData[("DEFAULT","0")][1][index],hex(PcdDBData[("DEFAULT","0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[("DEFAULT","0")][1][index]] + databasebuff = PcdDBData[("DEFAULT","0")][0] + for skuname,skuid in delta: + databasebuff += pack('=H', int(skuid)) + databasebuff += pack('=H', 0) + databasebuff += pack('=L', 8+4*len(delta[(skuname,skuid)])) + for item in delta[(skuname,skuid)]: + databasebuff += pack("=L",item[0]) + databasebuff = databasebuff[:-1] + pack("=B",item[1]) + totallen = len(databasebuff) + totallenbuff = pack("=L",totallen) + newbuffer = databasebuff[:32] + for i in range(4): + newbuffer += totallenbuff[i] + for i in range(36,totallen): + newbuffer += databasebuff[i] + + return newbuffer +def CreateVarCheckBin(VarCheckTab): + return VarCheckTab[('DEFAULT',"0")] +def CreateAutoGen(PcdDriverAutoGenData): + autogenC = TemplateString() + for skuname,skuid in PcdDriverAutoGenData: + autogenC.Append("//SKUID: %s" % skuname) + autogenC.Append(PcdDriverAutoGenData[(skuname,skuid)][1].String) + return (PcdDriverAutoGenData[(skuname,skuid)][0],autogenC) +def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): + def prune_sku(pcd,skuname): + new_pcd = copy.deepcopy(pcd) + new_pcd.SkuInfoList = {skuname:pcd.SkuInfoList[skuname]} + return new_pcd + DynamicPcds = Platform.DynamicPcdList + DynamicPcdSet_Sku = {(SkuName,skuobj.SkuId):[] for pcd in DynamicPcds for (SkuName,skuobj) in pcd.SkuInfoList.items() } + for skuname,skuid in DynamicPcdSet_Sku: + DynamicPcdSet_Sku[(skuname,skuid)] = [prune_sku(pcd,skuname) for pcd in DynamicPcds] + PcdDBData = {} + PcdDriverAutoGenData = {} + VarCheckTableData = {} + if DynamicPcdSet_Sku: + for skuname,skuid in DynamicPcdSet_Sku: + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer,VarCheckTab = CreatePcdDatabasePhaseSpecificAutoGen (Platform,DynamicPcdSet_Sku[(skuname,skuid)], Phase) + final_data = () + for item in PcdDbBuffer: + final_data += unpack("B",item) + PcdDBData[(skuname,skuid)] = (PcdDbBuffer, final_data) + PcdDriverAutoGenData[(skuname,skuid)] = (AdditionalAutoGenH, AdditionalAutoGenC) + VarCheckTableData[(skuname,skuid)] = VarCheckTab + if Platform.Platform.VarCheckFlag: + dest = os.path.join(Platform.BuildDir, 'FV') + VarCheckTable = CreateVarCheckBin(VarCheckTableData) + VarCheckTable.dump(dest, Phase) + AdditionalAutoGenH, AdditionalAutoGenC = CreateAutoGen(PcdDriverAutoGenData) + else: + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer,VarCheckTab = CreatePcdDatabasePhaseSpecificAutoGen (Platform,{}, Phase) + + PcdDbBuffer = CreatePcdDataBase(PcdDBData) + return AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer ## Create PCD database in DXE or PEI phase # # @param Platform The platform object # @retval tuple Two TemplateString objects for C code and header file, # respectively # -def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): +def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): AutoGenC = TemplateString() AutoGenH = TemplateString() @@ -1106,8 +1128,6 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'] = [] Dict['VARIABLE_DB_VALUE'] = [] - Dict['SKUHEAD_TABLE_VALUE'] = [] - Dict['SKU_INDEX_VALUE'] = [] Dict['PCD_TOKENSPACE'] = [] Dict['PCD_CNAME'] = [] @@ -1132,7 +1152,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): GuidList = [] VarCheckTab = VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER() i = 0 - ReorderedDynPcdList = GetOrderedDynamicPcdList(Platform.DynamicPcdList, Platform.PcdTokenNumber) + ReorderedDynPcdList = GetOrderedDynamicPcdList(DynamicPcdList, Platform.PcdTokenNumber) for item in ReorderedDynPcdList: if item.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: item.DatumType = "VOID*" @@ -1193,11 +1213,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): Pcd.TokenTypeList = ['PCD_DATUM_TYPE_' + Pcd.DatumType] if len(Pcd.SkuInfoList) > 1: - Pcd.TokenTypeList += ['PCD_TYPE_SKU_ENABLED'] +# Pcd.TokenTypeList += ['PCD_TYPE_SKU_ENABLED'] NumberOfSkuEnabledPcd += 1 - SkuIndexTableTmp = [] - SkuIndexTableTmp.append(0) SkuIdIndex = 1 VariableHeadList = [] for SkuName in Pcd.SkuInfoList: @@ -1206,10 +1224,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): if SkuId == None or SkuId == '': continue - if (SkuId + 'U') not in Dict['SKUID_VALUE']: - Dict['SKUID_VALUE'].append(SkuId + 'U') - SkuIndexTableTmp.append(SkuId+'U') SkuIdIndex += 1 if len(Sku.VariableName) > 0: @@ -1240,32 +1255,28 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): Pcd.InitString = 'INIT' # Store all variable names of one HII PCD under different SKU to stringTable # and calculate the VariableHeadStringIndex - if SkuIdIndex - 2 == 0: - for SkuName2 in Pcd.SkuInfoList: - SkuInfo = Pcd.SkuInfoList[SkuName2] - if SkuInfo.SkuId == None or SkuInfo.SkuId == '': - continue - VariableNameStructure = StringToArray(SkuInfo.VariableName) - if VariableNameStructure not in Dict['STRING_TABLE_VALUE']: - Dict['STRING_TABLE_CNAME'].append(CName) - Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid) - if StringTableIndex == 0: - Dict['STRING_TABLE_INDEX'].append('') - else: - Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex) - VarNameSize = len(VariableNameStructure.replace(',',' ').split()) - Dict['STRING_TABLE_LENGTH'].append(VarNameSize ) - Dict['STRING_TABLE_VALUE'].append(VariableNameStructure) - StringHeadOffsetList.append(str(StringTableSize) + 'U') - VarStringDbOffsetList = [] - VarStringDbOffsetList.append(StringTableSize) - Dict['STRING_DB_VALUE'].append(VarStringDbOffsetList) - StringTableIndex += 1 - StringTableSize += len(VariableNameStructure.replace(',',' ').split()) - VariableHeadStringIndex = 0 - for Index in range(Dict['STRING_TABLE_VALUE'].index(VariableNameStructure)): - VariableHeadStringIndex += Dict['STRING_TABLE_LENGTH'][Index] - VariableHeadList.append(VariableHeadStringIndex) + + VariableNameStructure = StringToArray(Sku.VariableName) + if VariableNameStructure not in Dict['STRING_TABLE_VALUE']: + Dict['STRING_TABLE_CNAME'].append(CName) + Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid) + if StringTableIndex == 0: + Dict['STRING_TABLE_INDEX'].append('') + else: + Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex) + VarNameSize = len(VariableNameStructure.replace(',',' ').split()) + Dict['STRING_TABLE_LENGTH'].append(VarNameSize ) + Dict['STRING_TABLE_VALUE'].append(VariableNameStructure) + StringHeadOffsetList.append(str(StringTableSize) + 'U') + VarStringDbOffsetList = [] + VarStringDbOffsetList.append(StringTableSize) + Dict['STRING_DB_VALUE'].append(VarStringDbOffsetList) + StringTableIndex += 1 + StringTableSize += len(VariableNameStructure.replace(',',' ').split()) + VariableHeadStringIndex = 0 + for Index in range(Dict['STRING_TABLE_VALUE'].index(VariableNameStructure)): + VariableHeadStringIndex += Dict['STRING_TABLE_LENGTH'][Index] + VariableHeadList.append(VariableHeadStringIndex) VariableHeadStringIndex = VariableHeadList[SkuIdIndex - 2] # store VariableGuid to GuidTable and get the VariableHeadGuidIndex @@ -1411,9 +1422,6 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): Dict['SIZE_TABLE_CURRENT_LENGTH'].append(VoidStarTypeCurrSize) - SkuIndexTableTmp[0] = len(SkuIndexTableTmp) - 1 - if len(Pcd.SkuInfoList) > 1: - Dict['SKU_INDEX_VALUE'].append(SkuIndexTableTmp) if 'PCD_TYPE_HII' in Pcd.TokenTypeList: Dict['VARIABLE_HEAD_CNAME_DECL'].append(CName) @@ -1666,11 +1674,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): AutoGenC.Append(gPcdDatabaseAutoGenC.Replace(Dict)) - if Platform.Platform.VarCheckFlag: - dest = os.path.join(Platform.BuildDir, 'FV') - VarCheckTab.dump(dest, Phase) + +# print Phase Buffer = BuildExDataBase(Dict) - return AutoGenH, AutoGenC, Buffer + return AutoGenH, AutoGenC, Buffer,VarCheckTab def GetOrderedDynamicPcdList(DynamicPcdList, PcdTokenNumberList): ReorderedDyPcdList = [None for i in range(len(DynamicPcdList))] diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 98e1a4cdae..7ee39796e3 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -115,6 +115,9 @@ class VariableMgr(object): var_data = self.process_variable_data() + if not var_data: + return [] + pcds_default_data = var_data.get(("DEFAULT","STANDARD")) NvStoreDataBuffer = "" var_data_offset = collections.OrderedDict() @@ -129,6 +132,11 @@ class VariableMgr(object): else: var_attr_value = 0x07 +# print "default var_name_buffer" +# print self.format_data(var_name_buffer) +# print "default var_buffer" +# print self.format_data(default_data) + DataBuffer = self.AlignData(var_name_buffer + default_data) data_size = len(DataBuffer) @@ -143,6 +151,8 @@ class VariableMgr(object): nv_default_part = self.AlignData(self.PACK_DEFAULT_DATA(0, 0, self.unpack_data(variable_storage_header_buffer+NvStoreDataBuffer))) +# print "default whole data \n",self.format_data(nv_default_part) + data_delta_structure_buffer = "" for skuname,defaultstore in var_data: if (skuname,defaultstore) == ("DEFAULT","STANDARD"): @@ -156,6 +166,9 @@ class VariableMgr(object): delta_data_set.extend(delta_data) data_delta_structure_buffer += self.AlignData(self.PACK_DELTA_DATA(skuname,defaultstore,delta_data_set)) +# print "delta data" +# print delta_data_set +# print self.format_data(self.AlignData(self.PACK_DELTA_DATA(skuname,defaultstore,delta_data_set))) return self.format_data(nv_default_part + data_delta_structure_buffer) @@ -171,6 +184,8 @@ class VariableMgr(object): return final_data def calculate_delta(self, default, theother): +# print "default data \n", default +# print "other data \n",theother if len(default) - len(theother) != 0: EdkLogger.error("build", FORMAT_INVALID, 'The variable data length is not the same for the same PCD.') data_delta = [] @@ -182,11 +197,13 @@ class VariableMgr(object): def dump(self): default_var_bin = self.new_process_varinfo() - value_str = "{" - default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin] - value_str += ",".join(default_var_bin_strip) - value_str += "}" - return value_str + if default_var_bin: + value_str = "{" + default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin] + value_str += ",".join(default_var_bin_strip) + value_str += "}" + return value_str + return "" def PACK_VARIABLE_STORE_HEADER(self,size): #Signature: gEfiVariableGuid diff --git a/BaseTools/Source/Python/Common/BuildToolError.py b/BaseTools/Source/Python/Common/BuildToolError.py index d3e5f9f167..27779c5d98 100644 --- a/BaseTools/Source/Python/Common/BuildToolError.py +++ b/BaseTools/Source/Python/Common/BuildToolError.py @@ -85,6 +85,7 @@ WARNING_AS_ERROR = 0xF006 MIGRATION_ERROR = 0xF010 PCD_VALIDATION_INFO_ERROR = 0xF011 PCD_VARIABLE_ATTRIBUTES_ERROR = 0xF012 +PCD_VARIABLE_INFO_ERROR = 0xF016 PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR = 0xF013 PCD_STRUCTURE_PCD_INVALID_FIELD_ERROR = 0xF014 PCD_STRUCTURE_PCD_ERROR = 0xF015 diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 8b9eed8a09..2ff8516469 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2111,7 +2111,10 @@ class DefaultStore(): def GetMin(self,DefaultSIdList): if not DefaultSIdList: return "STANDARD" - minid = min({storeid for storeid, storename in self.DefaultStores.values() if storename in DefaultSIdList} ) + storeidset = {storeid for storeid, storename in self.DefaultStores.values() if storename in DefaultSIdList} + if not storeidset: + return "" + minid = min(storeidset ) for sid,name in self.DefaultStores.values(): if sid == minid: return name diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index d45fb4cf03..56161efe6a 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -102,8 +102,9 @@ class VpdInfoFile: if Vpd.MaxDatumSize == None or Vpd.MaxDatumSize == "": Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType] else: - EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, - "Invalid DatumType %s for VPD PCD %s.%s" % (Vpd.DatumType, Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) + if Vpd.MaxDatumSize <= 0: + EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, + "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) if Vpd not in self._VpdArray.keys(): # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 5b5dbb64f9..d2114fedcd 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -598,7 +598,7 @@ class DscBuildData(PlatformBuildClassObject): if not IsValidWord(Record[1]): EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'", File=self.MetaFile, Line=Record[-1]) - self._SkuIds[Record[1]] = (Record[0],Record[1],Record[2]) + self._SkuIds[Record[1].upper()] = (Record[0], Record[1].upper(), Record[2].upper()) if 'DEFAULT' not in self._SkuIds: self._SkuIds['DEFAULT'] = ("0","DEFAULT","DEFAULT") if 'COMMON' not in self._SkuIds: @@ -617,7 +617,7 @@ class DscBuildData(PlatformBuildClassObject): if Record[1] in [None, '']: EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name', File=self.MetaFile, Line=Record[-1]) - self.DefaultStores[Record[1]] = (self.ToInt(Record[0]),Record[1]) + self.DefaultStores[Record[1].upper()] = (self.ToInt(Record[0]),Record[1].upper()) if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores: self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0,TAB_DEFAULT_STORES_DEFAULT) return self.DefaultStores @@ -794,7 +794,7 @@ class DscBuildData(PlatformBuildClassObject): def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo): if self._DecPcds == None: - self._DecPcds = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain) + FdfInfList = [] if GlobalData.gFdfParser: FdfInfList = GlobalData.gFdfParser.Profile.InfList @@ -806,13 +806,11 @@ class DscBuildData(PlatformBuildClassObject): continue ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain] PkgSet.update(ModuleData.Packages) - DecPcds = {} - for Pkg in PkgSet: - for Pcd in Pkg.Pcds: - DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd] - self._DecPcds.update(DecPcds) - if (PcdCName, TokenSpaceGuid) not in self._DecPcds and "." in TokenSpaceGuid and (TokenSpaceGuid.split(".")[1], TokenSpaceGuid.split(".")[0]) not in self._DecPcds: + self._DecPcds = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet) + + + if (PcdCName, TokenSpaceGuid) not in self._DecPcds: EdkLogger.error('build', PARSER_ERROR, "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (TokenSpaceGuid, PcdCName, self._Arch), File=self.MetaFile, Line=LineNo) @@ -861,6 +859,18 @@ class DscBuildData(PlatformBuildClassObject): pcd = Pcds[pcdname] Pcds[pcdname].SkuInfoList = {skuid:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku} return Pcds + def CompleteHiiPcdsDefaultStores(self,Pcds): + HiiPcd = [Pcds[pcd] for pcd in Pcds if Pcds[pcd].Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]] + DefaultStoreMgr = DefaultStore(self.DefaultStores) + for pcd in HiiPcd: + for skuid in pcd.SkuInfoList: + skuobj = pcd.SkuInfoList.get(skuid) + if "STANDARD" not in skuobj.DefaultStoreDict: + PcdDefaultStoreSet = set([defaultstorename for defaultstorename in skuobj.DefaultStoreDict]) + mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) + skuobj.DefaultStoreDict['STANDARD'] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename]) + return Pcds + ## Retrieve all PCD settings in platform def _GetPcds(self): if self._Pcds == None: @@ -877,6 +887,7 @@ class DscBuildData(PlatformBuildClassObject): self._Pcds = self.CompletePcdValues(self._Pcds) self._Pcds = self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, self._Pcds) + self._Pcds = self.CompleteHiiPcdsDefaultStores(self._Pcds) self._Pcds = self._FilterPcdBySkuUsage(self._Pcds) return self._Pcds @@ -938,28 +949,6 @@ class DscBuildData(PlatformBuildClassObject): return structure_pcd_data - def CompleteStructurePcdValue(self,pcdset): - skuset = set([item[3] for item in pcdset]) - pcddatamap = {(item[0],item[1],item[2],item[3]):item for item in pcdset} - FieldSet = {} - for item in pcdset: - if (item[0],item[1]) not in FieldSet: - FieldSet[(item[0],item[1])] = set() - FieldSet[(item[0],item[1])].add(item[2]) - completeset = [] - for tockenspacename,pcdname, in FieldSet: - for field in FieldSet[(tockenspacename,pcdname)]: - for skuid in skuset: - nextskuid = skuid - while (tockenspacename,pcdname,field,nextskuid) not in pcddatamap: - nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) - if nextskuid == "DEFAULT": - break - if (tockenspacename,pcdname,field,nextskuid) not in pcddatamap: - continue - item = pcddatamap[tockenspacename,pcdname,field,nextskuid] - completeset.append((tockenspacename,pcdname,field,skuid, item[4],item[5], item[6])) - return completeset def UpdateStructuredPcds(self, TypeList, AllPcds): Pcds = AllPcds DefaultStoreMgr = DefaultStore(self.DefaultStores) @@ -969,16 +958,19 @@ class DscBuildData(PlatformBuildClassObject): S_PcdSet = [] # Find out all possible PCD candidates for self._Arch RecordList = [] + for Type in TypeList: RecordList.extend(self._RawData[Type, self._Arch]) for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, default_store, Dummy4,Dummy5 in RecordList: + SkuName = SkuName.upper() + default_store = default_store.upper() + SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName if SkuName not in SkuIds: continue - SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName + if SkuName in SkuIds and "." in TokenSpaceGuid: S_PcdSet.append(( TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0])) - S_PcdSet = self.CompleteStructurePcdValue(S_PcdSet) # handle pcd value override StrPcdSet = self.GetStructurePcdInfo(S_PcdSet) @@ -997,6 +989,10 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_data[3] in SkuIds: str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str + else: + EdkLogger.error('build', PARSER_ERROR, + "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch), + File=self.MetaFile,Line = StrPcdSet[str_pcd][0][5]) # Add the Structure PCD that only defined in DEC, don't have override in DSC file for Pcd in self._DecPcds: if type (self._DecPcds[Pcd]) is StructurePcd: @@ -1022,22 +1018,33 @@ class DscBuildData(PlatformBuildClassObject): if stru_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: for skuid in SkuIds: nextskuid = skuid + NoDefault = False if skuid not in stru_pcd.SkuOverrideValues: while nextskuid not in stru_pcd.SkuOverrideValues: + if nextskuid == "DEFAULT": + NoDefault = True + break nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) stru_pcd.SkuOverrideValues[skuid] = {} - PcdDefaultStoreSet = set([defaultstorename for defaultstorename in stru_pcd.SkuOverrideValues[skuid]]) + if NoDefault: + continue + PcdDefaultStoreSet = set([defaultstorename for defaultstorename in stru_pcd.SkuOverrideValues[nextskuid]]) mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) + for defaultstoreid in DefaultStores: if defaultstoreid not in stru_pcd.SkuOverrideValues[skuid]: - stru_pcd.SkuOverrideValues[skuid][defaultstoreid] = stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename] + stru_pcd.SkuOverrideValues[skuid][defaultstoreid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename]) for skuid in SkuIds: if skuid in stru_pcd.SkuOverrideValues: continue nextskuid = self.SkuIdMgr.GetNextSkuId(skuid) + NoDefault = False while nextskuid not in stru_pcd.SkuOverrideValues: + if nextskuid == "DEFAULT": + NoDefault = True + break nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) - stru_pcd.SkuOverrideValues[skuid] = stru_pcd.SkuOverrideValues[nextskuid] + stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores}) Str_Pcd_Values = self.GenerateByteArrayValue(S_pcd_set) if Str_Pcd_Values: for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values: @@ -1070,8 +1077,7 @@ class DscBuildData(PlatformBuildClassObject): str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].HiiDefaultValue = str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].DefaultStoreDict[mindefaultstorename] for str_pcd_obj in S_pcd_set.values(): - if not str_pcd_obj.OverrideValues: - continue + str_pcd_obj.MaxDatumSize = self.GetStructurePcdMaxSize(str_pcd_obj) Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCName] = str_pcd_obj @@ -1089,7 +1095,7 @@ class DscBuildData(PlatformBuildClassObject): # tdict is a special dict kind of type, used for selecting correct # PCD settings for certain ARCH # - + AvailableSkuIdSet = copy.copy(self.SkuIds) PcdDict = tdict(True, 3) PcdSet = set() @@ -1097,6 +1103,11 @@ class DscBuildData(PlatformBuildClassObject): RecordList = self._RawData[Type, self._Arch] PcdValueDict = sdict() for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList: + SkuName = SkuName.upper() + SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName + if SkuName not in AvailableSkuIdSet: + EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, + File=self.MetaFile, Line=Dummy5) if SkuName in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'): if "." not in TokenSpaceGuid: PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy4)) @@ -1516,8 +1527,11 @@ class DscBuildData(PlatformBuildClassObject): for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList: + SkuName = SkuName.upper() + SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName if SkuName not in AvailableSkuIdSet: - continue + EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, + File=self.MetaFile, Line=Dummy5) if "." not in TokenSpaceGuid: PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy4)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting @@ -1590,7 +1604,7 @@ class DscBuildData(PlatformBuildClassObject): def CompletePcdValues(self,PcdSet): Pcds = {} DefaultStoreObj = DefaultStore(self._GetDefaultStores()) - SkuIds = set([skuid for pcdobj in PcdSet.values() for skuid in pcdobj.SkuInfoList.keys()]) + SkuIds = set([(skuid,skuobj.SkuId) for pcdobj in PcdSet.values() for skuid,skuobj in pcdobj.SkuInfoList.items()]) DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()]) for PcdCName, TokenSpaceGuid in PcdSet: PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)] @@ -1609,14 +1623,16 @@ class DscBuildData(PlatformBuildClassObject): mindefaultstorename = DefaultStoreObj.GetMin(set([defaultstorename for defaultstorename in skuobj.DefaultStoreDict])) for defaultstorename in DefaultStores: if defaultstorename not in skuobj.DefaultStoreDict: - skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename] + skuobj.DefaultStoreDict[defaultstorename] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename]) skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename] - for skuid in SkuIds: - if skuid not in PcdObj.SkuInfoList: - nextskuid = self.SkuIdMgr.GetNextSkuId(skuid) + for skuname,skuid in SkuIds: + if skuname not in PcdObj.SkuInfoList: + nextskuid = self.SkuIdMgr.GetNextSkuId(skuname) while nextskuid not in PcdObj.SkuInfoList: nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) - PcdObj.SkuInfoList[skuid] = PcdObj.SkuInfoList[nextskuid] + PcdObj.SkuInfoList[skuname] = copy.deepcopy(PcdObj.SkuInfoList[nextskuid]) + PcdObj.SkuInfoList[skuname].SkuId = skuid + PcdObj.SkuInfoList[skuname].SkuIdName = skuname if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: PcdObj.DefaultValue = PcdObj.SkuInfoList.values()[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList["DEFAULT"].HiiDefaultValue Pcds[PcdCName, TokenSpaceGuid]= PcdObj @@ -1641,12 +1657,20 @@ class DscBuildData(PlatformBuildClassObject): RecordList = self._RawData[Type, self._Arch] # Find out all possible PCD candidates for self._Arch AvailableSkuIdSet = copy.copy(self.SkuIds) + DefaultStoresDefine = self._GetDefaultStores() for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, DefaultStore, Dummy4,Dummy5 in RecordList: + SkuName = SkuName.upper() + SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName + DefaultStore = DefaultStore.upper() if DefaultStore == "COMMON": DefaultStore = "STANDARD" if SkuName not in AvailableSkuIdSet: - continue + EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, + File=self.MetaFile, Line=Dummy5) + if DefaultStore not in DefaultStoresDefine: + EdkLogger.error('build', PARAMETER_INVALID, 'DefaultStores %s is not defined in [DefaultStores] section' % DefaultStore, + File=self.MetaFile, Line=Dummy5) if "." not in TokenSpaceGuid: PcdSet.add((PcdCName, TokenSpaceGuid, SkuName,DefaultStore, Dummy4)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid,DefaultStore] = Setting @@ -1729,7 +1753,7 @@ class DscBuildData(PlatformBuildClassObject): sku.HiiDefaultValue = pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys(): valuefromDec = pcdDecObject.DefaultValue - SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec) + SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec}) pcd.SkuInfoList['DEFAULT'] = SkuInfo elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON'] @@ -1747,7 +1771,7 @@ class DscBuildData(PlatformBuildClassObject): else: MaxSize = 0 if pcdDecObject.DatumType == 'VOID*': - for (skuname, skuobj) in pcd.SkuInfoList.items(): + for (_, skuobj) in pcd.SkuInfoList.items(): datalen = 0 if skuobj.HiiDefaultValue.startswith("L"): datalen = (len(skuobj.HiiDefaultValue) - 3 + 1) * 2 @@ -1758,9 +1782,23 @@ class DscBuildData(PlatformBuildClassObject): if datalen > MaxSize: MaxSize = datalen pcd.MaxDatumSize = str(MaxSize) + rt, invalidhii = self.CheckVariableNameAssignment(Pcds) + if not rt: + invalidpcd = ",".join(invalidhii) + EdkLogger.error('build', PCD_VARIABLE_INFO_ERROR, Message='The same HII PCD must map to the same EFI variable for all SKUs', File=self.MetaFile, ExtraData=invalidpcd) return Pcds - + def CheckVariableNameAssignment(self,Pcds): + invalidhii = [] + for pcdname in Pcds: + pcd = Pcds[pcdname] + varnameset = set([sku.VariableName for (skuid,sku) in pcd.SkuInfoList.items()]) + if len(varnameset) > 1: + invalidhii.append(".".join((pcdname[1],pcdname[0]))) + if len(invalidhii): + return False,invalidhii + else: + return True, [] ## Retrieve dynamic VPD PCD settings # # @param Type PCD type @@ -1783,8 +1821,11 @@ class DscBuildData(PlatformBuildClassObject): AvailableSkuIdSet = copy.copy(self.SkuIds) for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList: + SkuName = SkuName.upper() + SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName if SkuName not in AvailableSkuIdSet: - continue + EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, + File=self.MetaFile, Line=Dummy5) if "." not in TokenSpaceGuid: PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy4)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index 67aa530526..c289b9d2b5 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -44,8 +44,10 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain): # @param Toolchain: Current toolchain # @retval: A dictionary contains instances of PcdClassObject with key (PcdCName, TokenSpaceGuid) # -def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain): +def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain,additionalPkgs): PkgList = GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain) + PkgList = set(PkgList) + PkgList |= additionalPkgs DecPcds = {} for Pkg in PkgList: for Pcd in Pkg.Pcds: