]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg and MdeModulePkg Pcd: Implement PCD Driver for External PCD Database and SKU...
authorBob C Feng <bob.c.feng@intel.com>
Mon, 18 Nov 2013 07:45:49 +0000 (07:45 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 18 Nov 2013 07:45:49 +0000 (07:45 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bob C Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14857 6f19259b-4bc3-4df7-8a09-765794883524

16 files changed:
MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/Universal/PCD/Dxe/Pcd.c
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
MdeModulePkg/Universal/PCD/Dxe/Service.c
MdeModulePkg/Universal/PCD/Dxe/Service.h
MdeModulePkg/Universal/PCD/Pei/Pcd.c
MdeModulePkg/Universal/PCD/Pei/Pcd.inf
MdeModulePkg/Universal/PCD/Pei/Service.c
MdeModulePkg/Universal/PCD/Pei/Service.h
MdePkg/Include/Library/PcdLib.h
MdePkg/Include/Ppi/Pcd.h
MdePkg/Include/Ppi/PiPcd.h
MdePkg/Include/Protocol/Pcd.h
MdePkg/Library/DxePcdLib/DxePcdLib.c
MdePkg/Library/PeiPcdLib/PeiPcdLib.c

diff --git a/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h b/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h
new file mode 100644 (file)
index 0000000..22c0d95
--- /dev/null
@@ -0,0 +1,147 @@
+/** @file\r
+  Guid for Pcd DataBase Signature.\r
+\r
+Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution.  \r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.                                            \r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PCD_DATABASE_SIGNATURE_GUID_H_\r
+#define _PCD_DATABASE_SIGNATURE_GUID_H_\r
+\r
+#define PCD_DATA_BASE_SIGNATURE_GUID \\r
+{ 0x3c7d193c, 0x682c, 0x4c14, { 0xa6, 0x8f, 0x55, 0x2d, 0xea, 0x4f, 0x43, 0x7e } }\r
+\r
+extern EFI_GUID gPcdDataBaseSignatureGuid;\r
+\r
+//\r
+// Common definitions\r
+//\r
+typedef UINT8 SKU_ID;\r
+\r
+#define PCD_TYPE_SHIFT        28\r
+\r
+#define PCD_TYPE_DATA         (0x0U << PCD_TYPE_SHIFT)\r
+#define PCD_TYPE_HII          (0x8U << PCD_TYPE_SHIFT)\r
+#define PCD_TYPE_VPD          (0x4U << PCD_TYPE_SHIFT)\r
+#define PCD_TYPE_SKU_ENABLED  (0x2U << PCD_TYPE_SHIFT)\r
+#define PCD_TYPE_STRING       (0x1U << PCD_TYPE_SHIFT)\r
+\r
+#define PCD_TYPE_ALL_SET      (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)\r
+\r
+#define PCD_DATUM_TYPE_SHIFT  24\r
+\r
+#define PCD_DATUM_TYPE_POINTER  (0x0U << PCD_DATUM_TYPE_SHIFT)\r
+#define PCD_DATUM_TYPE_UINT8    (0x1U << PCD_DATUM_TYPE_SHIFT)\r
+#define PCD_DATUM_TYPE_UINT16   (0x2U << PCD_DATUM_TYPE_SHIFT)\r
+#define PCD_DATUM_TYPE_UINT32   (0x4U << PCD_DATUM_TYPE_SHIFT)\r
+#define PCD_DATUM_TYPE_UINT64   (0x8U << PCD_DATUM_TYPE_SHIFT)\r
+\r
+#define PCD_DATUM_TYPE_ALL_SET  (PCD_DATUM_TYPE_POINTER | \\r
+                                 PCD_DATUM_TYPE_UINT8   | \\r
+                                 PCD_DATUM_TYPE_UINT16  | \\r
+                                 PCD_DATUM_TYPE_UINT32  | \\r
+                                 PCD_DATUM_TYPE_UINT64)\r
+\r
+#define PCD_DATUM_TYPE_SHIFT2 20\r
+\r
+#define PCD_DATUM_TYPE_UINT8_BOOLEAN (0x1U << PCD_DATUM_TYPE_SHIFT2)\r
+\r
+#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET | PCD_DATUM_TYPE_UINT8_BOOLEAN))\r
+\r
+typedef struct  {\r
+  UINT32  ExTokenNumber;\r
+  UINT16  TokenNumber;          // Token Number for Dynamic-Ex PCD.\r
+  UINT16  ExGuidIndex;          // Index of GuidTable in units of GUID.\r
+} DYNAMICEX_MAPPING;\r
+\r
+typedef struct {\r
+  UINT32  SkuDataStartOffset;   // Offset(with TYPE info) from the PCD_DB.\r
+  UINT32  SkuIdTableOffset;     // Offset from the PCD_DB.\r
+} SKU_HEAD;\r
+\r
+typedef struct {\r
+  UINT32  StringIndex;          // Offset in String Table in units of UINT8.\r
+  UINT32  DefaultValueOffset;   // Offset of the Default Value.\r
+  UINT16  GuidTableIndex;       // Offset in Guid Table in units of GUID.\r
+  UINT16  Offset;               // Offset in Variable.\r
+} VARIABLE_HEAD;\r
+\r
+typedef struct {\r
+  UINT32  Offset;\r
+} VPD_HEAD;\r
+\r
+typedef UINT32 STRING_HEAD;\r
+\r
+typedef UINT16 SIZE_INFO;\r
+\r
+typedef struct {\r
+  UINT32  TokenSpaceCNameIndex; // Offset in String Table in units of UINT8.\r
+  UINT32  PcdCNameIndex;        // Offset in String Table in units of UINT8.\r
+} PCD_NAME_INDEX;\r
+\r
+typedef UINT32 TABLE_OFFSET;\r
+\r
+typedef struct {\r
+    GUID                  Signature;            // PcdDataBaseGuid.\r
+    UINT32                BuildVersion;\r
+    UINT32                Length;\r
+    UINT32                UninitDataBaseSize;   // Total size for PCD those default value with 0.\r
+    TABLE_OFFSET          LocalTokenNumberTableOffset;\r
+    TABLE_OFFSET          ExMapTableOffset;\r
+    TABLE_OFFSET          GuidTableOffset;\r
+    TABLE_OFFSET          StringTableOffset;\r
+    TABLE_OFFSET          SizeTableOffset;\r
+    TABLE_OFFSET          SkuIdTableOffset;\r
+    TABLE_OFFSET          PcdNameTableOffset;\r
+    UINT16                LocalTokenCount;      // LOCAL_TOKEN_NUMBER for all.\r
+    UINT16                ExTokenCount;         // EX_TOKEN_NUMBER for DynamicEx.\r
+    UINT16                GuidTableCount;       // The Number of Guid in GuidTable.\r
+    SKU_ID                SystemSkuId;          // Current SkuId value.\r
+    UINT8                 Pad;                  // Pad bytes to satisfy the alignment.\r
+\r
+    //\r
+    // Default initialized external PCD database binary structure\r
+    //\r
+    // Padding is needed to keep necessary alignment\r
+    //\r
+    //UINT64                         ValueUint64[];\r
+    //UINT32                         ValueUint32[];\r
+    //VPD_HEAD                       VpdHead[];               // VPD Offset\r
+    //DYNAMICEX_MAPPING              ExMapTable[];            // DynamicEx PCD mapped to LocalIndex in LocalTokenNumberTable. It can be accessed by the ExMapTableOffset.\r
+    //UINT32                         LocalTokenNumberTable[]; // Offset | DataType | PCD Type. It can be accessed by LocalTokenNumberTableOffset.\r
+    //GUID                           GuidTable[];             // GUID for DynamicEx and HII PCD variable Guid. It can be accessed by the GuidTableOffset.\r
+    //STRING_HEAD                    StringHead[];            // String PCD \r
+    //PCD_NAME_INDEX                 PcdNameTable[];          // PCD name index info. It can be accessed by the PcdNameTableOffset.\r
+    //VARIABLE_HEAD                  VariableHead[];          // HII PCD\r
+    //SKU_HEAD                       SkuHead[];               // Store SKU info for each PCD with SKU enable.\r
+    //UINT8                          StringTable[];           // String for String PCD value and HII PCD Variable Name. It can be accessed by StringTableOffset.        \r
+    //SIZE_INFO                      SizeTable[];             // MaxSize and CurSize for String PCD. It can be accessed by SizeTableOffset.\r
+    //UINT16                         ValueUint16[];\r
+    //UINT8                          ValueUint8[];\r
+    //BOOLEAN                        ValueBoolean[];\r
+    //UINT8                          SkuIdTable[];            // SkuIds system supports.\r
+    //UINT8                          SkuIndexTable[];         // SkuIds for each PCD with SKU enable.\r
+\r
+} PCD_DATABASE_INIT;\r
+\r
+//\r
+// PEI and DXE Pcd driver use the same PCD database\r
+//\r
+typedef PCD_DATABASE_INIT  PEI_PCD_DATABASE;\r
+typedef PCD_DATABASE_INIT  DXE_PCD_DATABASE;\r
+\r
+\r
+typedef struct {\r
+  PEI_PCD_DATABASE  *PeiDb;\r
+  DXE_PCD_DATABASE  *DxeDb;\r
+} PCD_DATABASE;\r
+\r
+\r
+#endif\r
index fc9f9ccd9946695f728465140ea49158ae5be249..b627eb101c2851396a8a36fa873772c4d930b904 100644 (file)
   #  Include/Guid/PcdDataBaseHobGuid.h\r
   gPcdDataBaseHobGuid            = { 0xEA296D92, 0x0B69, 0x423C, { 0x8C, 0x28, 0x33, 0xB4, 0xE0, 0xA9, 0x12, 0x68 }}\r
 \r
   #  Include/Guid/PcdDataBaseHobGuid.h\r
   gPcdDataBaseHobGuid            = { 0xEA296D92, 0x0B69, 0x423C, { 0x8C, 0x28, 0x33, 0xB4, 0xE0, 0xA9, 0x12, 0x68 }}\r
 \r
+  ## Guid for PCD DataBase signature.\r
+  # Include/Guid/PcdDataBaseSignatureGuid.h\r
+  gPcdDataBaseSignatureGuid = { 0x3c7d193c, 0x682c, 0x4c14, { 0xa6, 0x8f, 0x55, 0x2d, 0xea, 0x4f, 0x43, 0x7e }}\r
+\r
   ## Guid for EDKII implementation GUIDed opcodes\r
   #  Include/Guid/MdeModuleHii.h\r
   gEfiIfrTianoGuid      = { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }}\r
   ## Guid for EDKII implementation GUIDed opcodes\r
   #  Include/Guid/MdeModuleHii.h\r
   gEfiIfrTianoGuid      = { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }}\r
index 3cd805a88df3aee37ef1c1af202bbff048e4b872..04fcd64306c32c6e8818821b36c15606e5d5efbc 100644 (file)
@@ -3,7 +3,7 @@
   produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in\r
   PI 1.2 Vol3.\r
 \r
   produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in\r
   PI 1.2 Vol3.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -16,13 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "Service.h"\r
 \r
 \r
 #include "Service.h"\r
 \r
-//\r
-// Just pre-allocate a memory buffer that is big enough to\r
-// host all distinct TokenSpace guid in both\r
-// PEI ExMap and DXE ExMap.\r
-//\r
-EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };\r
-\r
 ///\r
 /// PCD database lock.\r
 ///\r
 ///\r
 /// PCD database lock.\r
 ///\r
@@ -170,7 +163,7 @@ DxePcdSetSku (
   IN  UINTN         SkuId\r
   )\r
 {\r
   IN  UINTN         SkuId\r
   )\r
 {\r
-  mPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;\r
+  mPcdDatabase.PeiDb->SystemSkuId = (SKU_ID) SkuId;\r
   \r
   return;\r
 }\r
   \r
   return;\r
 }\r
@@ -336,18 +329,18 @@ DxePcdGetSize (
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);\r
+  ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1);\r
 \r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
 \r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  IsPeiDb = (BOOLEAN) (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
+  IsPeiDb = (BOOLEAN) (TokenNumber + 1 < mPeiLocalTokenCount + 1);\r
   \r
   TokenNumber = IsPeiDb ? TokenNumber : \r
   \r
   TokenNumber = IsPeiDb ? TokenNumber : \r
-                          (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);\r
+                          (TokenNumber - mPeiLocalTokenCount);\r
 \r
 \r
-  LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable \r
-                                  : mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r
+  LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) \r
+                                  : (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);\r
 \r
   Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
 \r
 \r
   Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
 \r
@@ -971,10 +964,8 @@ DxeUnRegisterCallBackOnSet (
   @param[in, out] TokenNumber \r
                           A pointer to the PCD token number to use to find the subsequent token number.  \r
 \r
   @param[in, out] TokenNumber \r
                           A pointer to the PCD token number to use to find the subsequent token number.  \r
 \r
-  @retval EFI_SUCCESS   The PCD service retrieved the next valid token number. Or the input token number \r
-                        is already the last valid token number in the PCD database. \r
-                        In the later case, *TokenNumber is updated with the value of 0.\r
-  @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r
+  @retval EFI_SUCCESS   The PCD service has retrieved the next valid token number.\r
+  @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -989,8 +980,8 @@ DxePcdGetNextToken (
   BOOLEAN             DxeExMapTableEmpty;\r
 \r
   Status = EFI_NOT_FOUND;\r
   BOOLEAN             DxeExMapTableEmpty;\r
 \r
   Status = EFI_NOT_FOUND;\r
-  PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r
-  DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;\r
+  PeiExMapTableEmpty = mPeiExMapTableEmpty;\r
+  DxeExMapTableEmpty = mDxeExMapTableEmpty;\r
 \r
   //\r
   // Scan the local token space\r
 \r
   //\r
   // Scan the local token space\r
@@ -999,27 +990,32 @@ DxePcdGetNextToken (
     // EBC compiler is very choosy. It may report warning about comparison\r
     // between UINTN and 0 . So we add 1 in each size of the \r
     // comparison.\r
     // EBC compiler is very choosy. It may report warning about comparison\r
     // between UINTN and 0 . So we add 1 in each size of the \r
     // comparison.\r
-    if (((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) && (*TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1)) ||\r
-        ((*TokenNumber + 1 > (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1)))) {\r
-        return EFI_NOT_FOUND;\r
+    if (((*TokenNumber + 1 > mPeiNexTokenCount + 1) && (*TokenNumber + 1 <= mPeiLocalTokenCount + 1)) ||\r
+        ((*TokenNumber + 1 > (mPeiLocalTokenCount + mDxeNexTokenCount + 1)))) {\r
+      return EFI_NOT_FOUND;\r
     }\r
     \r
     (*TokenNumber)++;\r
     }\r
     \r
     (*TokenNumber)++;\r
-    if ((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) &&\r
-        (*TokenNumber <= PEI_LOCAL_TOKEN_NUMBER)) {\r
+    if ((*TokenNumber + 1 > mPeiNexTokenCount + 1) &&\r
+        (*TokenNumber + 1 <= mPeiLocalTokenCount + 1)) {\r
       //\r
       // The first Non-Ex type Token Number for DXE PCD \r
       //\r
       // The first Non-Ex type Token Number for DXE PCD \r
-      // database is PEI_LOCAL_TOKEN_NUMBER\r
+      // database is mPeiLocalTokenCount + 1\r
       //\r
       //\r
-      *TokenNumber = PEI_LOCAL_TOKEN_NUMBER;\r
-    } else if (*TokenNumber + 1 > DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER + 1) {\r
+      if (mDxeNexTokenCount > 0) {\r
+        *TokenNumber = mPeiLocalTokenCount + 1;\r
+      } else {\r
+        *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
+        return EFI_NOT_FOUND;\r
+      }\r
+    } else if (*TokenNumber + 1 > mDxeNexTokenCount + mPeiLocalTokenCount + 1) {\r
       *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
       *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
+      return EFI_NOT_FOUND;\r
     }\r
     return EFI_SUCCESS;\r
   }\r
 \r
   if (PeiExMapTableEmpty && DxeExMapTableEmpty) {\r
     }\r
     return EFI_SUCCESS;\r
   }\r
 \r
   if (PeiExMapTableEmpty && DxeExMapTableEmpty) {\r
-    *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
     return EFI_NOT_FOUND;\r
   }\r
 \r
@@ -1027,10 +1023,10 @@ DxePcdGetNextToken (
     Status = ExGetNextTokeNumber (\r
                         Guid,\r
                         TokenNumber,\r
     Status = ExGetNextTokeNumber (\r
                         Guid,\r
                         TokenNumber,\r
-                        mPcdDatabase->PeiDb.Init.GuidTable,\r
-                        sizeof(mPcdDatabase->PeiDb.Init.GuidTable),\r
-                        mPcdDatabase->PeiDb.Init.ExMapTable,\r
-                        sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)\r
+                        (EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset),\r
+                        mPeiGuidTableSize,\r
+                        (DYNAMICEX_MAPPING *)((UINT8 *) mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset),\r
+                        mPeiExMapppingTableSize\r
                         );\r
   }\r
 \r
                         );\r
   }\r
 \r
@@ -1042,10 +1038,10 @@ DxePcdGetNextToken (
     Status = ExGetNextTokeNumber (\r
                         Guid,\r
                         TokenNumber,\r
     Status = ExGetNextTokeNumber (\r
                         Guid,\r
                         TokenNumber,\r
-                        mPcdDatabase->DxeDb.Init.GuidTable,\r
-                        sizeof(mPcdDatabase->DxeDb.Init.GuidTable),\r
-                        mPcdDatabase->DxeDb.Init.ExMapTable,\r
-                        sizeof(mPcdDatabase->DxeDb.Init.ExMapTable)\r
+                        (EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset),\r
+                        mDxeGuidTableSize,\r
+                        (DYNAMICEX_MAPPING *)((UINT8 *) mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset),\r
+                        mDxeExMapppingTableSize\r
                         );\r
   }\r
 \r
                         );\r
   }\r
 \r
@@ -1055,7 +1051,7 @@ DxePcdGetNextToken (
 /**\r
   Get all token space guid table which is different with given token space guid.\r
 \r
 /**\r
   Get all token space guid table which is different with given token space guid.\r
 \r
-  @param ExMapTableSize  The size of guid table\r
+  @param ExMapTableSize  The size of ExMapTable in item\r
   @param ExMapTable      Token space guid table that want to be scaned.\r
   @param GuidTable       Guid table\r
 \r
   @param ExMapTable      Token space guid table that want to be scaned.\r
   @param GuidTable       Guid table\r
 \r
@@ -1072,8 +1068,9 @@ GetDistinctTokenSpace (
   EFI_GUID  **DistinctTokenSpace;\r
   UINTN     OldGuidIndex;\r
   UINTN     TsIdx;\r
   EFI_GUID  **DistinctTokenSpace;\r
   UINTN     OldGuidIndex;\r
   UINTN     TsIdx;\r
+  UINTN     TempTsIdx;\r
   UINTN     Idx;\r
   UINTN     Idx;\r
-\r
+  BOOLEAN   Match;\r
 \r
   DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));\r
   ASSERT (DistinctTokenSpace != NULL);\r
 \r
   DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));\r
   ASSERT (DistinctTokenSpace != NULL);\r
@@ -1082,8 +1079,18 @@ GetDistinctTokenSpace (
   OldGuidIndex = ExMapTable[0].ExGuidIndex;\r
   DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];\r
   for (Idx = 1; Idx < *ExMapTableSize; Idx++) {\r
   OldGuidIndex = ExMapTable[0].ExGuidIndex;\r
   DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];\r
   for (Idx = 1; Idx < *ExMapTableSize; Idx++) {\r
-    if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {\r
-      OldGuidIndex = ExMapTable[Idx].ExGuidIndex;\r
+    Match = FALSE;\r
+    OldGuidIndex = ExMapTable[Idx].ExGuidIndex;\r
+    for (TempTsIdx = 0; TempTsIdx <= TsIdx; TempTsIdx++) {\r
+      if (&GuidTable[OldGuidIndex] == DistinctTokenSpace[TempTsIdx]) {\r
+        //\r
+        // Have recorded this GUID.\r
+        //\r
+        Match = TRUE;\r
+        break;\r
+      }\r
+    }\r
+    if (!Match) {\r
       DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];\r
     }\r
   }\r
       DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];\r
     }\r
   }\r
@@ -1099,16 +1106,20 @@ GetDistinctTokenSpace (
 }\r
   \r
 /**\r
 }\r
   \r
 /**\r
-  Get next token space in PCD database according to given token space guid.\r
-  \r
-  @param Guid            Given token space guid. If NULL, then Guid will be set to \r
-                         the first PCD token space in PCD database, If not NULL, then\r
-                         Guid will be set to next PCD token space.\r
-\r
-  @retval EFI_UNSUPPORTED \r
-  @retval EFI_NOT_FOUND   If PCD database has no token space table or can not find given\r
-                          token space in PCD database.\r
-  @retval EFI_SUCCESS     Success to get next token space guid.\r
+  Retrieves the next valid PCD token namespace for a given namespace.\r
+\r
+  Gets the next valid token namespace for a given namespace. This is useful to traverse the valid\r
+  token namespaces on a platform.\r
+\r
+  @param[in, out]   Guid    An indirect pointer to EFI_GUID. On input it designates a known token\r
+                            namespace from which the search will start. On output, it designates the next valid\r
+                            token namespace on the platform. If *Guid is NULL, then the GUID of the first token\r
+                            space of the current platform is returned. If the search cannot locate the next valid\r
+                            token namespace, an error is returned and the value of *Guid is undefined.\r
\r
+  @retval  EFI_SUCCESS      The PCD service retrieved the value requested.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the next valid token namespace.\r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1129,35 +1140,31 @@ DxePcdGetNextTokenSpace (
 \r
   ASSERT (Guid != NULL);\r
   \r
 \r
   ASSERT (Guid != NULL);\r
   \r
-  PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r
-  DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;\r
+  PeiExMapTableEmpty = mPeiExMapTableEmpty;\r
+  DxeExMapTableEmpty = mDxeExMapTableEmpty;\r
 \r
   if (PeiExMapTableEmpty && DxeExMapTableEmpty) {\r
 \r
   if (PeiExMapTableEmpty && DxeExMapTableEmpty) {\r
-    if (*Guid != NULL) {\r
-      return EFI_NOT_FOUND;\r
-    } else {\r
-      return EFI_SUCCESS;\r
-    }\r
+    return EFI_NOT_FOUND;\r
   }\r
   \r
   }\r
   \r
-  \r
   if (TmpTokenSpaceBuffer[0] == NULL) {\r
     PeiTokenSpaceTableSize = 0;\r
 \r
     if (!PeiExMapTableEmpty) {\r
   if (TmpTokenSpaceBuffer[0] == NULL) {\r
     PeiTokenSpaceTableSize = 0;\r
 \r
     if (!PeiExMapTableEmpty) {\r
-      PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;\r
+      PeiTokenSpaceTableSize = mPeiExMapppingTableSize / sizeof(DYNAMICEX_MAPPING);\r
       PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,\r
       PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,\r
-                            mPcdDatabase->PeiDb.Init.ExMapTable,\r
-                            mPcdDatabase->PeiDb.Init.GuidTable\r
+                            (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset),\r
+                            (EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset)\r
                             );\r
       CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);\r
                             );\r
       CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);\r
+      FreePool (PeiTokenSpaceTable);\r
     }\r
 \r
     if (!DxeExMapTableEmpty) {\r
     }\r
 \r
     if (!DxeExMapTableEmpty) {\r
-      DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;\r
+      DxeTokenSpaceTableSize = mDxeExMapppingTableSize / sizeof(DYNAMICEX_MAPPING);\r
       DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,\r
       DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,\r
-                            mPcdDatabase->DxeDb.Init.ExMapTable,\r
-                            mPcdDatabase->DxeDb.Init.GuidTable\r
+                            (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset),\r
+                            (EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset)\r
                             );\r
 \r
       //\r
                             );\r
 \r
       //\r
@@ -1175,6 +1182,9 @@ DxePcdGetNextTokenSpace (
           TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];\r
         }\r
       }\r
           TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];\r
         }\r
       }\r
+\r
+      TmpTokenSpaceBufferCount = Idx3;\r
+      FreePool (DxeTokenSpaceTable);\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
@@ -1183,11 +1193,19 @@ DxePcdGetNextTokenSpace (
     return EFI_SUCCESS;\r
   }\r
   \r
     return EFI_SUCCESS;\r
   }\r
   \r
-  for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {\r
-    if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {\r
-      Idx++;\r
-      *Guid = TmpTokenSpaceBuffer[Idx];\r
-      return EFI_SUCCESS;\r
+  for (Idx = 0; Idx < TmpTokenSpaceBufferCount; Idx++) {\r
+    if (CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {\r
+      if (Idx == TmpTokenSpaceBufferCount - 1) {\r
+        //\r
+        // It has been the last token namespace.\r
+        //\r
+        *Guid = NULL;\r
+        return EFI_NOT_FOUND;\r
+      } else {\r
+        Idx++;\r
+        *Guid = TmpTokenSpaceBuffer[Idx];\r
+        return EFI_SUCCESS;\r
+      }\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
index 112c91e0617e0543b99d1647e82e64d95948cb6e..6762bde06181896d951a2bd7466a0642ffce459c 100644 (file)
@@ -1,18 +1,19 @@
 ## @file\r
 ## @file\r
-# PCD DXE driver manage database contains all dynamic PCD entries initialized in \r
-# PEI phase, DXE phase and produce the implementation of PCD protocol.\r
+# PCD DXE driver manage database contains all dynamic PCD entries and produce the implementation of PCD protocol.\r
 #\r
 #\r
+# This version PCD DXE depends on the external PCD database binary file, not built in PCD data base. \r
 # There are two PCD Protocols as follows:\r
 #   1) PCD_PROTOCOL \r
 #      It is EDKII implementation which support Dynamic/DynamicEx type Pcds.\r
 # There are two PCD Protocols as follows:\r
 #   1) PCD_PROTOCOL \r
 #      It is EDKII implementation which support Dynamic/DynamicEx type Pcds.\r
-#   2) EFI_PCD_PROTOCOL_PPI\r
+#   2) EFI_PCD_PROTOCOL\r
 #      It is defined by PI specification 1.2, Vol 3 which only support dynamicEx \r
 #      type Pcd.\r
 #\r
 #      It is defined by PI specification 1.2, Vol 3 which only support dynamicEx \r
 #      type Pcd.\r
 #\r
-# For dynamicEx type PCD, it is compatible between PCD_PPI and EFI_PEI_PCD_PPI\r
+# For dynamicEx type PCD, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL\r
 # PCD DXE driver will produce above two protocols at same time.\r
 #\r
 # PCD DXE driver will produce above two protocols at same time.\r
 #\r
-# PCD database structure is generated at autogen.h/autogen.c in build time.\r
+# PCD database is generated as the separate binary image at build time. The binary image \r
+# will be intergrated into Firmware volume together with PCD driver. \r
 #\r
 # ////////////////////////////////////////////////////////////////////////////////\r
 # //                                                                            //\r
 #\r
 # ////////////////////////////////////////////////////////////////////////////////\r
 # //                                                                            //\r
@@ -63,7 +64,7 @@
 #      b) Variable Storage: \r
 #         - The PCD value is stored in variable area. \r
 #         - As default storage type, this type PCD could be used for PEI/DXE driver\r
 #      b) Variable Storage: \r
 #         - The PCD value is stored in variable area. \r
 #         - As default storage type, this type PCD could be used for PEI/DXE driver\r
-#           communication. But beside it, this type PCD could alsp be used to store \r
+#           communication. But beside it, this type PCD could also be used to store \r
 #           the value associate with a HII setting via variable interface.\r
 #         - In PEI phase, the PCD value could only be got but can not be set due \r
 #           to variable area is readonly.\r
 #           the value associate with a HII setting via variable interface.\r
 #         - In PEI phase, the PCD value could only be got but can not be set due \r
 #           to variable area is readonly.\r
 #    PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD\r
 #    database contains all PCDs used in PEI/DXE phase in memory.\r
 #    \r
 #    PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD\r
 #    database contains all PCDs used in PEI/DXE phase in memory.\r
 #    \r
-#    Build tool will generate PCD database into some C structure and variable for \r
+#    Build tool will generate PCD database into the separate binary file for \r
 #    PEI/DXE PCD driver according to dynamic PCD section in platform DSC file. \r
 #    \r
 #    3.1 PcdPeim and PcdDxe\r
 #      PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver\r
 #    PEI/DXE PCD driver according to dynamic PCD section in platform DSC file. \r
 #    \r
 #    3.1 PcdPeim and PcdDxe\r
 #      PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver\r
-#      build guid hob in temporary memory and copy auto-generated C structure \r
+#      build guid hob in temporary memory and copy the binary data base from flash \r
 #      to temporary memory for PEI PCD database. \r
 #      DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,\r
 #      a new PCD database is allocated in boot-time memory which including all\r
 #      to temporary memory for PEI PCD database. \r
 #      DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,\r
 #      a new PCD database is allocated in boot-time memory which including all\r
 #       Based on local token number, PCD driver could fast determine PCD type, value\r
 #       type and get PCD entry from PCD database.\r
 #       \r
 #       Based on local token number, PCD driver could fast determine PCD type, value\r
 #       type and get PCD entry from PCD database.\r
 #       \r
-#    3.3 PCD Database C structure.\r
-#      PCD Database C structure is generated by build tools in PCD driver's autogen.h/\r
+#    3.3 PCD Database binary file\r
+#      PCD Database binary file will be created at build time as the standalone binary image. \r
+#      To understand the binary image layout, PCD Database C structure is still generated \r
+#      as comments by build tools in PCD driver's autogen.h/\r
 #      autogen.c file. In generated C structure, following information is stored:\r
 #      - ExMapTable: This table is used translate a binary dynamicex type PCD's \r
 #                    "tokenguid + token" to local token number.\r
 #      autogen.c file. In generated C structure, following information is stored:\r
 #      - ExMapTable: This table is used translate a binary dynamicex type PCD's \r
 #                    "tokenguid + token" to local token number.\r
 #                    token number" as array index to get PCD entry's offset fastly.\r
 #      - SizeTable:  This table stores the size information for all PCD entry.\r
 #      - GuidTable:  This table stores guid value for DynamicEx's token space,\r
 #                    token number" as array index to get PCD entry's offset fastly.\r
 #      - SizeTable:  This table stores the size information for all PCD entry.\r
 #      - GuidTable:  This table stores guid value for DynamicEx's token space,\r
-#                    HII type PCD's variable.\r
+#                    HII type PCD's variable GUID.\r
 #      - SkuIdTable: TBD\r
 #      - SystemSkuId: TBD\r
 #      - PCD value structure:  \r
 #      - SkuIdTable: TBD\r
 #      - SystemSkuId: TBD\r
 #      - PCD value structure:  \r
 #          GuidTable array is used to store all related GUID value in PCD database:\r
 #            - Variable GUID for HII type PCD\r
 #            - Token space GUID for dynamicex type PCD \r
 #          GuidTable array is used to store all related GUID value in PCD database:\r
 #            - Variable GUID for HII type PCD\r
 #            - Token space GUID for dynamicex type PCD \r
-#\r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#    \r
+#  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   BASE_NAME                      = PcdDxe\r
   FILE_GUID                      = 80CF7257-87AB-47f9-A3FE-D50B76D89541\r
   MODULE_TYPE                    = DXE_DRIVER\r
   BASE_NAME                      = PcdDxe\r
   FILE_GUID                      = 80CF7257-87AB-47f9-A3FE-D50B76D89541\r
   MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
+  VERSION_STRING                 = 4.0\r
   PCD_IS_DRIVER                  = DXE_PCD_DRIVER\r
   ENTRY_POINT                    = PcdDxeInit\r
 \r
   PCD_IS_DRIVER                  = DXE_PCD_DRIVER\r
   ENTRY_POINT                    = PcdDxeInit\r
 \r
   DebugLib\r
   BaseLib\r
   PcdLib\r
   DebugLib\r
   BaseLib\r
   PcdLib\r
+  DxeServicesLib\r
 \r
 [Guids]\r
 \r
 [Guids]\r
-  gPcdDataBaseHobGuid                           ## CONSUMES  ## Hob: GUID_EXTENSION\r
+  gPcdDataBaseHobGuid                           ## SOMETIMES_CONSUMES  ## HOB\r
+  gPcdDataBaseSignatureGuid                     ## CONSUMES  ## UNDEFINED  # PCD database signature GUID.\r
 \r
 [Protocols]\r
   gPcdProtocolGuid                              ## PRODUCES\r
   gEfiPcdProtocolGuid                           ## PRODUCES\r
   \r
 [Pcd]\r
 \r
 [Protocols]\r
   gPcdProtocolGuid                              ## PRODUCES\r
   gEfiPcdProtocolGuid                           ## PRODUCES\r
   \r
 [Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress  ## SOMETIMES_CONSUMES\r
 \r
 [Depex]\r
   TRUE\r
 \r
 [Depex]\r
   TRUE\r
index 6eaadd6cceef24b8e381c6a7a7a90e7d8e18584d..513402cad91f1b591b44926258ead587ee541586 100644 (file)
@@ -13,10 +13,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include "Service.h"\r
 **/\r
 \r
 #include "Service.h"\r
+#include <Library/DxeServicesLib.h>\r
 \r
 \r
-PCD_DATABASE  *mPcdDatabase;\r
+PCD_DATABASE   mPcdDatabase;\r
+\r
+UINT32         mPcdTotalTokenCount; \r
+UINT32         mPeiLocalTokenCount; \r
+UINT32         mDxeLocalTokenCount; \r
+UINT32         mPeiNexTokenCount;   \r
+UINT32         mDxeNexTokenCount;  \r
+UINT32         mPeiExMapppingTableSize;\r
+UINT32         mDxeExMapppingTableSize;\r
+UINT32         mPeiGuidTableSize;\r
+UINT32         mDxeGuidTableSize;\r
+\r
+BOOLEAN        mPeiExMapTableEmpty; \r
+BOOLEAN        mDxeExMapTableEmpty; \r
+BOOLEAN        mPeiDatabaseEmpty;\r
 \r
 LIST_ENTRY    *mCallbackFnTable;\r
 \r
 LIST_ENTRY    *mCallbackFnTable;\r
+EFI_GUID     **TmpTokenSpaceBuffer;\r
+UINTN          TmpTokenSpaceBufferCount; \r
+\r
 \r
 /**\r
   Get the PCD entry pointer in PCD database.\r
 \r
 /**\r
   Get the PCD entry pointer in PCD database.\r
@@ -64,6 +82,8 @@ GetWorker (
   EfiAcquireLock (&mPcdDatabaseLock);\r
 \r
   RetPtr = NULL;\r
   EfiAcquireLock (&mPcdDatabaseLock);\r
 \r
   RetPtr = NULL;\r
+\r
+  ASSERT (TokenNumber > 0);\r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
   // We have to decrement TokenNumber by 1 to make it usable\r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
   // We have to decrement TokenNumber by 1 to make it usable\r
@@ -72,27 +92,26 @@ GetWorker (
   TokenNumber--;\r
 \r
   TmpTokenNumber = TokenNumber;\r
   TokenNumber--;\r
 \r
   TmpTokenNumber = TokenNumber;\r
-  \r
+\r
   //\r
   //\r
-  // PCD_TOTAL_TOKEN_NUMBER is a auto-generated constant.\r
-  // It could be zero. EBC compiler is very choosy. It may\r
-  // report warning. So we add 1 in each size of the \r
+  // EBC compiler is very choosy. It may report warning about comparison\r
+  // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
   // comparison.\r
   //\r
-  ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);\r
+  ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1);\r
 \r
   ASSERT ((GetSize == DxePcdGetSize (TokenNumber + 1)) || (GetSize == 0));\r
 \r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
 \r
   ASSERT ((GetSize == DxePcdGetSize (TokenNumber + 1)) || (GetSize == 0));\r
 \r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE);\r
+  IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);\r
 \r
 \r
-  LocalTokenNumberTable  = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable : \r
-                                     mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r
+  LocalTokenNumberTable  = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : \r
+                                     (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);\r
 \r
   TokenNumber            = IsPeiDb ? TokenNumber :\r
 \r
   TokenNumber            = IsPeiDb ? TokenNumber :\r
-                                     TokenNumber - PEI_LOCAL_TOKEN_NUMBER;\r
+                                     TokenNumber - mPeiLocalTokenCount;\r
 \r
   LocalTokenNumber = LocalTokenNumberTable[TokenNumber];\r
   \r
 \r
   LocalTokenNumber = LocalTokenNumberTable[TokenNumber];\r
   \r
@@ -105,82 +124,64 @@ GetWorker (
     LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);\r
   }\r
 \r
     LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);\r
   }\r
 \r
-  PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);\r
+  PcdDb = IsPeiDb ? ((UINT8 *) mPcdDatabase.PeiDb) : ((UINT8 *) mPcdDatabase.DxeDb);\r
                                     \r
   if (IsPeiDb) {\r
                                     \r
   if (IsPeiDb) {\r
-    StringTable = (UINT8 *) (&mPcdDatabase->PeiDb.Init.StringTable[0]);\r
+    StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->StringTableOffset);\r
   } else {\r
   } else {\r
-    StringTable = (UINT8 *) (&mPcdDatabase->DxeDb.Init.StringTable[0]);\r
+    StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->StringTableOffset);\r
   }\r
   }\r
-                                      \r
-  \r
+\r
+\r
   Offset     = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
   Offset     = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
-  \r
+\r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
       VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);\r
       RetPtr = (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);\r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
       VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);\r
       RetPtr = (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);\r
+\r
       break;\r
       break;\r
-      \r
+\r
     case PCD_TYPE_HII|PCD_TYPE_STRING:\r
     case PCD_TYPE_HII:\r
       if (IsPeiDb) {\r
     case PCD_TYPE_HII|PCD_TYPE_STRING:\r
     case PCD_TYPE_HII:\r
       if (IsPeiDb) {\r
-        GuidTable = (EFI_GUID *) (&mPcdDatabase->PeiDb.Init.GuidTable[0]);\r
+        GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset);\r
       } else {\r
       } else {\r
-        GuidTable = (EFI_GUID *) (&mPcdDatabase->DxeDb.Init.GuidTable[0]);\r
+        GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset);\r
       }\r
       }\r
-                              \r
+\r
       VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);\r
       Guid = GuidTable + VariableHead->GuidTableIndex;\r
       Name = (UINT16*)(StringTable + VariableHead->StringIndex);\r
       VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);\r
       Guid = GuidTable + VariableHead->GuidTableIndex;\r
       Name = (UINT16*)(StringTable + VariableHead->StringIndex);\r
-      \r
+\r
       if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) {\r
       if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) {\r
-           //\r
-               // If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of \r
-               // string array in string table.\r
-               //\r
+        //\r
+        // If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of \r
+        // string array in string table.\r
+        //\r
         StringTableIdx = *(STRING_HEAD*)((UINT8 *) PcdDb + VariableHead->DefaultValueOffset);   \r
         VaraiableDefaultBuffer = (VOID *) (StringTable + StringTableIdx);     \r
         StringTableIdx = *(STRING_HEAD*)((UINT8 *) PcdDb + VariableHead->DefaultValueOffset);   \r
         VaraiableDefaultBuffer = (VOID *) (StringTable + StringTableIdx);     \r
-        Status = GetHiiVariable (Guid, Name, &Data, &DataSize);\r
-        if (Status == EFI_SUCCESS) {\r
-          if (GetSize == 0) {\r
-            //\r
-            // It is a pointer type. So get the MaxSize reserved for\r
-            // this PCD entry.\r
-            //\r
-            GetPtrTypeSize (TmpTokenNumber, &GetSize);\r
-          }\r
-          //\r
-          // If the operation is successful, we copy the data\r
-          // to the default value buffer in the PCD Database.\r
-          // So that we can free the Data allocated in GetHiiVariable.\r
-          //\r
-          CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);\r
-          FreePool (Data);\r
-        }\r
-        RetPtr = (VOID *) VaraiableDefaultBuffer;                \r
       } else {\r
         VaraiableDefaultBuffer = (UINT8 *) PcdDb + VariableHead->DefaultValueOffset;\r
       } else {\r
         VaraiableDefaultBuffer = (UINT8 *) PcdDb + VariableHead->DefaultValueOffset;\r
-  \r
-        Status = GetHiiVariable (Guid, Name, &Data, &DataSize);\r
-        if (Status == EFI_SUCCESS) {\r
-          if (GetSize == 0) {\r
-            //\r
-            // It is a pointer type. So get the MaxSize reserved for\r
-            // this PCD entry.\r
-            //\r
-            GetPtrTypeSize (TmpTokenNumber, &GetSize);\r
-          }\r
+      }\r
+      Status = GetHiiVariable (Guid, Name, &Data, &DataSize);\r
+      if (Status == EFI_SUCCESS) {\r
+        if (GetSize == 0) {\r
           //\r
           //\r
-          // If the operation is successful, we copy the data\r
-          // to the default value buffer in the PCD Database.\r
-          // So that we can free the Data allocated in GetHiiVariable.\r
+          // It is a pointer type. So get the MaxSize reserved for\r
+          // this PCD entry.\r
           //\r
           //\r
-          CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);\r
-          FreePool (Data);\r
+          GetPtrTypeSize (TmpTokenNumber, &GetSize);\r
         }\r
         }\r
-        RetPtr = (VOID *) VaraiableDefaultBuffer;\r
+        //\r
+        // If the operation is successful, we copy the data\r
+        // to the default value buffer in the PCD Database.\r
+        // So that we can free the Data allocated in GetHiiVariable.\r
+        //\r
+        CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);\r
+        FreePool (Data);\r
       }\r
       }\r
+      RetPtr = (VOID *) VaraiableDefaultBuffer;\r
       break;\r
 \r
     case PCD_TYPE_STRING:\r
       break;\r
 \r
     case PCD_TYPE_STRING:\r
@@ -199,9 +200,9 @@ GetWorker (
   }\r
 \r
   EfiReleaseLock (&mPcdDatabaseLock);\r
   }\r
 \r
   EfiReleaseLock (&mPcdDatabaseLock);\r
-  \r
+\r
   return RetPtr;\r
   return RetPtr;\r
-  \r
+\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -359,6 +360,7 @@ ExGetNextTokeNumber (
   UINTN            Index;\r
   UINTN            GuidTableIdx;\r
   BOOLEAN          Found;\r
   UINTN            Index;\r
   UINTN            GuidTableIdx;\r
   BOOLEAN          Found;\r
+  UINTN            ExMapTableCount;\r
 \r
   //\r
   // Scan token space guid \r
 \r
   //\r
   // Scan token space guid \r
@@ -373,7 +375,8 @@ ExGetNextTokeNumber (
   //\r
   Found = FALSE;\r
   GuidTableIdx = MatchGuid - GuidTable;\r
   //\r
   Found = FALSE;\r
   GuidTableIdx = MatchGuid - GuidTable;\r
-  for (Index = 0; Index < SizeOfExMapTable; Index++) {\r
+  ExMapTableCount = SizeOfExMapTable / sizeof(ExMapTable[0]);\r
+  for (Index = 0; Index < ExMapTableCount; Index++) {\r
     if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
       Found = TRUE;\r
       break;\r
     if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
       Found = TRUE;\r
       break;\r
@@ -390,36 +393,71 @@ ExGetNextTokeNumber (
       return EFI_SUCCESS;\r
     }\r
 \r
       return EFI_SUCCESS;\r
     }\r
 \r
-    for ( ; Index < SizeOfExMapTable; Index++) {\r
+    for ( ; Index < ExMapTableCount; Index++) {\r
       if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {\r
       if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {\r
-        Index ++;\r
-        if (Index == SizeOfExMapTable) {\r
-          //\r
-          // Exceed the length of ExMap Table\r
-          //\r
-          *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
-          return EFI_SUCCESS;\r
-        } else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
-          //\r
-          // Found the next match\r
-          //\r
-          *TokenNumber = ExMapTable[Index].ExTokenNumber;\r
-          return EFI_SUCCESS;\r
-        } else {\r
-          //\r
-          // Guid has been changed. It is the next Token Space Guid.\r
-          // We should flag no more TokenNumber.\r
-          //\r
-          *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
-          return EFI_SUCCESS;\r
-        }\r
+        break;\r
+      }\r
+    }\r
+\r
+    while (Index < ExMapTableCount) {\r
+      Index++;\r
+      if (Index == ExMapTableCount) {\r
+        //\r
+        // Exceed the length of ExMap Table\r
+        //\r
+        *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
+        return EFI_NOT_FOUND;\r
+      } else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
+        //\r
+        // Found the next match\r
+        //\r
+        *TokenNumber = ExMapTable[Index].ExTokenNumber;\r
+        return EFI_SUCCESS;\r
       }\r
     }\r
   }\r
       }\r
     }\r
   }\r
-  \r
+\r
   return EFI_NOT_FOUND;\r
 }\r
 \r
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Find the PCD database.\r
+\r
+  @retval The base address of external PCD database binary.\r
+  @retval NULL         Return NULL if not find.\r
+**/\r
+DXE_PCD_DATABASE *\r
+LocateExPcdBinary (\r
+  VOID\r
+) \r
+{\r
+  DXE_PCD_DATABASE      *DxePcdDbBinary;\r
+  UINTN                 DxePcdDbSize;\r
+  EFI_STATUS            Status;\r
\r
+  DxePcdDbBinary = NULL;\r
+  //\r
+  // Search the External Pcd database from one section of current FFS, \r
+  // and read it to memory\r
+  //\r
+  Status = GetSectionFromFfs (\r
+             EFI_SECTION_RAW,\r
+             0,\r
+             (VOID **) &DxePcdDbBinary,\r
+             &DxePcdDbSize\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Check the first bytes (Header Signature Guid) and build version.\r
+  //\r
+  if (!CompareGuid ((VOID *)DxePcdDbBinary, &gPcdDataBaseSignatureGuid) ||\r
+      (DxePcdDbBinary->BuildVersion != PCD_SERVICE_DXE_VERSION)) {\r
+    ASSERT (FALSE);\r
+  }\r
+\r
+  return DxePcdDbBinary;\r
+}\r
 \r
 /**\r
   Initialize the PCD database in DXE phase.\r
 \r
 /**\r
   Initialize the PCD database in DXE phase.\r
@@ -436,15 +474,12 @@ BuildPcdDxeDataBase (
   PEI_PCD_DATABASE    *PeiDatabase;\r
   EFI_HOB_GUID_TYPE   *GuidHob;\r
   UINTN               Index;\r
   PEI_PCD_DATABASE    *PeiDatabase;\r
   EFI_HOB_GUID_TYPE   *GuidHob;\r
   UINTN               Index;\r
-\r
-  mPcdDatabase = AllocateZeroPool (sizeof(PCD_DATABASE));\r
-  ASSERT (mPcdDatabase != NULL);\r
+  UINT32              PcdDxeDbLen;\r
+  VOID                *PcdDxeDb;\r
 \r
   GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);\r
   if (GuidHob != NULL) {\r
 \r
 \r
   GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);\r
   if (GuidHob != NULL) {\r
 \r
-    //\r
-    // We will copy over the PEI phase's PCD Database.\r
     // \r
     // If no PEIMs use dynamic Pcd Entry, the Pcd Service PEIM\r
     // should not be included at all. So the GuidHob could\r
     // \r
     // If no PEIMs use dynamic Pcd Entry, the Pcd Service PEIM\r
     // should not be included at all. So the GuidHob could\r
@@ -454,28 +489,56 @@ BuildPcdDxeDataBase (
     \r
     PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);\r
     //\r
     \r
     PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);\r
     //\r
-    // Copy PCD Entries refereneced in PEI phase to PCD DATABASE\r
+    // Assign PCD Entries refereneced in PEI phase to PCD DATABASE\r
     //\r
     //\r
-    CopyMem (&mPcdDatabase->PeiDb, PeiDatabase, sizeof (PEI_PCD_DATABASE));\r
+    mPcdDatabase.PeiDb = PeiDatabase;\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
-  // Copy PCD Entries with default value to PCD DATABASE\r
+  // Assign PCD Entries with default value to PCD DATABASE\r
   //\r
   //\r
-  CopyMem (&mPcdDatabase->DxeDb.Init, &gDXEPcdDbInit, sizeof(DXE_PCD_DATABASE_INIT));\r
+  mPcdDatabase.DxeDb = LocateExPcdBinary ();\r
+  ASSERT(mPcdDatabase.DxeDb != NULL);\r
+  PcdDxeDbLen = mPcdDatabase.DxeDb->Length + mPcdDatabase.DxeDb->UninitDataBaseSize;\r
+  PcdDxeDb = AllocateZeroPool (PcdDxeDbLen);\r
+  CopyMem (PcdDxeDb, mPcdDatabase.DxeDb, mPcdDatabase.DxeDb->Length);\r
+  FreePool (mPcdDatabase.DxeDb);\r
+  mPcdDatabase.DxeDb = PcdDxeDb;\r
 \r
 \r
+  //\r
+  // Initialized the external PCD database local variables\r
+  //\r
+  mPeiLocalTokenCount     = mPcdDatabase.PeiDb->LocalTokenCount;\r
+  mDxeLocalTokenCount     = mPcdDatabase.DxeDb->LocalTokenCount;\r
+\r
+  mPeiExMapppingTableSize = mPcdDatabase.PeiDb->ExTokenCount * sizeof (DYNAMICEX_MAPPING);\r
+  mDxeExMapppingTableSize = mPcdDatabase.DxeDb->ExTokenCount * sizeof (DYNAMICEX_MAPPING);\r
+  mPeiGuidTableSize       = mPcdDatabase.PeiDb->GuidTableCount * sizeof(GUID);\r
+  mDxeGuidTableSize       = mPcdDatabase.DxeDb->GuidTableCount * sizeof (GUID);\r
+\r
+  mPcdTotalTokenCount     = mPeiLocalTokenCount + mDxeLocalTokenCount;\r
+  mPeiNexTokenCount       = mPeiLocalTokenCount - mPcdDatabase.PeiDb->ExTokenCount;\r
+  mDxeNexTokenCount       = mDxeLocalTokenCount - mPcdDatabase.DxeDb->ExTokenCount;  \r
+\r
+  mPeiExMapTableEmpty     = (mPcdDatabase.PeiDb->ExTokenCount == 0) ? TRUE : FALSE;\r
+  mDxeExMapTableEmpty     = (mPcdDatabase.DxeDb->ExTokenCount == 0) ? TRUE : FALSE;\r
+  mPeiDatabaseEmpty       = (mPeiLocalTokenCount == 0) ? TRUE : FALSE;\r
+\r
+  TmpTokenSpaceBufferCount = mPcdDatabase.PeiDb->ExTokenCount + mPcdDatabase.DxeDb->ExTokenCount;\r
+  TmpTokenSpaceBuffer     = (EFI_GUID **)AllocateZeroPool(TmpTokenSpaceBufferCount * sizeof (EFI_GUID *));\r
 \r
   //\r
   // Initialized the Callback Function Table\r
   //\r
 \r
   //\r
   // Initialized the Callback Function Table\r
   //\r
-\r
-  mCallbackFnTable = AllocateZeroPool (PCD_TOTAL_TOKEN_NUMBER * sizeof (LIST_ENTRY));\r
+  mCallbackFnTable = AllocateZeroPool (mPcdTotalTokenCount * sizeof (LIST_ENTRY));\r
   ASSERT(mCallbackFnTable != NULL);\r
   ASSERT(mCallbackFnTable != NULL);\r
-  \r
+\r
+  //\r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  for (Index = 0; Index + 1 < PCD_TOTAL_TOKEN_NUMBER + 1; Index++) {\r
+  //\r
+  for (Index = 0; Index + 1 < mPcdTotalTokenCount + 1; Index++) {\r
     InitializeListHead (&mCallbackFnTable[Index]);\r
   }\r
 }\r
     InitializeListHead (&mCallbackFnTable[Index]);\r
   }\r
 }\r
@@ -568,29 +631,39 @@ GetSkuEnabledTokenNumber (
   SKU_ID                *SkuIdTable;\r
   INTN                  Index;\r
   UINT8                 *Value;\r
   SKU_ID                *SkuIdTable;\r
   INTN                  Index;\r
   UINT8                 *Value;\r
-  SKU_ID                *PhaseSkuIdTable;\r
   UINT8                 *PcdDb;\r
   UINT8                 *PcdDb;\r
+  BOOLEAN               FoundSku;\r
 \r
   ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);\r
 \r
 \r
   ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);\r
 \r
-  PcdDb = IsPeiDb ? (UINT8 *) &mPcdDatabase->PeiDb : (UINT8 *) &mPcdDatabase->DxeDb;\r
+  PcdDb = IsPeiDb ? (UINT8 *) mPcdDatabase.PeiDb : (UINT8 *) mPcdDatabase.DxeDb;\r
 \r
   SkuHead     = (SKU_HEAD *) (PcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));\r
   Value       = (UINT8 *) (PcdDb + SkuHead->SkuDataStartOffset); \r
 \r
 \r
   SkuHead     = (SKU_HEAD *) (PcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));\r
   Value       = (UINT8 *) (PcdDb + SkuHead->SkuDataStartOffset); \r
 \r
-  PhaseSkuIdTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SkuIdTable :\r
-                              mPcdDatabase->DxeDb.Init.SkuIdTable;\r
-                              \r
-  SkuIdTable  = &PhaseSkuIdTable[SkuHead->SkuIdTableOffset];\r
-        \r
+  SkuIdTable =  (SKU_ID *)(PcdDb + SkuHead->SkuIdTableOffset);\r
   //\r
   // Find the current system's SKU ID entry in SKU ID table.\r
   //\r
   //\r
   // Find the current system's SKU ID entry in SKU ID table.\r
   //\r
+  FoundSku = FALSE;\r
   for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
   for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
-    if (mPcdDatabase->PeiDb.Init.SystemSkuId == SkuIdTable[Index + 1]) {\r
+    if (mPcdDatabase.PeiDb->SystemSkuId == SkuIdTable[Index + 1]) {\r
+      FoundSku = TRUE;\r
       break;\r
     }\r
   }\r
       break;\r
     }\r
   }\r
+  \r
+  //\r
+  // Find the default SKU ID entry in SKU ID table.\r
+  //\r
+  \r
+  if(!FoundSku) {\r
+    for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
+      if (0 == SkuIdTable[Index + 1]) {\r
+        break;\r
+      }\r
+    }\r
+  }\r
   ASSERT (Index < SkuIdTable[0]);\r
 \r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
   ASSERT (Index < SkuIdTable[0]);\r
 \r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
@@ -602,13 +675,17 @@ GetSkuEnabledTokenNumber (
       Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - PcdDb) | PCD_TYPE_HII);\r
 \r
       Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - PcdDb) | PCD_TYPE_HII);\r
 \r
+    case PCD_TYPE_HII|PCD_TYPE_STRING:\r
+      Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);\r
+      return (UINT32) ((Value - PcdDb) | PCD_TYPE_HII | PCD_TYPE_STRING);\r
+\r
     case PCD_TYPE_STRING:\r
       Value = (UINT8 *) &(((STRING_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - PcdDb) | PCD_TYPE_STRING);\r
       \r
     case PCD_TYPE_DATA:\r
       Value += Size * Index;\r
     case PCD_TYPE_STRING:\r
       Value = (UINT8 *) &(((STRING_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - PcdDb) | PCD_TYPE_STRING);\r
       \r
     case PCD_TYPE_DATA:\r
       Value += Size * Index;\r
-      return (UINT32) (Value - PcdDb);\r
+      return (UINT32) ((Value - PcdDb) | PCD_TYPE_DATA);\r
 \r
     default:\r
       ASSERT (FALSE);\r
 \r
     default:\r
       ASSERT (FALSE);\r
@@ -744,7 +821,7 @@ SetWorker (
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
-  ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);\r
+  ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1);\r
 \r
   if (PtrType) {\r
     //\r
 \r
   if (PtrType) {\r
     //\r
@@ -766,8 +843,8 @@ SetWorker (
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
-  if ((TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) ||\r
-      (TokenNumber + 1 >= PEI_LOCAL_TOKEN_NUMBER + 1 || TokenNumber + 1 < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1))) {\r
+  if ((TokenNumber + 1 < mPeiNexTokenCount + 1) ||\r
+      (TokenNumber + 1 >= mPeiLocalTokenCount + 1 && TokenNumber + 1 < (mPeiLocalTokenCount + mDxeNexTokenCount + 1))) {\r
     InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);\r
   }\r
 \r
     InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);\r
   }\r
 \r
@@ -781,13 +858,13 @@ SetWorker (
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
-  IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE);\r
+  IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);\r
 \r
 \r
-  LocalTokenNumberTable  = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable : \r
-                                     mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r
+  LocalTokenNumberTable  = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : \r
+                                     (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset) ;\r
 \r
   TokenNumber = IsPeiDb ? TokenNumber\r
 \r
   TokenNumber = IsPeiDb ? TokenNumber\r
-                        : TokenNumber - PEI_LOCAL_TOKEN_NUMBER;\r
+                        : TokenNumber - mPeiLocalTokenCount;\r
 \r
   LocalTokenNumber = LocalTokenNumberTable[TokenNumber];\r
   \r
 \r
   LocalTokenNumber = LocalTokenNumberTable[TokenNumber];\r
   \r
@@ -802,12 +879,12 @@ SetWorker (
 \r
   Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
 \r
 \r
   Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
 \r
-  PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);\r
+  PcdDb = IsPeiDb ? ((UINT8 *) mPcdDatabase.PeiDb) : ((UINT8 *) mPcdDatabase.DxeDb);\r
 \r
   if (IsPeiDb) {\r
 \r
   if (IsPeiDb) {\r
-    StringTable = (UINT8 *) (&mPcdDatabase->PeiDb.Init.StringTable[0]);\r
+    StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->StringTableOffset);\r
   } else {\r
   } else {\r
-    StringTable = (UINT8 *) (&mPcdDatabase->DxeDb.Init.StringTable[0]);\r
+    StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->StringTableOffset);\r
   }\r
 \r
   \r
   }\r
 \r
   \r
@@ -836,20 +913,20 @@ SetWorker (
           break;\r
         }\r
       }\r
           break;\r
         }\r
       }\r
-      \r
+\r
       if (IsPeiDb) {\r
       if (IsPeiDb) {\r
-        GuidTable = (EFI_GUID *) (&mPcdDatabase->PeiDb.Init.GuidTable[0]);\r
+        GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset);\r
       } else {\r
       } else {\r
-        GuidTable = (EFI_GUID *) (&mPcdDatabase->DxeDb.Init.GuidTable[0]);\r
+        GuidTable = (EFI_GUID *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset);\r
       }\r
       }\r
-                              \r
+\r
       VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);\r
       VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);\r
-      \r
+\r
       Guid = GuidTable + VariableHead->GuidTableIndex;\r
       Name = (UINT16*) (StringTable + VariableHead->StringIndex);\r
       VariableOffset = VariableHead->Offset;\r
       Status = SetHiiVariable (Guid, Name, Data, *Size, VariableOffset);\r
       Guid = GuidTable + VariableHead->GuidTableIndex;\r
       Name = (UINT16*) (StringTable + VariableHead->StringIndex);\r
       VariableOffset = VariableHead->Offset;\r
       Status = SetHiiVariable (Guid, Name, Data, *Size, VariableOffset);\r
-      \r
+\r
       if (EFI_NOT_FOUND == Status) {\r
         if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING))  {\r
           CopyMem (\r
       if (EFI_NOT_FOUND == Status) {\r
         if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING))  {\r
           CopyMem (\r
@@ -954,7 +1031,7 @@ ExSetValueWorker (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Set value for a dynamic PCD entry.\r
+  Set value for a dynamic-ex PCD entry.\r
   \r
   This routine find the local token number according to dynamic-ex PCD's token \r
   space guid and token number firstly, and invoke callback function if this PCD\r
   \r
   This routine find the local token number according to dynamic-ex PCD's token \r
   space guid and token number firstly, and invoke callback function if this PCD\r
@@ -1100,16 +1177,16 @@ SetHiiVariable (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
+  Get Token Number according to dynamic-ex PCD's {token space guid:token number}\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
-  space guid: token number} to local token number.\r
+  space guid: token number} to Token Number.\r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   @param ExTokenNumber   Dynamic-ex PCD token number.\r
 \r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   @param ExTokenNumber   Dynamic-ex PCD token number.\r
 \r
-  @return local token number for dynamic-ex PCD.\r
+  @return Token Number for dynamic-ex PCD.\r
 \r
 **/\r
 UINTN           \r
 \r
 **/\r
 UINTN           \r
@@ -1124,29 +1201,29 @@ GetExPcdTokenNumber (
   EFI_GUID            *MatchGuid;\r
   UINTN               MatchGuidIdx;\r
 \r
   EFI_GUID            *MatchGuid;\r
   UINTN               MatchGuidIdx;\r
 \r
-  if (!PEI_DATABASE_EMPTY) {\r
-    ExMap       = mPcdDatabase->PeiDb.Init.ExMapTable;\r
-    GuidTable   = mPcdDatabase->PeiDb.Init.GuidTable;\r
-    \r
-    MatchGuid   = ScanGuid (GuidTable, sizeof(mPcdDatabase->PeiDb.Init.GuidTable), Guid);\r
-    \r
+  if (!mPeiDatabaseEmpty) {\r
+    ExMap       = (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->ExMapTableOffset);\r
+    GuidTable   = (EFI_GUID *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->GuidTableOffset);\r
+\r
+    MatchGuid   = ScanGuid (GuidTable, mPeiGuidTableSize, Guid);\r
+\r
     if (MatchGuid != NULL) {\r
 \r
       MatchGuidIdx = MatchGuid - GuidTable;\r
     if (MatchGuid != NULL) {\r
 \r
       MatchGuidIdx = MatchGuid - GuidTable;\r
-      \r
-      for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+\r
+      for (Index = 0; Index < mPeiExMapppingTableSize; Index++) {\r
         if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&\r
             (MatchGuidIdx == ExMap[Index].ExGuidIndex)) {\r
         if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&\r
             (MatchGuidIdx == ExMap[Index].ExGuidIndex)) {\r
-            return ExMap[Index].LocalTokenNumber;\r
+            return ExMap[Index].TokenNumber;\r
         }\r
       }\r
     }\r
   }\r
         }\r
       }\r
     }\r
   }\r
-  \r
-  ExMap       = mPcdDatabase->DxeDb.Init.ExMapTable;\r
-  GuidTable   = mPcdDatabase->DxeDb.Init.GuidTable;\r
 \r
 \r
-  MatchGuid   = ScanGuid (GuidTable, sizeof(mPcdDatabase->DxeDb.Init.GuidTable), Guid);\r
+  ExMap       = (DYNAMICEX_MAPPING *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->ExMapTableOffset);\r
+  GuidTable   = (EFI_GUID *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->GuidTableOffset);\r
+\r
+  MatchGuid   = ScanGuid (GuidTable, mDxeGuidTableSize, Guid);\r
   //\r
   // We need to ASSERT here. If GUID can't be found in GuidTable, this is a\r
   // error in the BUILD system.\r
   //\r
   // We need to ASSERT here. If GUID can't be found in GuidTable, this is a\r
   // error in the BUILD system.\r
@@ -1154,11 +1231,11 @@ GetExPcdTokenNumber (
   ASSERT (MatchGuid != NULL);\r
 \r
   MatchGuidIdx = MatchGuid - GuidTable;\r
   ASSERT (MatchGuid != NULL);\r
 \r
   MatchGuidIdx = MatchGuid - GuidTable;\r
-  \r
-  for (Index = 0; Index < DXE_EXMAPPING_TABLE_SIZE; Index++) {\r
+\r
+  for (Index = 0; Index < mDxeExMapppingTableSize; Index++) {\r
     if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&\r
          (MatchGuidIdx == ExMap[Index].ExGuidIndex)) {\r
     if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&\r
          (MatchGuidIdx == ExMap[Index].ExGuidIndex)) {\r
-        return ExMap[Index].LocalTokenNumber;\r
+        return ExMap[Index].TokenNumber;\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
@@ -1171,27 +1248,27 @@ GetExPcdTokenNumber (
   Get SKU ID table from PCD database.\r
 \r
   @param LocalTokenNumberTableIdx Index of local token number in token number table.\r
   Get SKU ID table from PCD database.\r
 \r
   @param LocalTokenNumberTableIdx Index of local token number in token number table.\r
-  @param IsPeiPcd                 If TRUE, \r
-\r
+  @param IsPeiDb                  If TRUE, the pcd entry is initialized in PEI phase,\r
+                                  If FALSE, the pcd entry is initialized in DXE phase.\r
   @return Pointer to SKU ID array table\r
 \r
 **/\r
 SKU_ID *\r
 GetSkuIdArray (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
   @return Pointer to SKU ID array table\r
 \r
 **/\r
 SKU_ID *\r
 GetSkuIdArray (\r
   IN    UINTN             LocalTokenNumberTableIdx,\r
-  IN    BOOLEAN           IsPeiPcd\r
+  IN    BOOLEAN           IsPeiDb\r
   )\r
 {\r
   SKU_HEAD  *SkuHead;\r
   UINTN     LocalTokenNumber;\r
   UINT8     *Database;\r
 \r
   )\r
 {\r
   SKU_HEAD  *SkuHead;\r
   UINTN     LocalTokenNumber;\r
   UINT8     *Database;\r
 \r
-  if (IsPeiPcd) {\r
-    LocalTokenNumber = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
-    Database         = (UINT8 *) &mPcdDatabase->PeiDb;\r
+  if (IsPeiDb) {\r
+    LocalTokenNumber = *((UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);\r
+    Database         = (UINT8 *) mPcdDatabase.PeiDb;\r
   } else {\r
   } else {\r
-    LocalTokenNumber = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable[LocalTokenNumberTableIdx - PEI_LOCAL_TOKEN_NUMBER];\r
-    Database         = (UINT8 *) &mPcdDatabase->DxeDb;\r
+    LocalTokenNumber = *((UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);\r
+    Database         = (UINT8 *) mPcdDatabase.DxeDb;\r
   }\r
 \r
   ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);\r
   }\r
 \r
   ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);\r
@@ -1224,9 +1301,9 @@ GetSizeTableIndex (
   SKU_ID *SkuIdTable;\r
   \r
   if (IsPeiDb) {\r
   SKU_ID *SkuIdTable;\r
   \r
   if (IsPeiDb) {\r
-    LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;\r
+    LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset);\r
   } else {\r
   } else {\r
-    LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r
+    LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);\r
   }\r
 \r
   SizeTableIdx = 0;\r
   }\r
 \r
   SizeTableIdx = 0;\r
@@ -1241,11 +1318,12 @@ GetSizeTableIndex (
       //\r
       if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
           //\r
       //\r
       if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
           //\r
-          // We have only one entry for VPD enabled PCD entry:\r
+          // We have only two entry for VPD enabled PCD entry:\r
           // 1) MAX Size.\r
           // 1) MAX Size.\r
-          // We consider current size is equal to MAX size.\r
+          // 2) Current Size\r
+          // Current size is equal to MAX size.\r
           //\r
           //\r
-          SizeTableIdx++;\r
+          SizeTableIdx += 2;\r
       } else {\r
         if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r
           //\r
       } else {\r
         if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r
           //\r
@@ -1297,16 +1375,16 @@ GetPtrTypeSize (
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
+  IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < mPeiLocalTokenCount + 1);\r
 \r
 \r
   if (IsPeiDb) {\r
 \r
 \r
   if (IsPeiDb) {\r
-    LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;\r
-    SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;\r
+    LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset);\r
+    SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->SizeTableOffset);\r
   } else {\r
   } else {\r
-    LocalTokenNumberTableIdx -= PEI_LOCAL_TOKEN_NUMBER;\r
-    LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r
-    SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;\r
+    LocalTokenNumberTableIdx -= mPeiLocalTokenCount;\r
+    LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);\r
+    SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SizeTableOffset);\r
   }\r
 \r
   LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
   }\r
 \r
   LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
@@ -1322,8 +1400,9 @@ GetPtrTypeSize (
   //\r
   if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
       //\r
   //\r
   if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
       //\r
-      // We have only one entry for VPD enabled PCD entry:\r
+      // We have only two entry for VPD enabled PCD entry:\r
       // 1) MAX Size.\r
       // 1) MAX Size.\r
+      // 2) Current Size\r
       // We consider current size is equal to MAX size.\r
       //\r
       return *MaxSize;\r
       // We consider current size is equal to MAX size.\r
       //\r
       return *MaxSize;\r
@@ -1343,7 +1422,7 @@ GetPtrTypeSize (
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
-        if (SkuIdTable[1 + Index] == mPcdDatabase->PeiDb.Init.SystemSkuId) {\r
+        if (SkuIdTable[1 + Index] == mPcdDatabase.PeiDb->SystemSkuId) {\r
           return SizeTable[SizeTableIdx + 1 + Index];\r
         }\r
       }\r
           return SizeTable[SizeTableIdx + 1 + Index];\r
         }\r
       }\r
@@ -1382,15 +1461,15 @@ SetPtrTypeSize (
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   //\r
-  IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
+  IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < mPeiLocalTokenCount + 1);\r
 \r
   if (IsPeiDb) {\r
 \r
   if (IsPeiDb) {\r
-    LocalTokenNumberTable = mPcdDatabase->PeiDb.Init.LocalTokenNumberTable;\r
-    SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;\r
+    LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset);\r
+    SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->SizeTableOffset);\r
   } else {\r
   } else {\r
-    LocalTokenNumberTableIdx -= PEI_LOCAL_TOKEN_NUMBER;\r
-    LocalTokenNumberTable = mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r
-    SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;\r
+    LocalTokenNumberTableIdx -= mPeiLocalTokenCount;\r
+    LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);\r
+    SizeTable = (SIZE_INFO *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SizeTableOffset);\r
   }\r
 \r
   LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
   }\r
 \r
   LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
@@ -1433,7 +1512,7 @@ SetPtrTypeSize (
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, IsPeiDb);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
-        if (SkuIdTable[1 + Index] == mPcdDatabase->PeiDb.Init.SystemSkuId) {\r
+        if (SkuIdTable[1 + Index] == mPcdDatabase.PeiDb->SystemSkuId) {\r
           SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;\r
           return TRUE;\r
         }\r
           SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;\r
           return TRUE;\r
         }\r
index c15edd3e82ce7237c3940b937416568ec027f89b..292a74cfb5a036dae04d0421c7397a5dfcddcd52 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Private functions used by PCD DXE driver.\r
 \r
 /** @file\r
 Private functions used by PCD DXE driver.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <PiDxe.h>\r
 #include <Guid/PcdDataBaseHobGuid.h>\r
 \r
 #include <PiDxe.h>\r
 #include <Guid/PcdDataBaseHobGuid.h>\r
+#include <Guid/PcdDataBaseSignatureGuid.h>\r
 #include <Protocol/Pcd.h>\r
 #include <Protocol/PiPcd.h>\r
 #include <Library/BaseLib.h>\r
 #include <Protocol/Pcd.h>\r
 #include <Protocol/PiPcd.h>\r
 #include <Library/BaseLib.h>\r
@@ -34,7 +35,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 // Please make sure the PCD Serivce DXE Version is consistent with\r
 // the version of the generated DXE PCD Database by build tool.\r
 //\r
 // Please make sure the PCD Serivce DXE Version is consistent with\r
 // the version of the generated DXE PCD Database by build tool.\r
 //\r
-#define PCD_SERVICE_DXE_VERSION      2\r
+#define PCD_SERVICE_DXE_VERSION      4\r
 \r
 //\r
 // PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.\r
 \r
 //\r
 // PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.\r
@@ -995,16 +996,16 @@ BuildPcdDxeDataBase (
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
-  Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
+  Get Token Number according to dynamic-ex PCD's {token space guid:token number}\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
-  space guid: token number} to local token number.\r
+  space guid: token number} to Token Number.\r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   @param ExTokenNumber   Dynamic-ex PCD token number.\r
 \r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   @param ExTokenNumber   Dynamic-ex PCD token number.\r
 \r
-  @return local token number for dynamic-ex PCD.\r
+  @return Token Number for dynamic-ex PCD.\r
 \r
 **/\r
 UINTN\r
 \r
 **/\r
 UINTN\r
@@ -1079,9 +1080,24 @@ SetPtrTypeSize (
   IN    OUT   UINTN             *CurrentSize\r
   );\r
 \r
   IN    OUT   UINTN             *CurrentSize\r
   );\r
 \r
-extern PCD_DATABASE * mPcdDatabase;\r
+extern  PCD_DATABASE   mPcdDatabase;\r
 \r
 \r
-extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;\r
+extern  UINT32         mPcdTotalTokenCount; \r
+extern  UINT32         mPeiLocalTokenCount; \r
+extern  UINT32         mDxeLocalTokenCount; \r
+extern  UINT32         mPeiNexTokenCount;   \r
+extern  UINT32         mDxeNexTokenCount;  \r
+extern  UINT32         mPeiExMapppingTableSize;\r
+extern  UINT32         mDxeExMapppingTableSize;\r
+extern  UINT32         mPeiGuidTableSize;\r
+extern  UINT32         mDxeGuidTableSize;\r
+\r
+extern  BOOLEAN        mPeiExMapTableEmpty; \r
+extern  BOOLEAN        mDxeExMapTableEmpty; \r
+extern  BOOLEAN        mPeiDatabaseEmpty;\r
+\r
+extern  EFI_GUID     **TmpTokenSpaceBuffer;\r
+extern  UINTN          TmpTokenSpaceBufferCount;\r
 \r
 extern EFI_LOCK mPcdDatabaseLock;\r
 \r
 \r
 extern EFI_LOCK mPcdDatabaseLock;\r
 \r
index 5ab8e12874160562ccfe90e0143222c02ada2121..557b915a1234e9c881297db174d7bc9570572fda 100644 (file)
@@ -1,7 +1,7 @@
 /** @file \r
   All Pcd Ppi services are implemented here.\r
   \r
 /** @file \r
   All Pcd Ppi services are implemented here.\r
   \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -116,7 +116,7 @@ PcdPeimInit (
 {\r
   EFI_STATUS Status;\r
   \r
 {\r
   EFI_STATUS Status;\r
   \r
-  BuildPcdDatabase ();\r
+  BuildPcdDatabase (FileHandle);\r
 \r
   //\r
   // Install PCD_PPI and EFI_PEI_PCD_PPI.\r
 \r
   //\r
   // Install PCD_PPI and EFI_PEI_PCD_PPI.\r
@@ -155,7 +155,7 @@ PeiPcdSetSku (
   )\r
 {\r
 \r
   )\r
 {\r
 \r
-  GetPcdDatabase()->Init.SystemSkuId = (SKU_ID) SkuId;\r
+  GetPcdDatabase()->SystemSkuId = (SKU_ID) SkuId;\r
 \r
   return;\r
 }\r
 \r
   return;\r
 }\r
@@ -304,8 +304,10 @@ PeiPcdGetSize (
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   UINTN               Size;\r
   UINTN               MaxSize;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   UINTN               Size;\r
   UINTN               MaxSize;\r
+  UINT32              LocalTokenCount;\r
 \r
 \r
-  PeiPcdDb = GetPcdDatabase ();\r
+  PeiPcdDb        = GetPcdDatabase ();\r
+  LocalTokenCount = PeiPcdDb->LocalTokenCount;\r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
   // We have to decrement TokenNumber by 1 to make it usable\r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
   // We have to decrement TokenNumber by 1 to make it usable\r
@@ -316,9 +318,9 @@ PeiPcdGetSize (
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
+  ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));\r
 \r
 \r
-  Size = (PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
+  Size = (*((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber) & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
 \r
   if (Size == 0) {\r
     //\r
 \r
   if (Size == 0) {\r
     //\r
@@ -926,10 +928,8 @@ PcdUnRegisterCallBackOnSet (
                                is being made to retrieve tokens from the default token space.\r
   @param[in, out]  TokenNumber A pointer to the PCD token number to use to find the subsequent token number.\r
                    \r
                                is being made to retrieve tokens from the default token space.\r
   @param[in, out]  TokenNumber A pointer to the PCD token number to use to find the subsequent token number.\r
                    \r
-  @retval EFI_SUCCESS   The PCD service has retrieved the next valid token number. \r
-                        Or the input token number is already the last valid token number in the PCD database. \r
-                        In the later case, *TokenNumber is updated with the value of 0.\r
-  @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r
+  @retval EFI_SUCCESS   The PCD service has retrieved the next valid token number.\r
+  @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -942,55 +942,56 @@ PeiPcdGetNextToken (
   UINTN               GuidTableIdx;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   EFI_GUID            *MatchGuid;\r
   UINTN               GuidTableIdx;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   EFI_GUID            *MatchGuid;\r
+  EFI_GUID            *GuidTable;\r
   DYNAMICEX_MAPPING   *ExMapTable;\r
   UINTN               Index;\r
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
   DYNAMICEX_MAPPING   *ExMapTable;\r
   UINTN               Index;\r
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
+  UINTN               PeiNexTokenNumber; \r
 \r
   if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
 \r
   if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r
+  PeiPcdDb          = GetPcdDatabase ();\r
+  PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;\r
+  GuidTable         = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);\r
 \r
 \r
+  if (PeiPcdDb->ExTokenCount == 0) {\r
+    PeiExMapTableEmpty = TRUE;\r
+  } else {\r
+    PeiExMapTableEmpty = FALSE;\r
+  }\r
   if (Guid == NULL) {\r
   if (Guid == NULL) {\r
-    if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r
+    if (*TokenNumber > PeiNexTokenNumber) {\r
       return EFI_NOT_FOUND;\r
     }\r
     (*TokenNumber)++;\r
       return EFI_NOT_FOUND;\r
     }\r
     (*TokenNumber)++;\r
-    if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r
+    if (*TokenNumber > PeiNexTokenNumber) {\r
       *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
       *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
+      return EFI_NOT_FOUND;\r
     }\r
     return EFI_SUCCESS;\r
   } else {\r
     if (PeiExMapTableEmpty) {\r
     }\r
     return EFI_SUCCESS;\r
   } else {\r
     if (PeiExMapTableEmpty) {\r
-      *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
-      return EFI_SUCCESS;\r
+      return EFI_NOT_FOUND;\r
     }\r
     }\r
-    \r
-    //\r
-    // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r
-    // 1) ExGuid\r
-    // 2) ExTokenNumber\r
-    //\r
-    PeiPcdDb = GetPcdDatabase ();\r
-    \r
-    MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);\r
+\r
+    MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(EFI_GUID), Guid);\r
 \r
     if (MatchGuid == NULL) {\r
 \r
     if (MatchGuid == NULL) {\r
-      *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
       return EFI_NOT_FOUND;\r
     }\r
 \r
       return EFI_NOT_FOUND;\r
     }\r
 \r
-    GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r
+    GuidTableIdx = MatchGuid - GuidTable;\r
 \r
 \r
-    ExMapTable = PeiPcdDb->Init.ExMapTable;\r
+    ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);\r
 \r
     Found = FALSE;\r
     //\r
     // Locate the GUID in ExMapTable first.\r
     //\r
 \r
     Found = FALSE;\r
     //\r
     // Locate the GUID in ExMapTable first.\r
     //\r
-    for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+    for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {\r
       if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
         Found = TRUE;\r
         break;\r
       if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
         Found = TRUE;\r
         break;\r
@@ -1003,26 +1004,28 @@ PeiPcdGetNextToken (
          return EFI_SUCCESS;\r
       }\r
 \r
          return EFI_SUCCESS;\r
       }\r
 \r
-      for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+      for ( ; Index < PeiPcdDb->ExTokenCount; Index++) {\r
         if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {\r
         if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {\r
-          Index++;\r
-          if (Index == PEI_EXMAPPING_TABLE_SIZE) {\r
-            //\r
-            // Exceed the length of ExMap Table\r
-            //\r
-            *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
-            return EFI_SUCCESS;\r
-          }\r
-          if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
-            *TokenNumber = ExMapTable[Index].ExTokenNumber;\r
-            return EFI_SUCCESS;\r
-          } else {\r
-            *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
-            return EFI_SUCCESS;\r
-          }\r
+          break;\r
+        }\r
+      }\r
+\r
+      while (Index < PeiPcdDb->ExTokenCount) {\r
+        Index++;\r
+        if (Index == PeiPcdDb->ExTokenCount) {\r
+          //\r
+          // Exceed the length of ExMap Table\r
+          //\r
+          *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
+          return EFI_NOT_FOUND;\r
+        } else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
+          //\r
+          // Found the next match\r
+          //\r
+          *TokenNumber = ExMapTable[Index].ExTokenNumber;\r
+          return EFI_SUCCESS;\r
         }\r
       }\r
         }\r
       }\r
-      return EFI_NOT_FOUND;\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
@@ -1032,22 +1035,17 @@ PeiPcdGetNextToken (
 /**\r
   Retrieves the next valid PCD token namespace for a given namespace.\r
 \r
 /**\r
   Retrieves the next valid PCD token namespace for a given namespace.\r
 \r
-  @param[in, out]  Guid An indirect pointer to EFI_GUID.  On input it designates \r
-                    a known token namespace from which the search will start. On output, \r
-                    it designates the next valid token namespace on the platform. If the input \r
-                    token namespace does not exist on the platform, an error is returned and \r
-                    the value of *Guid is undefined. If *Guid is NULL, then the GUID of the \r
-                    first token space of the current platform is assigned to *Guid the function \r
-                    return EFI_SUCCESS. If  *Guid is NULL  and there is no namespace exist in \r
-                    the platform other than the default (NULL) tokennamespace, *Guid is unchanged \r
-                    and the function return EFI_SUCCESS. If this input token namespace is the last \r
-                    namespace on the platform, *Guid will be assigned to NULL and the function return \r
-                    EFI_SUCCESS. \r
-\r
-  @retval EFI_SUCCESS  The PCD service retrieved the next valid token space Guid. \r
-                        Or the input token space Guid is already the last valid token space Guid \r
-                        in the PCD database. In the later case, *Guid is updated with the value of NULL.\r
-  @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.\r
+  Gets the next valid token namespace for a given namespace. This is useful to traverse the valid\r
+  token namespaces on a platform.\r
+\r
+  @param[in, out]   Guid    An indirect pointer to EFI_GUID. On input it designates a known token\r
+                            namespace from which the search will start. On output, it designates the next valid\r
+                            token namespace on the platform. If *Guid is NULL, then the GUID of the first token\r
+                            space of the current platform is returned. If the search cannot locate the next valid\r
+                            token namespace, an error is returned and the value of *Guid is undefined.\r
\r
+  @retval  EFI_SUCCESS      The PCD service retrieved the value requested.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the next valid token namespace.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1061,8 +1059,10 @@ PeiPcdGetNextTokenSpace (
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   DYNAMICEX_MAPPING   *ExMapTable;\r
   UINTN               Index;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   DYNAMICEX_MAPPING   *ExMapTable;\r
   UINTN               Index;\r
+  UINTN               Index2;\r
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
   BOOLEAN             Found;\r
   BOOLEAN             PeiExMapTableEmpty;\r
+  EFI_GUID            *GuidTable;\r
 \r
   if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {\r
     return EFI_UNSUPPORTED;\r
 \r
   if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {\r
     return EFI_UNSUPPORTED;\r
@@ -1070,43 +1070,39 @@ PeiPcdGetNextTokenSpace (
 \r
   ASSERT (Guid != NULL);\r
 \r
 \r
   ASSERT (Guid != NULL);\r
 \r
-  PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;\r
+  PeiPcdDb = GetPcdDatabase ();\r
 \r
 \r
+  if (PeiPcdDb->ExTokenCount == 0) {\r
+    PeiExMapTableEmpty = TRUE;\r
+  } else {\r
+    PeiExMapTableEmpty = FALSE;\r
+  }\r
+  \r
   if (PeiExMapTableEmpty) {\r
   if (PeiExMapTableEmpty) {\r
-    if (*Guid != NULL) {\r
-      return EFI_NOT_FOUND;\r
-    } else {\r
-      return EFI_SUCCESS;\r
-    }\r
+    return EFI_NOT_FOUND;\r
   }\r
 \r
   }\r
 \r
-  //\r
-  // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r
-  // 1) ExGuid\r
-  // 2) ExTokenNumber\r
-  //\r
-  PeiPcdDb = GetPcdDatabase ();\r
-\r
-  ExMapTable = PeiPcdDb->Init.ExMapTable;\r
-\r
+  ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);\r
+  GuidTable  = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);\r
+  \r
   if (*Guid == NULL) {\r
     //\r
     // return the first Token Space Guid.\r
     //\r
   if (*Guid == NULL) {\r
     //\r
     // return the first Token Space Guid.\r
     //\r
-    *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[0].ExGuidIndex];\r
+    *Guid = GuidTable + ExMapTable[0].ExGuidIndex;\r
     return EFI_SUCCESS;\r
   }\r
 \r
     return EFI_SUCCESS;\r
   }\r
 \r
-  MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), *Guid);\r
+  MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(GuidTable[0]), *Guid);\r
 \r
   if (MatchGuid == NULL) {\r
     return EFI_NOT_FOUND;\r
   }\r
   \r
 \r
   if (MatchGuid == NULL) {\r
     return EFI_NOT_FOUND;\r
   }\r
   \r
-  GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r
+  GuidTableIdx = MatchGuid - GuidTable;\r
 \r
   Found = FALSE;\r
 \r
   Found = FALSE;\r
-  for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+  for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {\r
     if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
       Found = TRUE;\r
       break;\r
     if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
       Found = TRUE;\r
       break;\r
@@ -1115,14 +1111,25 @@ PeiPcdGetNextTokenSpace (
 \r
   if (Found) {\r
     Index++;\r
 \r
   if (Found) {\r
     Index++;\r
-    for ( ; Index < PEI_EXMAPPING_TABLE_SIZE; Index++ ) {\r
-      if (ExMapTable[Index].ExGuidIndex != GuidTableIdx ) {\r
-        *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[Index].ExGuidIndex];\r
-        return EFI_SUCCESS;\r
+    for ( ; Index < PeiPcdDb->ExTokenCount; Index++ ) {\r
+      if (ExMapTable[Index].ExGuidIndex != GuidTableIdx) {\r
+        Found = FALSE;\r
+        for (Index2 = 0 ; Index2 < Index; Index2++) {\r
+          if (ExMapTable[Index2].ExGuidIndex == ExMapTable[Index].ExGuidIndex) {\r
+            //\r
+            // This token namespace should have been found and output at preceding getting.\r
+            //\r
+            Found = TRUE;\r
+            break;\r
+          }\r
+        }\r
+        if (!Found) {\r
+          *Guid = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset) + ExMapTable[Index].ExGuidIndex;\r
+          return EFI_SUCCESS;\r
+        }\r
       }\r
     }\r
     *Guid = NULL;\r
       }\r
     }\r
     *Guid = NULL;\r
-    return EFI_SUCCESS;\r
   }\r
 \r
   return EFI_NOT_FOUND;\r
   }\r
 \r
   return EFI_NOT_FOUND;\r
@@ -1132,7 +1139,7 @@ PeiPcdGetNextTokenSpace (
 /**\r
   Get PCD value's size for POINTER type PCD.\r
   \r
 /**\r
   Get PCD value's size for POINTER type PCD.\r
   \r
-  The POINTER type PCD's value will be stored into a buffer in specificed size.\r
+  The POINTER type PCD's value will be stored into a buffer in specified size.\r
   The max size of this PCD's value is described in PCD's definition in DEC file.\r
 \r
   @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
   The max size of this PCD's value is described in PCD's definition in DEC file.\r
 \r
   @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
@@ -1157,11 +1164,11 @@ GetPtrTypeSize (
 \r
   SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r
 \r
 \r
   SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r
 \r
-  LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
+  LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);\r
 \r
   ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r
   \r
 \r
   ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r
   \r
-  SizeTable = Database->Init.SizeTable;\r
+  SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);\r
 \r
   *MaxSize = SizeTable[SizeTableIdx];\r
   //\r
 \r
   *MaxSize = SizeTable[SizeTableIdx];\r
   //\r
@@ -1170,8 +1177,9 @@ GetPtrTypeSize (
   //\r
   if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
       //\r
   //\r
   if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
       //\r
-      // We have only one entry for VPD enabled PCD entry:\r
+      // We have only two entry for VPD enabled PCD entry:\r
       // 1) MAX Size.\r
       // 1) MAX Size.\r
+      // 2) Current Size\r
       // We consider current size is equal to MAX size.\r
       //\r
       return *MaxSize;\r
       // We consider current size is equal to MAX size.\r
       //\r
       return *MaxSize;\r
@@ -1191,7 +1199,7 @@ GetPtrTypeSize (
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
-        if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r
+        if (SkuIdTable[1 + Index] == Database->SystemSkuId) {\r
           return SizeTable[SizeTableIdx + 1 + Index];\r
         }\r
       }\r
           return SizeTable[SizeTableIdx + 1 + Index];\r
         }\r
       }\r
@@ -1203,7 +1211,7 @@ GetPtrTypeSize (
 /**\r
   Set PCD value's size for POINTER type PCD.\r
   \r
 /**\r
   Set PCD value's size for POINTER type PCD.\r
   \r
-  The POINTER type PCD's value will be stored into a buffer in specificed size.\r
+  The POINTER type PCD's value will be stored into a buffer in specified size.\r
   The max size of this PCD's value is described in PCD's definition in DEC file.\r
 \r
   @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
   The max size of this PCD's value is described in PCD's definition in DEC file.\r
 \r
   @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table\r
@@ -1230,11 +1238,11 @@ SetPtrTypeSize (
   \r
   SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r
 \r
   \r
   SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);\r
 \r
-  LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
+  LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);\r
 \r
   ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r
 \r
   ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);\r
-  \r
-  SizeTable = Database->Init.SizeTable;\r
+\r
+  SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);\r
 \r
   MaxSize = SizeTable[SizeTableIdx];\r
   //\r
 \r
   MaxSize = SizeTable[SizeTableIdx];\r
   //\r
@@ -1270,7 +1278,7 @@ SetPtrTypeSize (
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
       //\r
       SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);\r
       for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
-        if (SkuIdTable[1 + Index] == Database->Init.SystemSkuId) {\r
+        if (SkuIdTable[1 + Index] == Database->SystemSkuId) {\r
           SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;\r
           return TRUE;\r
         }\r
           SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;\r
           return TRUE;\r
         }\r
index 20e442082ae042a3cbf3681a2e8f0404a1c8af13..8c2ab190a7dbec6e23a5ee2e219dc5d298822d76 100644 (file)
@@ -1,6 +1,7 @@
 ## @file\r
 # PCD PEIM produces PCD database to manage all dynamic PCD in PEI phase and install Pcd Ppi service.\r
 #\r
 ## @file\r
 # PCD PEIM produces PCD database to manage all dynamic PCD in PEI phase and install Pcd Ppi service.\r
 #\r
+# This version PCD PEIM depends on the external PCD database binary file, not built in PCD data base. \r
 # There are two PCD PPIs as follows:\r
 #   1) PCD_PPI \r
 #      It is EDKII implementation which support Dynamic/DynamicEx Pcds.\r
 # There are two PCD PPIs as follows:\r
 #   1) PCD_PPI \r
 #      It is EDKII implementation which support Dynamic/DynamicEx Pcds.\r
@@ -8,6 +9,10 @@
 #      It is defined by PI specification 1.2, Vol 3 which only support dynamicEx \r
 #      type Pcd.\r
 # For dynamicEx type PCD, it is compatible between PCD_PPI and EFI_PEI_PCD_PPI.\r
 #      It is defined by PI specification 1.2, Vol 3 which only support dynamicEx \r
 #      type Pcd.\r
 # For dynamicEx type PCD, it is compatible between PCD_PPI and EFI_PEI_PCD_PPI.\r
+# PCD PEIM driver will produce above two PPIs at same time.\r
+#\r
+# PCD database is generated as the separate binary image at build time. The binary image \r
+# will be intergrated into Firmware volume together with PCD driver. \r
 #\r
 # ////////////////////////////////////////////////////////////////////////////////\r
 # //                                                                            //\r
 #\r
 # ////////////////////////////////////////////////////////////////////////////////\r
 # //                                                                            //\r
@@ -58,7 +63,7 @@
 #      b) Variable Storage: \r
 #         - The PCD value is stored in variable area. \r
 #         - As default storage type, this type PCD could be used for PEI/DXE driver\r
 #      b) Variable Storage: \r
 #         - The PCD value is stored in variable area. \r
 #         - As default storage type, this type PCD could be used for PEI/DXE driver\r
-#           communication. But beside it, this type PCD could alsp be used to store \r
+#           communication. But beside it, this type PCD could also be used to store \r
 #           the value associate with a HII setting via variable interface.\r
 #         - In PEI phase, the PCD value could only be got but can not be set due \r
 #           to variable area is readonly.\r
 #           the value associate with a HII setting via variable interface.\r
 #         - In PEI phase, the PCD value could only be got but can not be set due \r
 #           to variable area is readonly.\r
 #    PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD\r
 #    database contains all PCDs used in PEI/DXE phase in memory.\r
 #    \r
 #    PCD information used in PEI phase or use in both PEI/DXE phase. And DXE PCD\r
 #    database contains all PCDs used in PEI/DXE phase in memory.\r
 #    \r
-#    Build tool will generate PCD database into some C structure and variable for \r
+#    Build tool will generate PCD database into the separate binary file for \r
 #    PEI/DXE PCD driver according to dynamic PCD section in platform DSC file. \r
 #    \r
 #    3.1 PcdPeim and PcdDxe\r
 #      PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver\r
 #    PEI/DXE PCD driver according to dynamic PCD section in platform DSC file. \r
 #    \r
 #    3.1 PcdPeim and PcdDxe\r
 #      PEI PCD database is maintained by PcdPeim driver run from flash. PcdPeim driver\r
-#      build guid hob in temporary memory and copy auto-generated C structure \r
+#      build guid hob in temporary memory and copy the binary data base from flash \r
 #      to temporary memory for PEI PCD database. \r
 #      DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,\r
 #      a new PCD database is allocated in boot-time memory which including all\r
 #      to temporary memory for PEI PCD database. \r
 #      DXE PCD database is maintained by PcdDxe driver.At entry point of PcdDxe driver,\r
 #      a new PCD database is allocated in boot-time memory which including all\r
 #       Based on local token number, PCD driver could fast determine PCD type, value\r
 #       type and get PCD entry from PCD database.\r
 #       \r
 #       Based on local token number, PCD driver could fast determine PCD type, value\r
 #       type and get PCD entry from PCD database.\r
 #       \r
-#    3.3 PCD Database C structure.\r
-#      PCD Database C structure is generated by build tools in PCD driver's autogen.h/\r
+#    3.3 PCD Database binary file\r
+#      PCD Database binary file will be created at build time as the standalone binary image. \r
+#      To understand the binary image layout, PCD Database C structure is still generated \r
+#      as comments by build tools in PCD driver's autogen.h/\r
 #      autogen.c file. In generated C structure, following information is stored:\r
 #      - ExMapTable: This table is used translate a binary dynamicex type PCD's \r
 #                    "tokenguid + token" to local token number.\r
 #      autogen.c file. In generated C structure, following information is stored:\r
 #      - ExMapTable: This table is used translate a binary dynamicex type PCD's \r
 #                    "tokenguid + token" to local token number.\r
 #                    token number" as array index to get PCD entry's offset fastly.\r
 #      - SizeTable:  This table stores the size information for all PCD entry.\r
 #      - GuidTable:  This table stores guid value for DynamicEx's token space,\r
 #                    token number" as array index to get PCD entry's offset fastly.\r
 #      - SizeTable:  This table stores the size information for all PCD entry.\r
 #      - GuidTable:  This table stores guid value for DynamicEx's token space,\r
-#                    HII type PCD's variable.\r
+#                    HII type PCD's variable GUID.\r
 #      - SkuIdTable: TBD\r
 #      - SystemSkuId: TBD\r
 #      - PCD value structure:  \r
 #      - SkuIdTable: TBD\r
 #      - SystemSkuId: TBD\r
 #      - PCD value structure:  \r
 #            - Variable GUID for HII type PCD\r
 #            - Token space GUID for dynamicex type PCD \r
 #    \r
 #            - Variable GUID for HII type PCD\r
 #            - Token space GUID for dynamicex type PCD \r
 #    \r
-#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   BASE_NAME                      = PcdPeim\r
   FILE_GUID                      = 9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50\r
   MODULE_TYPE                    = PEIM\r
   BASE_NAME                      = PcdPeim\r
   FILE_GUID                      = 9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50\r
   MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
+  VERSION_STRING                 = 4.0\r
   PCD_IS_DRIVER                  = PEI_PCD_DRIVER\r
   ENTRY_POINT                    = PcdPeimInit\r
 \r
   PCD_IS_DRIVER                  = PEI_PCD_DRIVER\r
   ENTRY_POINT                    = PcdPeimInit\r
 \r
   DebugLib\r
 \r
 [Guids]\r
   DebugLib\r
 \r
 [Guids]\r
-  gPcdDataBaseHobGuid                           ## PRODUCES  ## Hob\r
-  gPcdDataBaseHobGuid                           ## CONSUMES  ## Hob\r
+  ## PRODUCES            ## HOB\r
+  ## SOMETIMES_CONSUMES  ## HOB\r
+  gPcdDataBaseHobGuid                           \r
+  gPcdDataBaseSignatureGuid                     ## CONSUMES  ## UNDEFINED  # PCD database signature GUID.\r
 \r
 [Ppis]\r
 \r
 [Ppis]\r
-  gEfiPeiReadOnlyVariable2PpiGuid               ## CONSUMES\r
+  gEfiPeiReadOnlyVariable2PpiGuid               ## SOMETIMES_CONSUMES\r
   gPcdPpiGuid                                   ## PRODUCES\r
   gEfiPeiPcdPpiGuid                             ## PRODUCES\r
   \r
 [FeaturePcd]\r
   gPcdPpiGuid                                   ## PRODUCES\r
   gEfiPeiPcdPpiGuid                             ## PRODUCES\r
   \r
 [FeaturePcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable  ## CONSUMES\r
 \r
 [Pcd]\r
 \r
 [Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry || gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry || gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## SOMETIMES_CONSUMES\r
 \r
 [Depex]\r
   TRUE\r
 \r
 [Depex]\r
   TRUE\r
index e5d5f0c2085fbc49af613eb3bff95f8fb80bf443..47e87d3bcddba3265c67458da167a7a3a2ced783 100644 (file)
@@ -2,7 +2,7 @@
   The driver internal functions are implmented here.\r
   They build Pei PCD database, and provide access service to PCD database.\r
 \r
   The driver internal functions are implmented here.\r
   They build Pei PCD database, and provide access service to PCD database.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -43,25 +43,30 @@ PeiRegisterCallBackWorker (
   PCD_PPI_CALLBACK        Compare;\r
   PCD_PPI_CALLBACK        Assign;\r
   UINT32                  LocalTokenNumber;\r
   PCD_PPI_CALLBACK        Compare;\r
   PCD_PPI_CALLBACK        Assign;\r
   UINT32                  LocalTokenNumber;\r
+  UINT32                  LocalTokenCount;\r
+  UINTN                   PeiNexTokenNumber;\r
   UINTN                   TokenNumber;\r
   UINTN                   Idx;\r
   UINTN                   TokenNumber;\r
   UINTN                   Idx;\r
+  PEI_PCD_DATABASE        *PeiPcdDb;\r
+\r
+  PeiPcdDb          = GetPcdDatabase();\r
+  LocalTokenCount   = PeiPcdDb->LocalTokenCount;\r
+  PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;\r
 \r
   if (Guid == NULL) {\r
     TokenNumber = ExTokenNumber;\r
 \r
   if (Guid == NULL) {\r
     TokenNumber = ExTokenNumber;\r
-\r
     //\r
     // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
     // We have to decrement TokenNumber by 1 to make it usable\r
     // as the array index.\r
     //\r
     TokenNumber--;\r
     //\r
     // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
     // We have to decrement TokenNumber by 1 to make it usable\r
     // as the array index.\r
     //\r
     TokenNumber--;\r
-    ASSERT (TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1);\r
+    ASSERT (TokenNumber + 1 < (PeiNexTokenNumber + 1));\r
   } else {\r
     TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);\r
     if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
       return EFI_NOT_FOUND;\r
     }\r
   } else {\r
     TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);\r
     if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
       return EFI_NOT_FOUND;\r
     }\r
-    \r
     //\r
     // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
     // We have to decrement TokenNumber by 1 to make it usable\r
     //\r
     // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
     // We have to decrement TokenNumber by 1 to make it usable\r
@@ -71,11 +76,11 @@ PeiRegisterCallBackWorker (
     // EBC compiler is very choosy. It may report warning about comparison\r
     // between UINTN and 0 . So we add 1 in each size of the \r
     // comparison.\r
     // EBC compiler is very choosy. It may report warning about comparison\r
     // between UINTN and 0 . So we add 1 in each size of the \r
     // comparison.\r
-    ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
+    ASSERT ((TokenNumber + 1) < (LocalTokenCount + 1));\r
   }\r
 \r
 \r
   }\r
 \r
 \r
-  LocalTokenNumber = GetPcdDatabase()->Init.LocalTokenNumberTable[TokenNumber];\r
+  LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);\r
 \r
   //\r
   // We don't support SET for HII and VPD type PCD entry in PEI phase.\r
 \r
   //\r
   // We don't support SET for HII and VPD type PCD entry in PEI phase.\r
@@ -105,29 +110,74 @@ PeiRegisterCallBackWorker (
 \r
 }\r
 \r
 \r
 }\r
 \r
+\r
+/**\r
+  Find the Pcd database. \r
+\r
+  @param  FileHandle  Handle of the file the external PCD database binary located.\r
+\r
+  @retval The base address of external PCD database binary.\r
+  @retval NULL         Return NULL if not find.\r
+**/\r
+VOID *\r
+LocateExPcdBinary (\r
+  IN EFI_PEI_FILE_HANDLE    FileHandle\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  VOID                  *PcdDb;\r
+\r
+  PcdDb       = NULL;\r
+\r
+  ASSERT (FileHandle != NULL);\r
+\r
+  Status = PeiServicesFfsFindSectionData (EFI_SECTION_RAW, FileHandle, &PcdDb);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Check the first bytes (Header Signature Guid) and build version.\r
+  //\r
+  if (!CompareGuid (PcdDb, &gPcdDataBaseSignatureGuid) ||\r
+      (((PEI_PCD_DATABASE *) PcdDb)->BuildVersion != PCD_SERVICE_PEIM_VERSION)) {\r
+    ASSERT (FALSE);\r
+  }\r
+  return PcdDb;\r
+}\r
+\r
+\r
 /**\r
   The function builds the PCD database.\r
 /**\r
   The function builds the PCD database.\r
+\r
+  @param  FileHandle  Handle of the file the external PCD database binary located.\r
+\r
 **/\r
 VOID\r
 BuildPcdDatabase (\r
 **/\r
 VOID\r
 BuildPcdDatabase (\r
-  VOID\r
+  IN EFI_PEI_FILE_HANDLE    FileHandle\r
   )\r
 {\r
   )\r
 {\r
-  PEI_PCD_DATABASE  *Database;\r
-  VOID              *CallbackFnTable;\r
-  UINTN             SizeOfCallbackFnTable;\r
-  \r
-  Database = BuildGuidHob (&gPcdDataBaseHobGuid, sizeof (PEI_PCD_DATABASE));\r
+  PEI_PCD_DATABASE       *Database;\r
+  PEI_PCD_DATABASE       *PeiPcdDbBinary;\r
+  VOID                   *CallbackFnTable;\r
+  UINTN                  SizeOfCallbackFnTable;\r
+\r
+  //\r
+  // Locate the external PCD database binary for one section of current FFS\r
+  //\r
+  PeiPcdDbBinary = LocateExPcdBinary (FileHandle);\r
 \r
 \r
-  ZeroMem (Database, sizeof (PEI_PCD_DATABASE));\r
+  ASSERT(PeiPcdDbBinary != NULL);\r
+\r
+  Database = BuildGuidHob (&gPcdDataBaseHobGuid, PeiPcdDbBinary->Length + PeiPcdDbBinary->UninitDataBaseSize);\r
+\r
+  ZeroMem (Database, PeiPcdDbBinary->Length  + PeiPcdDbBinary->UninitDataBaseSize);\r
 \r
   //\r
 \r
   //\r
-  // gPEIPcdDbInit is smaller than PEI_PCD_DATABASE\r
+  // PeiPcdDbBinary is smaller than Database\r
   //\r
   //\r
-  \r
-  CopyMem (&Database->Init, &gPEIPcdDbInit, sizeof (gPEIPcdDbInit));\r
+  CopyMem (Database, PeiPcdDbBinary, PeiPcdDbBinary->Length);\r
 \r
 \r
-  SizeOfCallbackFnTable = PEI_LOCAL_TOKEN_NUMBER * sizeof (PCD_PPI_CALLBACK) * PcdGet32 (PcdMaxPeiPcdCallBackNumberPerPcdEntry);\r
+  SizeOfCallbackFnTable = Database->LocalTokenCount * sizeof (PCD_PPI_CALLBACK) * PcdGet32 (PcdMaxPeiPcdCallBackNumberPerPcdEntry);\r
 \r
   CallbackFnTable = BuildGuidHob (&gEfiCallerIdGuid, SizeOfCallbackFnTable);\r
   \r
 \r
   CallbackFnTable = BuildGuidHob (&gEfiCallerIdGuid, SizeOfCallbackFnTable);\r
   \r
@@ -215,6 +265,7 @@ GetSkuEnabledTokenNumber (
   SKU_ID                *SkuIdTable;\r
   INTN                  Index;\r
   UINT8                 *Value;\r
   SKU_ID                *SkuIdTable;\r
   INTN                  Index;\r
   UINT8                 *Value;\r
+  BOOLEAN               FoundSku;\r
 \r
   PeiPcdDb = GetPcdDatabase ();\r
 \r
 \r
   PeiPcdDb = GetPcdDatabase ();\r
 \r
@@ -223,13 +274,30 @@ GetSkuEnabledTokenNumber (
   SkuHead     = (SKU_HEAD *) ((UINT8 *)PeiPcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));\r
   Value       = (UINT8 *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuDataStartOffset));\r
   SkuIdTable  = (SKU_ID *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuIdTableOffset));\r
   SkuHead     = (SKU_HEAD *) ((UINT8 *)PeiPcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));\r
   Value       = (UINT8 *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuDataStartOffset));\r
   SkuIdTable  = (SKU_ID *) ((UINT8 *)PeiPcdDb + (SkuHead->SkuIdTableOffset));\r
-        \r
+\r
+  //\r
+  // Find the current system's SKU ID entry in SKU ID table.\r
+  //\r
+  FoundSku = FALSE;\r
   for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
   for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
-    if (PeiPcdDb->Init.SystemSkuId == SkuIdTable[Index + 1]) {\r
+    if (PeiPcdDb->SystemSkuId == SkuIdTable[Index + 1]) {\r
+      FoundSku = TRUE;\r
       break;\r
     }\r
   }\r
 \r
       break;\r
     }\r
   }\r
 \r
+  //\r
+  // Find the default SKU ID entry in SKU ID table.\r
+  //\r
+  if(!FoundSku) {\r
+    for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
+      if (0 == SkuIdTable[Index + 1]) {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  ASSERT (Index < SkuIdTable[0]);\r
+\r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
       Value = (UINT8 *) &(((VPD_HEAD *) Value)[Index]);\r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
       Value = (UINT8 *) &(((VPD_HEAD *) Value)[Index]);\r
@@ -238,14 +306,18 @@ GetSkuEnabledTokenNumber (
     case PCD_TYPE_HII:\r
       Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);\r
     case PCD_TYPE_HII:\r
       Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII);\r
-      \r
+\r
+    case PCD_TYPE_HII|PCD_TYPE_STRING:\r
+      Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[Index]);\r
+      return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_HII | PCD_TYPE_STRING);\r
+\r
     case PCD_TYPE_STRING:\r
       Value = (UINT8 *) &(((STRING_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);\r
 \r
     case PCD_TYPE_DATA:\r
       Value += Size * Index;\r
     case PCD_TYPE_STRING:\r
       Value = (UINT8 *) &(((STRING_HEAD *) Value)[Index]);\r
       return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_STRING);\r
 \r
     case PCD_TYPE_DATA:\r
       Value += Size * Index;\r
-      return (UINT32) (Value - (UINT8 *) PeiPcdDb);\r
+      return (UINT32) ((Value - (UINT8 *) PeiPcdDb) | PCD_TYPE_DATA);\r
 \r
     default:\r
       ASSERT (FALSE);\r
 \r
     default:\r
       ASSERT (FALSE);\r
@@ -281,6 +353,8 @@ InvokeCallbackOnSet (
   EFI_HOB_GUID_TYPE   *GuidHob;\r
   PCD_PPI_CALLBACK    *CallbackTable;\r
   UINTN               Idx;\r
   EFI_HOB_GUID_TYPE   *GuidHob;\r
   PCD_PPI_CALLBACK    *CallbackTable;\r
   UINTN               Idx;\r
+  PEI_PCD_DATABASE    *PeiPcdDb;\r
+  UINT32              LocalTokenCount;\r
 \r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
 \r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
@@ -288,12 +362,15 @@ InvokeCallbackOnSet (
   // as the array index.\r
   //\r
   TokenNumber--;\r
   // as the array index.\r
   //\r
   TokenNumber--;\r
-  \r
+\r
+  PeiPcdDb        = GetPcdDatabase ();\r
+  LocalTokenCount = PeiPcdDb->LocalTokenCount;\r
+\r
   if (Guid == NULL) {\r
     // EBC compiler is very choosy. It may report warning about comparison\r
     // between UINTN and 0 . So we add 1 in each size of the \r
     // comparison.\r
   if (Guid == NULL) {\r
     // EBC compiler is very choosy. It may report warning about comparison\r
     // between UINTN and 0 . So we add 1 in each size of the \r
     // comparison.\r
-    ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
+    ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));\r
   }\r
 \r
   GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid);\r
   }\r
 \r
   GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid);\r
@@ -359,11 +436,13 @@ SetWorker (
   )\r
 {\r
   UINT32              LocalTokenNumber;\r
   )\r
 {\r
   UINT32              LocalTokenNumber;\r
+  UINTN               PeiNexTokenNumber;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   STRING_HEAD         StringTableIdx;\r
   UINTN               Offset;\r
   VOID                *InternalData;\r
   UINTN               MaxSize;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   STRING_HEAD         StringTableIdx;\r
   UINTN               Offset;\r
   VOID                *InternalData;\r
   UINTN               MaxSize;\r
+  UINT32              LocalTokenCount;\r
 \r
   if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) {\r
     return EFI_UNSUPPORTED;\r
 \r
   if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) {\r
     return EFI_UNSUPPORTED;\r
@@ -375,15 +454,15 @@ SetWorker (
   // as the array index.\r
   //\r
   TokenNumber--;\r
   // as the array index.\r
   //\r
   TokenNumber--;\r
+  PeiPcdDb        = GetPcdDatabase ();\r
+  LocalTokenCount = PeiPcdDb->LocalTokenCount;\r
 \r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
 \r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
-    \r
-  PeiPcdDb = GetPcdDatabase ();\r
+  ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));\r
 \r
 \r
-  LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];\r
+  LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);\r
 \r
   if (PtrType) {\r
     //\r
 \r
   if (PtrType) {\r
     //\r
@@ -405,7 +484,8 @@ SetWorker (
   // For Dynamic EX PCD entry, we have invoked the callback function for Dynamic EX\r
   // type PCD entry in ExSetWorker.\r
   //\r
   // For Dynamic EX PCD entry, we have invoked the callback function for Dynamic EX\r
   // type PCD entry in ExSetWorker.\r
   //\r
-  if (TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) {\r
+  PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;\r
+  if (TokenNumber + 1 < PeiNexTokenNumber + 1) {\r
     InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);\r
   }\r
 \r
     InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);\r
   }\r
 \r
@@ -433,7 +513,7 @@ SetWorker (
     case PCD_TYPE_STRING:\r
       if (SetPtrTypeSize (TokenNumber, Size, PeiPcdDb)) {\r
         StringTableIdx = *((STRING_HEAD *)InternalData);\r
     case PCD_TYPE_STRING:\r
       if (SetPtrTypeSize (TokenNumber, Size, PeiPcdDb)) {\r
         StringTableIdx = *((STRING_HEAD *)InternalData);\r
-        CopyMem (&PeiPcdDb->Init.StringTable[StringTableIdx], Data, *Size);\r
+        CopyMem ((UINT8 *)PeiPcdDb + PeiPcdDb->StringTableOffset + StringTableIdx, Data, *Size);\r
         return EFI_SUCCESS;\r
       } else {\r
         return EFI_INVALID_PARAMETER;\r
         return EFI_SUCCESS;\r
       } else {\r
         return EFI_INVALID_PARAMETER;\r
@@ -503,7 +583,7 @@ ExSetValueWorker (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Set value for a dynamic PCD entry.\r
+  Set value for a dynamic-ex PCD entry.\r
   \r
   This routine find the local token number according to dynamic-ex PCD's token \r
   space guid and token number firstly, and invoke callback function if this PCD\r
   \r
   This routine find the local token number according to dynamic-ex PCD's token \r
   space guid and token number firstly, and invoke callback function if this PCD\r
@@ -598,6 +678,7 @@ GetWorker (
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   UINT32              LocalTokenNumber;\r
   UINTN               MaxSize;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   UINT32              LocalTokenNumber;\r
   UINTN               MaxSize;\r
+  UINT32              LocalTokenCount;\r
 \r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
 \r
   //\r
   // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
@@ -606,16 +687,17 @@ GetWorker (
   //\r
   TokenNumber--;\r
 \r
   //\r
   TokenNumber--;\r
 \r
+  PeiPcdDb        = GetPcdDatabase ();\r
+  LocalTokenCount = PeiPcdDb->LocalTokenCount;\r
+\r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
   // EBC compiler is very choosy. It may report warning about comparison\r
   // between UINTN and 0 . So we add 1 in each size of the \r
   // comparison.\r
-  ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
+  ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));\r
 \r
   ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));\r
 \r
 \r
   ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));\r
 \r
-  PeiPcdDb        = GetPcdDatabase ();\r
-\r
-  LocalTokenNumber = PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber];\r
+  LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);\r
 \r
   if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
     if (GetSize == 0) {\r
 \r
   if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
     if (GetSize == 0) {\r
@@ -627,8 +709,8 @@ GetWorker (
   }\r
 \r
   Offset      = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
   }\r
 \r
   Offset      = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
-  StringTable = PeiPcdDb->Init.StringTable;\r
-  \r
+  StringTable = (UINT8 *)PeiPcdDb + PeiPcdDb->StringTableOffset;\r
+\r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
     {\r
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
     {\r
@@ -642,7 +724,7 @@ GetWorker (
     {\r
       VariableHead = (VARIABLE_HEAD *) ((UINT8 *)PeiPcdDb + Offset);\r
       \r
     {\r
       VariableHead = (VARIABLE_HEAD *) ((UINT8 *)PeiPcdDb + Offset);\r
       \r
-      Guid = &(PeiPcdDb->Init.GuidTable[VariableHead->GuidTableIndex]);\r
+      Guid = (EFI_GUID *) ((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset) + VariableHead->GuidTableIndex;\r
       Name = (UINT16*)&StringTable[VariableHead->StringIndex];\r
 \r
       Status = GetHiiVariable (Guid, Name, &Data, &DataSize);\r
       Name = (UINT16*)&StringTable[VariableHead->StringIndex];\r
 \r
       Status = GetHiiVariable (Guid, Name, &Data, &DataSize);\r
@@ -681,16 +763,16 @@ GetWorker (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
+  Get Token Number according to dynamic-ex PCD's {token space guid:token number}\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
-  space guid: token number} to local token number.\r
+  space guid: token number} to Token Number.\r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
-  @param ExTokenNumber   EDES_TODO: Add parameter description\r
+  @param ExTokenNumber   Dynamic-ex PCD token number.\r
 \r
 \r
-  @return local token number for dynamic-ex PCD.\r
+  @return Token Number for dynamic-ex PCD.\r
 \r
 **/\r
 UINTN           \r
 \r
 **/\r
 UINTN           \r
@@ -707,11 +789,11 @@ GetExPcdTokenNumber (
   PEI_PCD_DATABASE    *PeiPcdDb;\r
 \r
   PeiPcdDb    = GetPcdDatabase();\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
 \r
   PeiPcdDb    = GetPcdDatabase();\r
-  \r
-  ExMap       = PeiPcdDb->Init.ExMapTable;\r
-  GuidTable   = PeiPcdDb->Init.GuidTable;\r
 \r
 \r
-  MatchGuid = ScanGuid (GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);\r
+  ExMap       = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);\r
+  GuidTable   = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);\r
+\r
+  MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(EFI_GUID), Guid);\r
   //\r
   // We need to ASSERT here. If GUID can't be found in GuidTable, this is a\r
   // error in the BUILD system.\r
   //\r
   // We need to ASSERT here. If GUID can't be found in GuidTable, this is a\r
   // error in the BUILD system.\r
@@ -720,10 +802,10 @@ GetExPcdTokenNumber (
   \r
   MatchGuidIdx = MatchGuid - GuidTable;\r
   \r
   \r
   MatchGuidIdx = MatchGuid - GuidTable;\r
   \r
-  for (Index = 0; Index < PEI_EXMAPPING_TABLE_SIZE; Index++) {\r
+  for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {\r
     if ((ExTokenNumber == ExMap[Index].ExTokenNumber) && \r
         (MatchGuidIdx == ExMap[Index].ExGuidIndex)) {\r
     if ((ExTokenNumber == ExMap[Index].ExTokenNumber) && \r
         (MatchGuidIdx == ExMap[Index].ExGuidIndex)) {\r
-      return ExMap[Index].LocalTokenNumber;\r
+      return ExMap[Index].TokenNumber;\r
     }\r
   }\r
   \r
     }\r
   }\r
   \r
@@ -750,7 +832,7 @@ GetPcdDatabase (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Get SKU ID tabble from PCD database.\r
+  Get SKU ID table from PCD database.\r
 \r
   @param LocalTokenNumberTableIdx Index of local token number in token number table.\r
   @param Database                 PCD database.\r
 \r
   @param LocalTokenNumberTableIdx Index of local token number in token number table.\r
   @param Database                 PCD database.\r
@@ -767,7 +849,7 @@ GetSkuIdArray (
   SKU_HEAD *SkuHead;\r
   UINTN     LocalTokenNumber;\r
 \r
   SKU_HEAD *SkuHead;\r
   UINTN     LocalTokenNumber;\r
 \r
-  LocalTokenNumber = Database->Init.LocalTokenNumberTable[LocalTokenNumberTableIdx];\r
+  LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);\r
 \r
   ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);\r
 \r
 \r
   ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) != 0);\r
 \r
@@ -793,14 +875,14 @@ GetSizeTableIndex (
   )\r
 {\r
   UINTN       Index;\r
   )\r
 {\r
   UINTN       Index;\r
-  UINTN        SizeTableIdx;\r
+  UINTN       SizeTableIdx;\r
   UINTN       LocalTokenNumber;\r
   SKU_ID      *SkuIdTable;\r
   \r
   SizeTableIdx = 0;\r
 \r
   UINTN       LocalTokenNumber;\r
   SKU_ID      *SkuIdTable;\r
   \r
   SizeTableIdx = 0;\r
 \r
-  for (Index=0; Index<LocalTokenNumberTableIdx; Index++) {\r
-    LocalTokenNumber = Database->Init.LocalTokenNumberTable[Index];\r
+  for (Index = 0; Index < LocalTokenNumberTableIdx; Index++) {\r
+    LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + Index);\r
 \r
     if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) {\r
       //\r
 \r
     if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) {\r
       //\r
@@ -809,11 +891,12 @@ GetSizeTableIndex (
       //\r
       if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
           //\r
       //\r
       if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {\r
           //\r
-          // We have only one entry for VPD enabled PCD entry:\r
+          // We have only two entry for VPD enabled PCD entry:\r
           // 1) MAX Size.\r
           // 1) MAX Size.\r
-          // We consider current size is equal to MAX size.\r
+          // 2) Current Size\r
+          // Current size is equal to MAX size.\r
           //\r
           //\r
-          SizeTableIdx++;\r
+          SizeTableIdx += 2;\r
       } else {\r
         if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r
           //\r
       } else {\r
         if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {\r
           //\r
index 2847686259799f4de749b9cb0d1a6d020bcb2d1d..1928dcb928ea44270fd7a91637a3f33a332d7fc3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The internal header file declares the private functions used by PeiPcd driver.\r
 \r
 /** @file\r
   The internal header file declares the private functions used by PeiPcd driver.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Ppi/Pcd.h>\r
 #include <Ppi/PiPcd.h>\r
 #include <Guid/PcdDataBaseHobGuid.h>\r
 #include <Ppi/Pcd.h>\r
 #include <Ppi/PiPcd.h>\r
 #include <Guid/PcdDataBaseHobGuid.h>\r
+#include <Guid/PcdDataBaseSignatureGuid.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/BaseLib.h>\r
@@ -33,7 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 // Please make sure the PCD Serivce PEIM Version is consistent with\r
 // the version of the generated PEIM PCD Database by build tool.\r
 //\r
 // Please make sure the PCD Serivce PEIM Version is consistent with\r
 // the version of the generated PEIM PCD Database by build tool.\r
 //\r
-#define PCD_SERVICE_PEIM_VERSION      2\r
+#define PCD_SERVICE_PEIM_VERSION      4\r
 \r
 //\r
 // PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.\r
 \r
 //\r
 // PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.\r
@@ -896,16 +897,16 @@ typedef struct {
 } EX_PCD_ENTRY_ATTRIBUTE;\r
 \r
 /**\r
 } EX_PCD_ENTRY_ATTRIBUTE;\r
 \r
 /**\r
-  Get local token number according to dynamic-ex PCD's {token space guid:token number}\r
+  Get Token Number according to dynamic-ex PCD's {token space guid:token number}\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
 \r
   A dynamic-ex type PCD, developer must provide pair of token space guid: token number\r
   in DEC file. PCD database maintain a mapping table that translate pair of {token\r
-  space guid: token number} to local token number.\r
+  space guid: token number} to Token Number.\r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   @param ExTokenNumber   Token number for dynamic-ex PCD.\r
 \r
   \r
   @param Guid            Token space guid for dynamic-ex PCD entry.\r
   @param ExTokenNumber   Token number for dynamic-ex PCD.\r
 \r
-  @return local token number for dynamic-ex PCD.\r
+  @return Token Number for dynamic-ex PCD.\r
 \r
 **/\r
 UINTN\r
 \r
 **/\r
 UINTN\r
@@ -938,10 +939,13 @@ PeiRegisterCallBackWorker (
 \r
 /**\r
   The function builds the PCD database.\r
 \r
 /**\r
   The function builds the PCD database.\r
+\r
+  @param  FileHandle  Handle of the file the external PCD database binary located.\r
+\r
 **/\r
 VOID\r
 BuildPcdDatabase (\r
 **/\r
 VOID\r
 BuildPcdDatabase (\r
-  VOID\r
+  IN EFI_PEI_FILE_HANDLE    FileHandle\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -1015,10 +1019,5 @@ SetPtrTypeSize (
   IN          PEI_PCD_DATABASE  *Database\r
   );\r
 \r
   IN          PEI_PCD_DATABASE  *Database\r
   );\r
 \r
-//\r
-// The init Database created by PCD Database generation tool\r
-//\r
-extern PEI_PCD_DATABASE_INIT gPEIPcdDbInit;\r
-\r
 #endif\r
 \r
 #endif\r
 \r
index 8deb6f758e07126b61abac1d677bc0f332974e4b..1fc584060f32965d6efbc48d72c78716818e19d5 100644 (file)
@@ -14,7 +14,7 @@
   There are no restrictions on the use of FeaturePcd(), FixedPcdGetXX(),\r
   PatchPcdGetXX(), and PatchPcdSetXX().\r
 \r
   There are no restrictions on the use of FeaturePcd(), FixedPcdGetXX(),\r
   PatchPcdGetXX(), and PatchPcdSetXX().\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -532,6 +532,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define PcdSetBool(TokenName, Value)        _PCD_SET_MODE_BOOL_##TokenName  ((Value))\r
 \r
 \r
 #define PcdSetBool(TokenName, Value)        _PCD_SET_MODE_BOOL_##TokenName  ((Value))\r
 \r
 \r
+/**\r
+  Retrieves a token number based on a GUID and a token name.\r
+\r
+  Returns the token number for the token specified by Guid and TokenName.\r
+\r
+  @param   Guid        Pointer to a 128-bit unique value that designates \r
+                       which namespace to retrieve a value from.\r
+  @param   TokenName   The name of the PCD token to retrieve a current value for.                 \r
+\r
+  @return  Return the token number.\r
+\r
+**/\r
+#define PcdTokenEx(Guid,TokenName)  _PCD_TOKEN_EX_##TokenName(Guid)\r
+\r
 /**\r
   Retrieves an 8-bit PCD token value based on a GUID and a token name.\r
 \r
 /**\r
   Retrieves an 8-bit PCD token value based on a GUID and a token name.\r
 \r
@@ -548,8 +562,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return  An 8-bit PCD token value.\r
 \r
 **/\r
   @return  An 8-bit PCD token value.\r
 \r
 **/\r
-#define PcdGetEx8(Guid, TokenName)          LibPcdGetEx8    ((Guid), _PCD_TOKEN_##TokenName)\r
-\r
+#define PcdGetEx8(Guid, TokenName)          LibPcdGetEx8 ((Guid), PcdTokenEx(Guid,TokenName))\r
 \r
 /**\r
   Retrieves a 16-bit PCD token value based on a GUID and a token name.\r
 \r
 /**\r
   Retrieves a 16-bit PCD token value based on a GUID and a token name.\r
@@ -567,7 +580,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return  A 16-bit PCD token value.\r
 \r
 **/\r
   @return  A 16-bit PCD token value.\r
 \r
 **/\r
-#define PcdGetEx16(Guid, TokenName)         LibPcdGetEx16   ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetEx16(Guid, TokenName)         LibPcdGetEx16 ((Guid), PcdTokenEx(Guid,TokenName))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -586,7 +599,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return  A 32-bit PCD token value.\r
 \r
 **/\r
   @return  A 32-bit PCD token value.\r
 \r
 **/\r
-#define PcdGetEx32(Guid, TokenName)         LibPcdGetEx32   ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetEx32(Guid, TokenName)         LibPcdGetEx32 ((Guid), PcdTokenEx(Guid,TokenName))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -605,7 +618,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return  A 64-bit PCD token value.\r
 \r
 **/\r
   @return  A 64-bit PCD token value.\r
 \r
 **/\r
-#define PcdGetEx64(Guid, TokenName)         LibPcdGetEx64   ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetEx64(Guid, TokenName)         LibPcdGetEx64 ((Guid), PcdTokenEx(Guid,TokenName))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -624,7 +637,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return  A pointer to a PCD token buffer.\r
 \r
 **/\r
   @return  A pointer to a PCD token buffer.\r
 \r
 **/\r
-#define PcdGetExPtr(Guid, TokenName)        LibPcdGetExPtr  ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetExPtr(Guid, TokenName)        LibPcdGetExPtr ((Guid), PcdTokenEx(Guid,TokenName))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -643,7 +656,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return  A Boolean PCD token value.\r
 \r
 **/\r
   @return  A Boolean PCD token value.\r
 \r
 **/\r
-#define PcdGetExBool(Guid, TokenName)       LibPcdGetExBool ((Guid), _PCD_TOKEN_##TokenName)\r
+#define PcdGetExBool(Guid, TokenName)       LibPcdGetExBool  ((Guid), PcdTokenEx(Guid,TokenName))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -663,7 +676,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return Return the Value that was set.\r
 \r
 **/\r
   @return Return the Value that was set.\r
 \r
 **/\r
-#define PcdSetEx8(Guid, TokenName, Value)   LibPcdSetEx8   ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetEx8(Guid, TokenName, Value)   LibPcdSetEx8   ((Guid), PcdTokenEx(Guid,TokenName), (Value))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -683,7 +696,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return Return the Value that was set.\r
 \r
 **/\r
   @return Return the Value that was set.\r
 \r
 **/\r
-#define PcdSetEx16(Guid, TokenName, Value)  LibPcdSetEx16  ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetEx16(Guid, TokenName, Value)  LibPcdSetEx16  ((Guid), PcdTokenEx(Guid,TokenName), (Value))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -703,7 +716,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return Return the Value that was set.\r
 \r
 **/\r
   @return Return the Value that was set.\r
 \r
 **/\r
-#define PcdSetEx32(Guid, TokenName, Value)  LibPcdSetEx32  ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetEx32(Guid, TokenName, Value)  LibPcdSetEx32  ((Guid), PcdTokenEx(Guid,TokenName), (Value))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -723,7 +736,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return Return the Value that was set.\r
 \r
 **/\r
   @return Return the Value that was set.\r
 \r
 **/\r
-#define PcdSetEx64(Guid, TokenName, Value)  LibPcdSetEx64  ((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+#define PcdSetEx64(Guid, TokenName, Value)  LibPcdSetEx64  ((Guid), PcdTokenEx(Guid,TokenName), (Value))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -752,7 +765,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 #define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \\r
 \r
 **/\r
 #define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \\r
-                                            LibPcdSetExPtr ((Guid), _PCD_TOKEN_##TokenName, (SizeOfBuffer), (Buffer))\r
+                                            LibPcdSetExPtr ((Guid), PcdTokenEx(Guid,TokenName), (SizeOfBuffer), (Buffer))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -773,7 +786,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/                                         \r
 #define PcdSetExBool(Guid, TokenName, Value) \\r
 \r
 **/                                         \r
 #define PcdSetExBool(Guid, TokenName, Value) \\r
-                                            LibPcdSetExBool((Guid), _PCD_TOKEN_##TokenName, (Value))\r
+                                            LibPcdSetExBool((Guid), PcdTokenEx(Guid,TokenName), (Value))\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
index da250a59ed648b3f4e462493189e59a2e19ca7d8..79e9c3e971ce4b2731030c5cd7ae89db8935783b 100644 (file)
@@ -6,7 +6,7 @@
   The interfaces for dynamic type PCD do not require the token space guid as parameter,\r
   but interfaces for dynamic-ex type PCD require token space guid as parameter.\r
 \r
   The interfaces for dynamic type PCD do not require the token space guid as parameter,\r
   but interfaces for dynamic-ex type PCD require token space guid as parameter.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -775,10 +775,8 @@ EFI_STATUS
                                is being made to retrieve tokens from the default token space.\r
   @param[in, out]  TokenNumber A pointer to the PCD token number to use to find the subsequent token number.\r
                    \r
                                is being made to retrieve tokens from the default token space.\r
   @param[in, out]  TokenNumber A pointer to the PCD token number to use to find the subsequent token number.\r
                    \r
-  @retval EFI_SUCCESS   The PCD service has retrieved the next valid token number. \r
-                        Or the input token number is already the last valid token number in the PCD database. \r
-                        In the later case, *TokenNumber is updated with the value of 0.\r
-  @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r
+  @retval EFI_SUCCESS   The PCD service has retrieved the next valid token number.\r
+  @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.\r
 \r
 **/\r
 typedef \r
 \r
 **/\r
 typedef \r
@@ -793,25 +791,17 @@ EFI_STATUS
 /**\r
   Retrieves the next valid PCD token namespace for a given namespace.\r
 \r
 /**\r
   Retrieves the next valid PCD token namespace for a given namespace.\r
 \r
-  If *Guid is NULL, then the GUID of the first token space of the \r
-  current platform is assigned to *Guid the function return EFI_SUCCESS. \r
-  If  *Guid is NULL  and there is no namespace exist in the platform other than the default \r
-  (NULL) tokennamespace, *Guid is unchanged and the function return EFI_SUCCESS. \r
-  If this input token namespace is the last namespace on the platform, \r
-  *Guid will be assigned to NULL and the function return EFI_SUCCESS.\r
-\r
-  @param[in, out]  Guid An indirect pointer to EFI_GUID.  On input it designates a known \r
-                        token namespace from which the search will start. On output, it designates \r
-                        the next valid token namespace on the platform. If the input token namespace \r
-                        does not exist on the platform, an error is returned, and the value of *Guid is \r
-                        undefined.\r
-\r
-  @retval EFI_SUCCESS  The PCD service has retrieved the next valid token namespace. \r
-                        Or the input token namespace is already the last valid token \r
-                        number in the PCD database. In the later case, *Guid is updated \r
-                        with the value of NULL. Or the input token name space is NULL and there \r
-                        is no valid token namespace other than the default namespace (NULL).\r
-  @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.\r
+  Gets the next valid token namespace for a given namespace. This is useful to traverse the valid\r
+  token namespaces on a platform.\r
+\r
+  @param[in, out]   Guid    An indirect pointer to EFI_GUID. On input it designates a known token\r
+                            namespace from which the search will start. On output, it designates the next valid\r
+                            token namespace on the platform. If *Guid is NULL, then the GUID of the first token\r
+                            space of the current platform is returned. If the search cannot locate the next valid\r
+                            token namespace, an error is returned and the value of *Guid is undefined.\r
\r
+  @retval  EFI_SUCCESS      The PCD service retrieved the value requested.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the next valid token namespace.\r
 \r
 **/\r
 typedef\r
 \r
 **/\r
 typedef\r
index d116dc230f4249dc9eb5ea8be26974c7c9a13ca1..4698ecc3ada54a793f8351f5ae4eb1ddc4c0419d 100644 (file)
@@ -1,18 +1,17 @@
 /** @file\r
 /** @file\r
-  Platform Configuration Database (PCD) Protocol defined in PI 1.2 Vol3\r
+  Platform Configuration Database (PCD) PPI defined in PI 1.2 Vol3\r
 \r
   A platform database that contains a variety of current platform settings or\r
   directives that can be accessed by a driver or application.\r
 \r
   A platform database that contains a variety of current platform settings or\r
   directives that can be accessed by a driver or application.\r
-  PI PCD protocol only provide the accessing interfaces for Dynamic-Ex type PCD.\r
+  PI PCD ppi only provide the accessing interfaces for Dynamic-Ex type PCD.\r
 \r
 \r
-  Callers to this protocol must be at a TPL_APPLICATION task priority level.\r
   This is the base PCD service API that provides an abstraction for accessing configuration content in\r
   the platform. It a seamless mechanism for extracting information regardless of where the\r
   information is stored (such as in Read-only data, or an EFI Variable).\r
   This protocol allows access to data through size-granular APIs and provides a mechanism for a\r
   firmware component to monitor specific settings and be alerted when a setting is changed.\r
 \r
   This is the base PCD service API that provides an abstraction for accessing configuration content in\r
   the platform. It a seamless mechanism for extracting information regardless of where the\r
   information is stored (such as in Read-only data, or an EFI Variable).\r
   This protocol allows access to data through size-granular APIs and provides a mechanism for a\r
   firmware component to monitor specific settings and be alerted when a setting is changed.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -73,7 +72,7 @@ UINT8
 );\r
 \r
 /**\r
 );\r
 \r
 /**\r
-  Retrieves the current byte-sized value for a PCD token number. If the TokenNumber is invalid,\r
+  Retrieves the current word-sized value for a PCD token number. If the TokenNumber is invalid,\r
   the results are unpredictable.\r
 \r
   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.\r
   the results are unpredictable.\r
 \r
   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.\r
@@ -375,7 +374,8 @@ EFI_STATUS
   know what token numbers are valid in the database.\r
 \r
   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.\r
   know what token numbers are valid in the database.\r
 \r
   @param[in]    Guid          The 128-bit unique value that designates which namespace to extract the value from.\r
-  @param[in]    TokenNumber   The PCD token number.\r
+  @param[in]    TokenNumber   A pointer to the PCD token number to use to find the subsequent token number. To\r
+                              retrieve the "first" token, have the pointer reference a TokenNumber value of 0.\r
 \r
   @retval   EFI_SUCCESS       The PCD service has retrieved the value requested.\r
   @retval   EFI_NOT_FOUND     The PCD service could not find data from the requested token number.\r
 \r
   @retval   EFI_SUCCESS       The PCD service has retrieved the value requested.\r
   @retval   EFI_NOT_FOUND     The PCD service could not find data from the requested token number.\r
index 03ce981d467bae869f5f889acd1cbd64edf26df2..03b02fd936ebb2b3b08fa932260c798df8c61425 100644 (file)
@@ -6,7 +6,7 @@
   The interfaces in dynamic type PCD do not require the token space guid as parameter,\r
   but interfaces in dynamic-ex type PCD require token space guid as parameter.\r
   \r
   The interfaces in dynamic type PCD do not require the token space guid as parameter,\r
   but interfaces in dynamic-ex type PCD require token space guid as parameter.\r
   \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -766,7 +766,7 @@ EFI_STATUS
   Retrieves the next valid token number in a given namespace.  \r
   \r
   This is useful since the PCD infrastructure contains a sparse list of token numbers, \r
   Retrieves the next valid token number in a given namespace.  \r
   \r
   This is useful since the PCD infrastructure contains a sparse list of token numbers, \r
-  and one cannot know without examination or by deduction what token numbers are valid in the database. \r
+  and one cannot a priori know what token numbers are valid in the database.\r
   \r
   If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.  \r
   If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.  \r
   \r
   If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.  \r
   If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.  \r
@@ -784,10 +784,8 @@ EFI_STATUS
   @param[in,out]  TokenNumber \r
                           A pointer to the PCD token number to use to find the subsequent token number.  \r
 \r
   @param[in,out]  TokenNumber \r
                           A pointer to the PCD token number to use to find the subsequent token number.  \r
 \r
-  @retval EFI_SUCCESS   The PCD service retrieved the next valid token number. Or the input token number \r
-                        is already the last valid token number in the PCD database. \r
-                        In the later case, *TokenNumber is updated with the value of 0.\r
-  @retval EFI_NOT_FOUND If this input token number and token namespace does not exist on the platform.\r
+  @retval EFI_SUCCESS   The PCD service has retrieved the next valid token number.\r
+  @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.\r
 \r
 **/\r
 typedef \r
 \r
 **/\r
 typedef \r
@@ -802,22 +800,17 @@ EFI_STATUS
 /**\r
   Retrieves the next valid PCD token namespace for a given namespace.\r
 \r
 /**\r
   Retrieves the next valid PCD token namespace for a given namespace.\r
 \r
-  @param[in, out]  Guid An indirect pointer to EFI_GUID. On input it designates \r
-                        a known token namespace from which the search will start. On output, \r
-                        it designates the next valid token namespace on the platform. If the input \r
-                        token namespace does not exist on the platform, an error is returned and \r
-                        the value of *Guid is undefined. If *Guid is NULL, then the GUID of the \r
-                        first token space of the current platform is assigned to *Guid the function \r
-                        return EFI_SUCCESS. If *Guid is NULL  and there is no namespace exist in \r
-                        the platform other than the default (NULL) token namespace, *Guid is unchanged \r
-                        and the function return EFI_SUCCESS. If this input token namespace is the last \r
-                        namespace on the platform, *Guid will be assigned to NULL and the function return \r
-                        EFI_SUCCESS. \r
-\r
-  @retval EFI_SUCCESS  The PCD service retrieved the next valid token space Guid. \r
-                        Or, the input token space Guid is already the last valid token space Guid \r
-                        in the PCD database. In the later case, *Guid is updated with the value of NULL.\r
-  @retval EFI_NOT_FOUND If the input token namespace does not exist on the platform.\r
+  Gets the next valid token namespace for a given namespace. This is useful to traverse the valid\r
+  token namespaces on a platform.\r
+\r
+  @param[in, out]   Guid    An indirect pointer to EFI_GUID. On input it designates a known token namespace\r
+                            from which the search will start. On output, it designates the next valid token\r
+                            namespace on the platform. If *Guid is NULL, then the GUID of the first token\r
+                            space of the current platform is returned. If the search cannot locate the next valid\r
+                            token namespace, an error is returned and the value of *Guid is undefined.\r
+\r
+  @retval   EFI_SUCCESS   The PCD service retrieved the value requested.\r
+  @retval   EFI_NOT_FOUND The PCD service could not find the next valid token namespace.\r
 \r
 **/\r
 typedef \r
 \r
 **/\r
 typedef \r
index a7303e800c3d9046c6fbd5cc567a8b2013f936eb..cd8212824fc74d773c2107221fd7ac87f8168dd3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation of PcdLib class library for DXE phase.\r
 \r
 /** @file\r
 Implementation of PcdLib class library for DXE phase.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -955,10 +955,7 @@ LibPcdGetNextToken (
   IN UINTN                    TokenNumber\r
   )\r
 {\r
   IN UINTN                    TokenNumber\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);\r
 \r
   return TokenNumber;\r
 }\r
 \r
   return TokenNumber;\r
 }\r
@@ -984,10 +981,7 @@ LibPcdGetNextTokenSpace (
   IN CONST GUID  *TokenSpaceGuid\r
   )\r
 {\r
   IN CONST GUID  *TokenSpaceGuid\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid);\r
-  ASSERT_EFI_ERROR (Status);\r
+  GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid);\r
 \r
   return (GUID *)TokenSpaceGuid;\r
 }\r
 \r
   return (GUID *)TokenSpaceGuid;\r
 }\r
index 4d91799025a46ccc346dacfc1068b6a49e3799d0..0a7efdb44ec2160ff628985ff6cd06cef53c4091 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation of PcdLib class library for PEI phase.\r
 \r
 /** @file\r
 Implementation of PcdLib class library for PEI phase.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -962,11 +962,7 @@ LibPcdGetNextToken (
   IN UINTN                    TokenNumber\r
   )\r
 {\r
   IN UINTN                    TokenNumber\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
+  (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber);\r
 \r
   return TokenNumber;\r
 }\r
 \r
   return TokenNumber;\r
 }\r
@@ -991,11 +987,7 @@ LibPcdGetNextTokenSpace (
   IN CONST GUID  *TokenSpaceGuid\r
   )\r
 {\r
   IN CONST GUID  *TokenSpaceGuid\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
+  (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid);\r
 \r
   return (GUID *) TokenSpaceGuid;\r
 }\r
 \r
   return (GUID *) TokenSpaceGuid;\r
 }\r