public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Correct the PcdDatabase Info in AutoGen
@ 2019-02-02  1:52 Feng, Bob C
  2019-02-14 15:02 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Feng, Bob C @ 2019-02-02  1:52 UTC (permalink / raw)
  To: edk2-devel; +Cc: Zhaozh1x, Bob Feng, Liming Gao

From: Zhaozh1x <zhiqiangx.zhao@intel.com>

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 <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-14 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-02  1:52 [Patch] BaseTools: Correct the PcdDatabase Info in AutoGen Feng, Bob C
2019-02-14 15:02 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox