[edk2] [Patch] BaseTools: Correct the PcdDatabase Info in AutoGen
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] = SizeCur
Re: [edk2] [Patch] BaseTools: Correct the PcdDatabase Info in AutoGen
Zhiju: 1. Please make sure struct PEI_PCD_DATABASE_INIT in AutoGen.h to match gPEIPcdDbInit in AutoGen.c. 2. Please make sure struct DXE_PCD_DATABASE_INIT in AutoGen.h to match gDXEPcdDbinit in AutoGen.c 3. gDXEPcdDbinit in AutoGen.c a. Keep origin style of /* LocalTokenNumberTable */ and /* VariableHead */ b. Remove /* SkuHead */. It is not in PCD data bin. c. Use the real string for the value in /* PcdTokenTable */ and /* PcdCNameTable */ Thanks Liming > -Original Message- > From: Feng, Bob C > Sent: Saturday, February 2, 2019 9:52 AM > To: edk2-devel@lists.01.org > Cc: Zhao, ZhiqiangX ; Feng, Bob C > ; Gao, Liming > Subject: [Patch] BaseTools: Correct the PcdDatabase Info in AutoGen > > 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