Fix a bug in autogen c code for the calculation of offset for Dynamic Ex PCD entries.
authorqhuang8 <qhuang8@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 23 Jan 2009 07:21:29 +0000 (07:21 +0000)
committerqhuang8 <qhuang8@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 23 Jan 2009 07:21:29 +0000 (07:21 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1465 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/AutoGen/GenC.py

index a34b01d..bf64315 100644 (file)
@@ -1341,7 +1341,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
             Dict['EXMAPPING_TABLE_EXTOKEN'].append(Pcd.TokenValue)
             if Phase == 'DXE':
                 GeneratedTokenNumber += NumberOfPeiLocalTokens
-            Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append(GeneratedTokenNumber)
+            #
+            # Per, PCD architecture specification, PCD Token Number is 1 based and 0 is defined as invalid token number.
+            # For each EX type PCD, a PCD Token Number is assigned. When the
+            # PCD Driver/PEIM map EX_GUID and EX_TOKEN_NUMBER to the PCD Token Number,
+            # the non-EX Protocol/PPI interface can be called to get/set the value. This assumption is made by
+            # Pcd Driver/PEIM in MdeModulePkg.
+            # Therefore, 1 is added to GeneratedTokenNumber to generate a PCD Token Number before being inserted
+            # to the EXMAPPING_TABLE. 
+            #
+            Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append(GeneratedTokenNumber + 1)
             Dict['EXMAPPING_TABLE_GUID_INDEX'].append(GuidList.index(TokenSpaceGuid))
 
     if GuidList != []: