From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0D91C211B6C26 for ; Fri, 1 Feb 2019 17:52:07 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2019 17:52:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,550,1539673200"; d="scan'208";a="111783847" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga007.jf.intel.com with ESMTP; 01 Feb 2019 17:52:06 -0800 From: "Feng, Bob C" To: edk2-devel@lists.01.org Cc: Zhaozh1x , Bob Feng , Liming Gao Date: Sat, 2 Feb 2019 09:52:04 +0800 Message-Id: <20190202015204.5672-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Subject: [Patch] BaseTools: Correct the PcdDatabase Info in AutoGen X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Feb 2019 01:52:08 -0000 Content-Transfer-Encoding: 8bit From: Zhaozh1x PcdDriver AutoGen code shows PCD DB format for debug purpose only. But now, AutoGen code doesn't exactly match the generated PCD DB binary file. It brings the complex for Pcd driver debug. This patch is going to fix that issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 41 +++++++++++++-------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index cbf7a39dd5..2ca9001417 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -52,23 +52,32 @@ ${END} ${BEGIN} { ${EXMAPPING_TABLE_EXTOKEN}, ${EXMAPPING_TABLE_LOCAL_TOKEN}, ${EXMAPPING_TABLE_GUID_INDEX} }, ${END} }, /* LocalTokenNumberTable */ { -${BEGIN} offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE}, +${BEGIN} ${LOCAL_TOKEN_NUMBER_DB_VALUE}, /* offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE} */ ${END} }, /* GuidTable */ { ${BEGIN} ${GUID_STRUCTURE}, ${END} }, + /* StringHead */ ${BEGIN} { ${STRING_HEAD_VALUE} }, /* ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}] */ ${END} + /* PcdNameTable */ + /* TokenSpaceCNameIndex, PcdCNameIndex, TokenSpaceCNameIndex, PcdCNameIndex, ...... */ + { +${BEGIN} ${PCD_NAME_OFFSET}, +${END} + }, + /* VariableHead */ + /* StringIndex, DefaultValueOffset, GuidTableIndex, Offset, Attributes, Property */ ${BEGIN} /* ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}] */ { - ${VARIABLE_HEAD_VALUE} + ${VARIABLE_DB_VALUE} }, ${END} /* SkuHead */ { ${BEGIN} offsetof (${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE}, /* */ @@ -76,10 +85,20 @@ ${END} ${END} }, /* StringTable */ ${BEGIN} ${STRING_TABLE_VALUE}, /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */ ${END} + /* PcdTokenTable */ + { +${BEGIN} ${PCD_TOKENSPACE}, /* PCD_TOKENSPACE */ +${END} + }, + /* PcdCNameTable */ + { +${BEGIN} ${PCD_CNAME}, /* PCD_CNAME */ +${END} + }, /* SizeTable */ { ${BEGIN} ${SIZE_TABLE_MAXIMUM_LENGTH}, ${SIZE_TABLE_CURRENT_LENGTH}, /* ${SIZE_TABLE_CNAME}_${SIZE_TABLE_GUID} */ ${END} }, @@ -1221,18 +1240,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): if VariableGuid not in GuidList: GuidList.append(VariableGuid) Dict['GUID_STRUCTURE'].append(VariableGuidStructure) VariableHeadGuidIndex = GuidList.index(VariableGuid) - if "PCD_TYPE_STRING" in Pcd.TokenTypeList: - VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s), %dU, %sU' % - (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid, - VariableHeadGuidIndex, Sku.VariableOffset)) - else: - VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s), %dU, %sU' % - (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid, SkuIdIndex, - VariableHeadGuidIndex, Sku.VariableOffset)) Dict['VARDEF_CNAME_'+Pcd.DatumType].append(CName) Dict['VARDEF_GUID_'+Pcd.DatumType].append(TokenSpaceGuid) Dict['VARDEF_SKUID_'+Pcd.DatumType].append(SkuIdIndex) if "PCD_TYPE_STRING" in Pcd.TokenTypeList: Dict['VARDEF_VALUE_' + Pcd.DatumType].append("%s_%s[%d]" % (Pcd.TokenCName, TokenSpaceGuid, SkuIdIndex)) @@ -1571,13 +1582,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): if AvailableSkuNumber not in Dict['SKUID_VALUE']: Dict['SKUID_VALUE'].append(AvailableSkuNumber) Dict['SKUID_VALUE'][0] = len(Dict['SKUID_VALUE']) - 1 AutoGenH.Append(gPcdDatabaseAutoGenH.Replace(Dict)) - if NumberOfLocalTokens == 0: - AutoGenC.Append(gEmptyPcdDatabaseAutoGenC.Replace(Dict)) - else: + if NumberOfLocalTokens != 0: # # Update Size Table to the right order, it should be same with LocalTokenNumberTable # SizeCNameTempList = [] SizeGuidTempList = [] @@ -1603,15 +1612,17 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): Dict['SIZE_TABLE_CNAME'][Count] = SizeCNameTempList[Count] Dict['SIZE_TABLE_GUID'][Count] = SizeGuidTempList[Count] Dict['SIZE_TABLE_CURRENT_LENGTH'][Count] = SizeCurLenTempList[Count] Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count] = SizeMaxLenTempList[Count] - AutoGenC.Append(gPcdDatabaseAutoGenC.Replace(Dict)) - # print Phase Buffer = BuildExDataBase(Dict) + if NumberOfLocalTokens == 0: + AutoGenC.Append(gEmptyPcdDatabaseAutoGenC.Replace(Dict)) + else: + AutoGenC.Append(gPcdDatabaseAutoGenC.Replace(Dict)) return AutoGenH, AutoGenC, Buffer, VarCheckTab def GetOrderedDynamicPcdList(DynamicPcdList, PcdTokenNumberList): ReorderedDyPcdList = [None for i in range(len(DynamicPcdList))] for Pcd in DynamicPcdList: -- 2.20.1.windows.1