]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg and MdeModulePkg Pcd: Add the new EFI_GET_PCD_INFO_PROTOCOL and EFI_GET_PCD_IN...
authorStar Zeng <star.zeng@intel.com>
Wed, 20 Nov 2013 00:44:25 +0000 (00:44 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Nov 2013 00:44:25 +0000 (00:44 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14866 6f19259b-4bc3-4df7-8a09-765794883524

21 files changed:
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/Pi/PiMultiPhase.h
MdePkg/Include/Ppi/PcdInfo.h [new file with mode: 0644]
MdePkg/Include/Ppi/PiPcdInfo.h [new file with mode: 0644]
MdePkg/Include/Protocol/PcdInfo.h [new file with mode: 0644]
MdePkg/Include/Protocol/PiPcdInfo.h [new file with mode: 0644]
MdePkg/Library/BasePcdLibNull/PcdLib.c
MdePkg/Library/DxePcdLib/DxePcdLib.c
MdePkg/Library/DxePcdLib/DxePcdLib.inf
MdePkg/Library/PeiPcdLib/PeiPcdLib.c
MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
MdePkg/MdePkg.dec

index b627eb101c2851396a8a36fa873772c4d930b904..536fba8240e61833b24d40f4aaa395ddacbb252c 100644 (file)
   gEdkiiFormBrowserEx2ProtocolGuid = { 0xa770c357, 0xb693, 0x4e6d, { 0xa6, 0xcf, 0xd2, 0x1c, 0x72, 0x8e, 0x55, 0xb } }\r
 \r
 [PcdsFeatureFlag]\r
+  ## Indicates if the Pcd Info Ppi and Protocol should be produced.<BR><BR>\r
+  #  It can be disabled to save size.<BR><BR>\r
+  #   TRUE  - Pcd Info Ppi and Protocol will be produced.<BR>\r
+  #   FALSE - Pcd Info Ppi and Protocol will not be produced.<BR>\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPcdInfoGeneration|TRUE|BOOLEAN|0x0001001C\r
+\r
   ## Indicate whether platform can support update capsule across a system reset\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|FALSE|BOOLEAN|0x0001001d\r
 \r
index 04fcd64306c32c6e8818821b36c15606e5d5efbc..afe925c5e2e18594b7d1d13214ab4023ffd704a9 100644 (file)
@@ -89,6 +89,25 @@ EFI_PCD_PROTOCOL mEfiPcdInstance = {
   DxePcdGetNextTokenSpace\r
 };\r
 \r
+///\r
+/// Instance of GET_PCD_INFO_PROTOCOL protocol is EDKII native implementation.\r
+/// This protocol instance support dynamic and dynamicEx type PCDs.\r
+///\r
+GET_PCD_INFO_PROTOCOL mGetPcdInfoInstance = {\r
+  DxeGetPcdInfoGetInfo,\r
+  DxeGetPcdInfoGetInfoEx,\r
+  DxeGetPcdInfoGetSku\r
+};\r
+\r
+///\r
+/// Instance of EFI_GET_PCD_INFO_PROTOCOL which is defined in PI 1.2.1 Vol 3.\r
+/// This PPI instance only support dyanmicEx type PCD.\r
+///\r
+EFI_GET_PCD_INFO_PROTOCOL  mEfiGetPcdInfoInstance = {\r
+  DxeGetPcdInfoGetInfoEx,\r
+  DxeGetPcdInfoGetSku\r
+};\r
+\r
 EFI_HANDLE mPcdHandle = NULL;\r
 \r
 /**\r
@@ -129,11 +148,90 @@ PcdDxeInit (
                   &gEfiPcdProtocolGuid,  &mEfiPcdInstance,\r
                   NULL\r
                   );\r
-                 \r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  if (FeaturePcdGet (PcdPcdInfoGeneration) && mPcdDatabase.DxeDb->PcdNameTableOffset != 0) {\r
+    //\r
+    // Install GET_PCD_INFO_PROTOCOL to handle dynamic type PCD\r
+    // Install EFI_GET_PCD_INFO_PROTOCOL to handle dynamicEx type PCD\r
+    //\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &mPcdHandle,\r
+                    &gGetPcdInfoProtocolGuid,     &mGetPcdInfoInstance,\r
+                    &gEfiGetPcdInfoProtocolGuid,  &mEfiGetPcdInfoInstance,\r
+                    NULL\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
   return Status;\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token in the default token space.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
 \r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeGetPcdInfoGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  )\r
+{\r
+  return DxeGetPcdInfo (NULL, TokenNumber, PcdInfo);\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeGetPcdInfoGetInfoEx (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  )\r
+{\r
+  return DxeGetPcdInfo (Guid, TokenNumber, PcdInfo);\r
+}\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+DxeGetPcdInfoGetSku (\r
+  VOID\r
+  )\r
+{\r
+  if (!FeaturePcdGet (PcdPcdInfoGeneration)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  return mPcdDatabase.PeiDb->SystemSkuId;\r
 }\r
 \r
 /**\r
index 6762bde06181896d951a2bd7466a0642ffce459c..8565b30307c5da7f5c8602f42675a6fff5bc72b4 100644 (file)
 [Protocols]\r
   gPcdProtocolGuid                              ## PRODUCES\r
   gEfiPcdProtocolGuid                           ## PRODUCES\r
-  \r
+  gGetPcdInfoProtocolGuid                       ## SOMETIMES_PRODUCES\r
+  gEfiGetPcdInfoProtocolGuid                    ## SOMETIMES_PRODUCES\r
+\r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress  ## SOMETIMES_CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPcdInfoGeneration\r
 \r
 [Depex]\r
   TRUE\r
index 4bdb071a6e80e13e9222ba730692e4d98d6e1a89..43a3bda7760d45ecc165da430164a5d63321f24f 100644 (file)
@@ -35,6 +35,317 @@ LIST_ENTRY    *mCallbackFnTable;
 EFI_GUID     **TmpTokenSpaceBuffer;\r
 UINTN          TmpTokenSpaceBufferCount; \r
 \r
+/**\r
+  Get Local Token Number by Token Number.\r
+\r
+  @param[in]    IsPeiDb     If TRUE, the pcd entry is initialized in PEI phase,\r
+                            If FALSE, the pcd entry is initialized in DXE phase.\r
+  @param[in]    TokenNumber The PCD token number.\r
+\r
+  @return       Local Token Number.\r
+**/\r
+UINT32\r
+GetLocalTokenNumber (\r
+  IN BOOLEAN            IsPeiDb,\r
+  IN UINTN              TokenNumber\r
+  )\r
+{\r
+  UINT32                *LocalTokenNumberTable;\r
+  UINT32                LocalTokenNumber;\r
+  UINTN                 Size;\r
+  UINTN                 MaxSize;\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
+  LocalTokenNumberTable  = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : \r
+                                     (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);\r
+  TokenNumber            = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount;\r
+\r
+  LocalTokenNumber = LocalTokenNumberTable[TokenNumber];\r
+\r
+  Size = (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
+\r
+  if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
+    if (Size == 0) {\r
+      GetPtrTypeSize (TokenNumber, &MaxSize);\r
+    } else {\r
+      MaxSize = Size;\r
+    }\r
+    LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);\r
+  }\r
+\r
+  return LocalTokenNumber;\r
+}\r
+\r
+/**\r
+  Get PCD type by Local Token Number.\r
+\r
+  @param[in]    LocalTokenNumber The PCD local token number.\r
+\r
+  @return       PCD type.\r
+**/\r
+EFI_PCD_TYPE\r
+GetPcdType (\r
+  IN UINT32             LocalTokenNumber\r
+  )\r
+{\r
+  switch (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) {\r
+    case PCD_DATUM_TYPE_POINTER:\r
+      return EFI_PCD_TYPE_PTR;\r
+    case PCD_DATUM_TYPE_UINT8:\r
+      if (LocalTokenNumber & PCD_DATUM_TYPE_UINT8_BOOLEAN) {\r
+        return EFI_PCD_TYPE_BOOL;\r
+      } else {\r
+        return EFI_PCD_TYPE_8;\r
+      }\r
+    case PCD_DATUM_TYPE_UINT16:\r
+      return EFI_PCD_TYPE_16;\r
+    case PCD_DATUM_TYPE_UINT32:\r
+      return EFI_PCD_TYPE_32;\r
+    case PCD_DATUM_TYPE_UINT64:\r
+      return EFI_PCD_TYPE_64;\r
+    default:\r
+      ASSERT (FALSE);\r
+      return EFI_PCD_TYPE_8;\r
+  }\r
+}\r
+\r
+/**\r
+  Get PCD name.\r
+\r
+  @param[in]    OnlyTokenSpaceName  If TRUE, only need to get the TokenSpaceCName.\r
+                                    If FALSE, need to get the full PCD name.\r
+  @param[in]    IsPeiDb             If TRUE, the pcd entry is initialized in PEI phase,\r
+                                    If FALSE, the pcd entry is initialized in DXE phase.\r
+  @param[in]    TokenNumber         The PCD token number.\r
+\r
+  @return       The TokenSpaceCName or full PCD name.\r
+**/\r
+CHAR8 *\r
+GetPcdName (\r
+  IN BOOLEAN            OnlyTokenSpaceName,\r
+  IN BOOLEAN            IsPeiDb,\r
+  IN UINTN              TokenNumber\r
+  )\r
+{\r
+  PCD_DATABASE_INIT *Database;\r
+  UINT8             *StringTable;\r
+  PCD_NAME_INDEX    *PcdNameIndex;\r
+  CHAR8             *TokenSpaceName;\r
+  CHAR8             *PcdName;\r
+  CHAR8             *Name;\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
+  Database = IsPeiDb ? mPcdDatabase.PeiDb: mPcdDatabase.DxeDb;\r
+  TokenNumber = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount;\r
+\r
+  StringTable = (UINT8 *) Database + Database->StringTableOffset;\r
+\r
+  //\r
+  // Get the PCD name index.\r
+  //\r
+  PcdNameIndex = (PCD_NAME_INDEX *)((UINT8 *) Database + Database->PcdNameTableOffset) + TokenNumber;\r
+  TokenSpaceName = (CHAR8 *)&StringTable[PcdNameIndex->TokenSpaceCNameIndex];\r
+  PcdName = (CHAR8 *)&StringTable[PcdNameIndex->PcdCNameIndex];\r
+\r
+  if (OnlyTokenSpaceName) {\r
+    //\r
+    // Only need to get the TokenSpaceCName.\r
+    //\r
+    Name = AllocateCopyPool (AsciiStrSize (TokenSpaceName), TokenSpaceName);\r
+  } else {\r
+    //\r
+    // Need to get the full PCD name.\r
+    //\r
+    Name = AllocateZeroPool (AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName));\r
+    //\r
+    // Catenate TokenSpaceCName and PcdCName with a '.' to form the full PCD name.\r
+    //\r
+    AsciiStrCat (Name, TokenSpaceName);\r
+    Name[AsciiStrSize (TokenSpaceName) - sizeof (CHAR8)] = '.';\r
+    AsciiStrCat (Name, PcdName);  \r
+  }\r
+\r
+  return Name;\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    IsPeiDb     If TRUE, the pcd entry is initialized in PEI phase,\r
+                            If FALSE, the pcd entry is initialized in DXE phase.\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. \r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+ExGetPcdInfo (\r
+  IN        BOOLEAN             IsPeiDb,\r
+  IN CONST  EFI_GUID            *Guid,\r
+  IN        UINTN               TokenNumber,\r
+  OUT       EFI_PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  PCD_DATABASE_INIT     *Database;\r
+  UINTN                 GuidTableIdx;\r
+  EFI_GUID              *MatchGuid;\r
+  EFI_GUID              *GuidTable;\r
+  DYNAMICEX_MAPPING     *ExMapTable;\r
+  UINTN                 Index;\r
+  UINT32                LocalTokenNumber;\r
+\r
+  Database = IsPeiDb ? mPcdDatabase.PeiDb: mPcdDatabase.DxeDb;\r
+\r
+  GuidTable = (EFI_GUID *)((UINT8 *)Database + Database->GuidTableOffset);\r
+  MatchGuid = ScanGuid (GuidTable, Database->GuidTableCount * sizeof(EFI_GUID), Guid);\r
+\r
+  if (MatchGuid == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  GuidTableIdx = MatchGuid - GuidTable;\r
+\r
+  ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)Database + Database->ExMapTableOffset);\r
+\r
+  //\r
+  // Find the PCD by GuidTableIdx and ExTokenNumber in ExMapTable.\r
+  //\r
+  for (Index = 0; Index < Database->ExTokenCount; Index++) {\r
+    if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
+      if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
+        //\r
+        // TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,\r
+        // PcdSize to 0 and PcdName to the null-terminated ASCII string\r
+        // associated with the token's namespace Guid.\r
+        //\r
+        PcdInfo->PcdType = EFI_PCD_TYPE_8;\r
+        PcdInfo->PcdSize = 0;\r
+        //\r
+        // Here use one representative in the token space to get the TokenSpaceCName.\r
+        // \r
+        PcdInfo->PcdName = GetPcdName (TRUE, IsPeiDb, ExMapTable[Index].TokenNumber);\r
+        return EFI_SUCCESS;\r
+      } else if (ExMapTable[Index].ExTokenNumber == TokenNumber) {\r
+        PcdInfo->PcdSize = DxePcdGetSize (ExMapTable[Index].TokenNumber);\r
+        LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, ExMapTable[Index].TokenNumber);\r
+        PcdInfo->PcdType = GetPcdType (LocalTokenNumber);\r
+        PcdInfo->PcdName = GetPcdName (FALSE, IsPeiDb, ExMapTable[Index].TokenNumber);\r
+        return EFI_SUCCESS;\r
+      }\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+DxeGetPcdInfo (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  BOOLEAN               PeiExMapTableEmpty;\r
+  BOOLEAN               DxeExMapTableEmpty;\r
+  UINT32                LocalTokenNumber;\r
+  BOOLEAN               IsPeiDb;\r
+\r
+  if (!FeaturePcdGet (PcdPcdInfoGeneration)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  ASSERT (PcdInfo != NULL);\r
+\r
+  Status = EFI_NOT_FOUND;\r
+  PeiExMapTableEmpty = mPeiExMapTableEmpty;\r
+  DxeExMapTableEmpty = mDxeExMapTableEmpty;\r
+\r
+  if (Guid == NULL) {\r
+    if (((TokenNumber + 1 > mPeiNexTokenCount + 1) && (TokenNumber + 1 <= mPeiLocalTokenCount + 1)) ||\r
+        ((TokenNumber + 1 > (mPeiLocalTokenCount + mDxeNexTokenCount + 1)))) {\r
+      return EFI_NOT_FOUND;\r
+    } else if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
+      //\r
+      // TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,\r
+      // PcdSize to 0 and PcdName to NULL for default Token Space.\r
+      //\r
+      PcdInfo->PcdType = EFI_PCD_TYPE_8;\r
+      PcdInfo->PcdSize = 0;\r
+      PcdInfo->PcdName = NULL;\r
+    } else {\r
+      PcdInfo->PcdSize = DxePcdGetSize (TokenNumber);\r
+      IsPeiDb = FALSE;\r
+      if ((TokenNumber + 1 <= mPeiNexTokenCount + 1)) {\r
+        IsPeiDb = TRUE;\r
+      }\r
+      LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, TokenNumber);\r
+      PcdInfo->PcdType = GetPcdType (LocalTokenNumber);\r
+      PcdInfo->PcdName = GetPcdName (FALSE, IsPeiDb, TokenNumber);\r
+    }\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (PeiExMapTableEmpty && DxeExMapTableEmpty) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  if (!PeiExMapTableEmpty) {\r
+    Status = ExGetPcdInfo (\r
+               TRUE,\r
+               Guid,\r
+               TokenNumber,\r
+               PcdInfo\r
+               );\r
+  }\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    return Status;\r
+  }\r
+\r
+  if (!DxeExMapTableEmpty) {\r
+    Status = ExGetPcdInfo (\r
+               FALSE,\r
+               Guid,\r
+               TokenNumber,\r
+               PcdInfo\r
+               );\r
+  }\r
+\r
+  return Status;\r
+}\r
 \r
 /**\r
   Get the PCD entry pointer in PCD database.\r
@@ -56,7 +367,6 @@ GetWorker (
   IN UINTN             GetSize\r
   )\r
 {\r
-  UINT32              *LocalTokenNumberTable;\r
   EFI_GUID            *GuidTable;\r
   UINT8               *StringTable;\r
   EFI_GUID            *Guid;\r
@@ -67,7 +377,6 @@ GetWorker (
   VPD_HEAD            *VpdHead;\r
   UINT8               *PcdDb;\r
   VOID                *RetPtr;\r
-  UINTN               MaxSize;\r
   UINTN               TmpTokenNumber;\r
   UINTN               DataSize;\r
   EFI_STATUS          Status;\r
@@ -107,22 +416,7 @@ GetWorker (
   // comparison.\r
   IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);\r
 \r
-  LocalTokenNumberTable  = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : \r
-                                     (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset);\r
-\r
-  TokenNumber            = IsPeiDb ? TokenNumber :\r
-                                     TokenNumber - mPeiLocalTokenCount;\r
-\r
-  LocalTokenNumber = LocalTokenNumberTable[TokenNumber];\r
-  \r
-  if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
-    if (GetSize == 0) {\r
-      GetPtrTypeSize (TmpTokenNumber, &MaxSize);\r
-    } else {\r
-      MaxSize = GetSize;\r
-    }\r
-    LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);\r
-  }\r
+  LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, TokenNumber + 1);\r
 \r
   PcdDb = IsPeiDb ? ((UINT8 *) mPcdDatabase.PeiDb) : ((UINT8 *) mPcdDatabase.DxeDb);\r
                                     \r
@@ -792,7 +1086,6 @@ SetWorker (
   IN          BOOLEAN                 PtrType\r
   )\r
 {\r
-  UINT32              *LocalTokenNumberTable;\r
   BOOLEAN             IsPeiDb;\r
   UINT32              LocalTokenNumber;\r
   EFI_GUID            *GuidTable;\r
@@ -861,22 +1154,7 @@ SetWorker (
   //\r
   IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE);\r
 \r
-  LocalTokenNumberTable  = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : \r
-                                     (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset) ;\r
-\r
-  TokenNumber = IsPeiDb ? TokenNumber\r
-                        : TokenNumber - mPeiLocalTokenCount;\r
-\r
-  LocalTokenNumber = LocalTokenNumberTable[TokenNumber];\r
-  \r
-  if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
-    if (PtrType) {\r
-      GetPtrTypeSize (TmpTokenNumber, &MaxSize);\r
-    } else {\r
-      MaxSize = *Size;\r
-    }\r
-    LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize, IsPeiDb);\r
-  }\r
+  LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, TokenNumber + 1);\r
 \r
   Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
 \r
index 292a74cfb5a036dae04d0421c7397a5dfcddcd52..55717dc98281eab6733510dbaa3f356acd3f5105 100644 (file)
@@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/PcdDataBaseSignatureGuid.h>\r
 #include <Protocol/Pcd.h>\r
 #include <Protocol/PiPcd.h>\r
+#include <Protocol/PcdInfo.h>\r
+#include <Protocol/PiPcdInfo.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiLib.h>\r
@@ -44,6 +46,61 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   #error "Please make sure the version of PCD DXE Service and the generated PCD DXE Database match."\r
 #endif\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token in the default token space.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeGetPcdInfoGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeGetPcdInfoGetInfoEx (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+DxeGetPcdInfoGetSku (\r
+  VOID\r
+  );\r
+\r
 //\r
 // Protocol Interface function declaration.\r
 //\r
@@ -757,6 +814,27 @@ typedef struct {
 // Internal Functions\r
 //\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. \r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+DxeGetPcdInfo (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
+\r
 /**\r
   Wrapper function for setting non-pointer type value for a PCD entry.\r
 \r
index 557b915a1234e9c881297db174d7bc9570572fda..a9ee051263752732b78673db3bb1e9d4e3636998 100644 (file)
@@ -83,6 +83,25 @@ EFI_PEI_PCD_PPI  mEfiPcdPpiInstance = {
   PeiPcdGetNextTokenSpace\r
 };\r
 \r
+///\r
+/// Instance of GET_PCD_INFO_PPI protocol is EDKII native implementation.\r
+/// This protocol instance support dynamic and dynamicEx type PCDs.\r
+///\r
+GET_PCD_INFO_PPI mGetPcdInfoInstance = {\r
+  PeiGetPcdInfoGetInfo,\r
+  PeiGetPcdInfoGetInfoEx,\r
+  PeiGetPcdInfoGetSku\r
+};\r
+\r
+///\r
+/// Instance of EFI_GET_PCD_INFO_PPI which is defined in PI 1.2.1 Vol 3.\r
+/// This PPI instance only support dyanmicEx type PCD.\r
+///\r
+EFI_GET_PCD_INFO_PPI  mEfiGetPcdInfoInstance = {\r
+  PeiGetPcdInfoGetInfoEx,\r
+  PeiGetPcdInfoGetSku\r
+};\r
+\r
 EFI_PEI_PPI_DESCRIPTOR  mPpiList[] = {\r
   {\r
     EFI_PEI_PPI_DESCRIPTOR_PPI,\r
@@ -96,6 +115,19 @@ EFI_PEI_PPI_DESCRIPTOR  mPpiList[] = {
   }\r
 };\r
 \r
+EFI_PEI_PPI_DESCRIPTOR  mPpiList2[] = {\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gGetPcdInfoPpiGuid,\r
+    &mGetPcdInfoInstance\r
+  },\r
+  {\r
+    (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+    &gEfiGetPcdInfoPpiGuid,\r
+    &mEfiGetPcdInfoInstance\r
+  }\r
+};\r
+\r
 /**\r
   Main entry for PCD PEIM driver.\r
   \r
@@ -114,19 +146,98 @@ PcdPeimInit (
   IN CONST EFI_PEI_SERVICES     **PeiServices\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-  \r
-  BuildPcdDatabase (FileHandle);\r
+  EFI_STATUS        Status;\r
+  PEI_PCD_DATABASE  *DataBase;\r
+\r
+  DataBase = BuildPcdDatabase (FileHandle);\r
 \r
   //\r
   // Install PCD_PPI and EFI_PEI_PCD_PPI.\r
   //\r
   Status = PeiServicesInstallPpi (&mPpiList[0]);\r
   ASSERT_EFI_ERROR (Status);\r
-  \r
+\r
+  //\r
+  // Only install PcdInfo PPI when the feature is enabled and PCD info content is present. \r
+  //\r
+  if (FeaturePcdGet (PcdPcdInfoGeneration) && (DataBase->PcdNameTableOffset != 0)) {\r
+    //\r
+    // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.\r
+    //\r
+    Status = PeiServicesInstallPpi (&mPpiList2[0]);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
   return Status;\r
 }\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token in the default token space.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetPcdInfoGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  )\r
+{\r
+  return PeiGetPcdInfo (NULL, TokenNumber, PcdInfo);\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetPcdInfoGetInfoEx (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  )\r
+{\r
+  return PeiGetPcdInfo (Guid, TokenNumber, PcdInfo);\r
+}\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+PeiGetPcdInfoGetSku (\r
+  VOID\r
+  )\r
+{\r
+  if (!FeaturePcdGet (PcdPcdInfoGeneration)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  return GetPcdDatabase()->SystemSkuId;\r
+}\r
+\r
 /**\r
   Sets the SKU value for subsequent calls to set or get PCD token values.\r
 \r
index 8c2ab190a7dbec6e23a5ee2e219dc5d298822d76..fabe63c4f4c345c670b6abe8981c244c9f285faa 100644 (file)
   BaseLib\r
   PeimEntryPoint\r
   DebugLib\r
+  MemoryAllocationLib\r
 \r
 [Guids]\r
   ## PRODUCES            ## HOB\r
   gEfiPeiReadOnlyVariable2PpiGuid               ## SOMETIMES_CONSUMES\r
   gPcdPpiGuid                                   ## PRODUCES\r
   gEfiPeiPcdPpiGuid                             ## PRODUCES\r
-  \r
+  gGetPcdInfoPpiGuid                            ## SOMETIMES_PRODUCES\r
+  gEfiGetPcdInfoPpiGuid                         ## SOMETIMES_PRODUCES\r
+\r
 [FeaturePcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable  ## CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry || gEfiMdeModulePkgTokenSpaceGuid.PcdPeiFullPcdDatabaseEnable ## SOMETIMES_CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPcdInfoGeneration\r
 \r
 [Depex]\r
   TRUE\r
index 47e87d3bcddba3265c67458da167a7a3a2ced783..04ae874a21c05a1c9d2f48e7bdbe0f8796d515a1 100644 (file)
@@ -15,6 +15,284 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "Service.h"\r
 \r
+/**\r
+  Get Local Token Number by Token Number.\r
+\r
+  @param[in]    Database    PCD database.\r
+  @param[in]    TokenNumber The PCD token number.\r
+\r
+  @return       Local Token Number.\r
+**/\r
+UINT32\r
+GetLocalTokenNumber (\r
+  IN PEI_PCD_DATABASE   *Database,\r
+  IN UINTN              TokenNumber\r
+  )\r
+{\r
+  UINT32                LocalTokenNumber;\r
+  UINTN                 Size;\r
+  UINTN                 MaxSize;\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
+  LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + TokenNumber);\r
+\r
+  Size = (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
+\r
+  if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
+    if (Size == 0) {\r
+      GetPtrTypeSize (TokenNumber, &MaxSize, Database);\r
+    } else {\r
+      MaxSize = Size;\r
+    }\r
+    LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);\r
+  }\r
+\r
+  return LocalTokenNumber;\r
+}\r
+\r
+/**\r
+  Get PCD type by Local Token Number.\r
+\r
+  @param[in]    LocalTokenNumber The PCD local token number.\r
+\r
+  @return       PCD type.\r
+**/\r
+EFI_PCD_TYPE\r
+GetPcdType (\r
+  IN UINT32             LocalTokenNumber\r
+  )\r
+{\r
+  switch (LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) {\r
+    case PCD_DATUM_TYPE_POINTER:\r
+      return EFI_PCD_TYPE_PTR;\r
+    case PCD_DATUM_TYPE_UINT8:\r
+      if (LocalTokenNumber & PCD_DATUM_TYPE_UINT8_BOOLEAN) {\r
+        return EFI_PCD_TYPE_BOOL;\r
+      } else {\r
+        return EFI_PCD_TYPE_8;\r
+      }\r
+    case PCD_DATUM_TYPE_UINT16:\r
+      return EFI_PCD_TYPE_16;\r
+    case PCD_DATUM_TYPE_UINT32:\r
+      return EFI_PCD_TYPE_32;\r
+    case PCD_DATUM_TYPE_UINT64:\r
+      return EFI_PCD_TYPE_64;\r
+    default:\r
+      ASSERT (FALSE);\r
+      return EFI_PCD_TYPE_8;\r
+  }\r
+}\r
+\r
+/**\r
+  Get PCD name.\r
+\r
+  @param[in]    OnlyTokenSpaceName  If TRUE, only need to get the TokenSpaceCName.\r
+                                    If FALSE, need to get the full PCD name.\r
+  @param[in]    Database            PCD database.\r
+  @param[in]    TokenNumber         The PCD token number.\r
+\r
+  @return       The TokenSpaceCName or full PCD name.\r
+**/\r
+CHAR8 *\r
+GetPcdName (\r
+  IN BOOLEAN            OnlyTokenSpaceName,\r
+  IN PEI_PCD_DATABASE   *Database,\r
+  IN UINTN              TokenNumber\r
+  )\r
+{\r
+  UINT8             *StringTable;\r
+  PCD_NAME_INDEX    *PcdNameIndex;\r
+  CHAR8             *TokenSpaceName;\r
+  CHAR8             *PcdName;\r
+  CHAR8             *Name;\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
+  StringTable = (UINT8 *) Database + Database->StringTableOffset;\r
+\r
+  //\r
+  // Get the PCD name index.\r
+  //\r
+  PcdNameIndex = (PCD_NAME_INDEX *)((UINT8 *) Database + Database->PcdNameTableOffset) + TokenNumber;\r
+  TokenSpaceName = (CHAR8 *)&StringTable[PcdNameIndex->TokenSpaceCNameIndex];\r
+  PcdName = (CHAR8 *)&StringTable[PcdNameIndex->PcdCNameIndex];\r
+\r
+  if (OnlyTokenSpaceName) {\r
+    //\r
+    // Only need to get the TokenSpaceCName.\r
+    //\r
+    Name = AllocateCopyPool (AsciiStrSize (TokenSpaceName), TokenSpaceName);\r
+  } else {\r
+    //\r
+    // Need to get the full PCD name.\r
+    //\r
+    Name = AllocateZeroPool (AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName));\r
+    //\r
+    // Catenate TokenSpaceCName and PcdCName with a '.' to form the full PCD name.\r
+    //\r
+    AsciiStrCat (Name, TokenSpaceName);\r
+    Name[AsciiStrSize (TokenSpaceName) - sizeof (CHAR8)] = '.';\r
+    AsciiStrCat (Name, PcdName);  \r
+  }\r
+\r
+  return Name;\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Database    PCD database.\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. \r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+ExGetPcdInfo (\r
+  IN        PEI_PCD_DATABASE    *Database,\r
+  IN CONST  EFI_GUID            *Guid,\r
+  IN        UINTN               TokenNumber,\r
+  OUT       EFI_PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  UINTN                 GuidTableIdx;\r
+  EFI_GUID              *MatchGuid;\r
+  EFI_GUID              *GuidTable;\r
+  DYNAMICEX_MAPPING     *ExMapTable;\r
+  UINTN                 Index;\r
+  UINT32                LocalTokenNumber;\r
+\r
+  GuidTable = (EFI_GUID *)((UINT8 *)Database + Database->GuidTableOffset);\r
+  MatchGuid = ScanGuid (GuidTable, Database->GuidTableCount * sizeof(EFI_GUID), Guid);\r
+\r
+  if (MatchGuid == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  GuidTableIdx = MatchGuid - GuidTable;\r
+\r
+  ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)Database + Database->ExMapTableOffset);\r
+\r
+  //\r
+  // Find the PCD by GuidTableIdx and ExTokenNumber in ExMapTable.\r
+  //\r
+  for (Index = 0; Index < Database->ExTokenCount; Index++) {\r
+    if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {\r
+      if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
+        //\r
+        // TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,\r
+        // PcdSize to 0 and PcdName to the null-terminated ASCII string\r
+        // associated with the token's namespace Guid.\r
+        //\r
+        PcdInfo->PcdType = EFI_PCD_TYPE_8;\r
+        PcdInfo->PcdSize = 0;\r
+        //\r
+        // Here use one representative in the token space to get the TokenSpaceCName.\r
+        // \r
+        PcdInfo->PcdName = GetPcdName (TRUE, Database, ExMapTable[Index].TokenNumber);\r
+        return EFI_SUCCESS;\r
+      } else if (ExMapTable[Index].ExTokenNumber == TokenNumber) {\r
+        PcdInfo->PcdSize = PeiPcdGetSize (ExMapTable[Index].TokenNumber);\r
+        LocalTokenNumber = GetLocalTokenNumber (Database, ExMapTable[Index].TokenNumber);\r
+        PcdInfo->PcdType = GetPcdType (LocalTokenNumber);\r
+        PcdInfo->PcdName = GetPcdName (FALSE, Database, ExMapTable[Index].TokenNumber);\r
+        return EFI_SUCCESS;\r
+      }\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+PeiGetPcdInfo (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  )\r
+{\r
+  PEI_PCD_DATABASE      *PeiPcdDb;\r
+  BOOLEAN               PeiExMapTableEmpty;\r
+  UINTN                 PeiNexTokenNumber;\r
+  UINT32                LocalTokenNumber;\r
+\r
+  if (!FeaturePcdGet (PcdPcdInfoGeneration)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  ASSERT (PcdInfo != NULL);\r
+\r
+  PeiPcdDb          = GetPcdDatabase ();\r
+  PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;\r
+\r
+  if (PeiPcdDb->ExTokenCount == 0) {\r
+    PeiExMapTableEmpty = TRUE;\r
+  } else {\r
+    PeiExMapTableEmpty = FALSE;\r
+  }\r
+\r
+  if (Guid == NULL) {\r
+    if (TokenNumber > PeiNexTokenNumber) {\r
+      return EFI_NOT_FOUND;\r
+    } else if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
+      //\r
+      // TokenNumber is 0, follow spec to set PcdType to EFI_PCD_TYPE_8,\r
+      // PcdSize to 0 and PcdName to NULL for default Token Space.\r
+      //\r
+      PcdInfo->PcdType = EFI_PCD_TYPE_8;\r
+      PcdInfo->PcdSize = 0;\r
+      PcdInfo->PcdName = NULL;\r
+    } else {\r
+      PcdInfo->PcdSize = PeiPcdGetSize (TokenNumber);\r
+      LocalTokenNumber = GetLocalTokenNumber (PeiPcdDb, TokenNumber);\r
+      PcdInfo->PcdType = GetPcdType (LocalTokenNumber);\r
+      PcdInfo->PcdName = GetPcdName (FALSE, PeiPcdDb, TokenNumber);\r
+    }\r
+    return EFI_SUCCESS;\r
+  } else {\r
+    if (PeiExMapTableEmpty) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+    return ExGetPcdInfo (\r
+             PeiPcdDb,\r
+             Guid,\r
+             TokenNumber,\r
+             PcdInfo\r
+             );\r
+  }\r
+}\r
+\r
 /**\r
   The function registers the CallBackOnSet fucntion\r
   according to TokenNumber and EFI_GUID space.\r
@@ -150,8 +428,9 @@ LocateExPcdBinary (
 \r
   @param  FileHandle  Handle of the file the external PCD database binary located.\r
 \r
+  @return Pointer to PCD database.\r
 **/\r
-VOID\r
+PEI_PCD_DATABASE *\r
 BuildPcdDatabase (\r
   IN EFI_PEI_FILE_HANDLE    FileHandle\r
   )\r
@@ -182,6 +461,8 @@ BuildPcdDatabase (
   CallbackFnTable = BuildGuidHob (&gEfiCallerIdGuid, SizeOfCallbackFnTable);\r
   \r
   ZeroMem (CallbackFnTable, SizeOfCallbackFnTable);\r
+\r
+  return Database;\r
 }\r
 \r
 /**\r
@@ -462,8 +743,6 @@ SetWorker (
   // comparison.\r
   ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));\r
 \r
-  LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);\r
-\r
   if (PtrType) {\r
     //\r
     // Get MaxSize first, then check new size with max buffer size.\r
@@ -489,14 +768,7 @@ SetWorker (
     InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);\r
   }\r
 \r
-  if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {\r
-    if (PtrType) {\r
-      GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r
-    } else {\r
-      MaxSize = *Size;\r
-    }\r
-    LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);\r
-  }\r
+  LocalTokenNumber = GetLocalTokenNumber (PeiPcdDb, TokenNumber + 1);\r
 \r
   Offset          = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
   InternalData    = (VOID *) ((UINT8 *) PeiPcdDb + Offset);\r
@@ -677,7 +949,6 @@ GetWorker (
   STRING_HEAD         StringTableIdx;\r
   PEI_PCD_DATABASE    *PeiPcdDb;\r
   UINT32              LocalTokenNumber;\r
-  UINTN               MaxSize;\r
   UINT32              LocalTokenCount;\r
 \r
   //\r
@@ -697,16 +968,7 @@ GetWorker (
 \r
   ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));\r
 \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
-      GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r
-    } else {\r
-      MaxSize = GetSize;\r
-    }\r
-    LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, MaxSize);\r
-  }\r
+  LocalTokenNumber = GetLocalTokenNumber (PeiPcdDb, TokenNumber + 1);\r
 \r
   Offset      = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;\r
   StringTable = (UINT8 *)PeiPcdDb + PeiPcdDb->StringTableOffset;\r
index 1928dcb928ea44270fd7a91637a3f33a332d7fc3..2bd28b28c9bcba54cc3f1470df4920924a22b79b 100644 (file)
@@ -19,6 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Ppi/ReadOnlyVariable2.h>\r
 #include <Ppi/Pcd.h>\r
 #include <Ppi/PiPcd.h>\r
+#include <Ppi/PcdInfo.h>\r
+#include <Ppi/PiPcdInfo.h>\r
 #include <Guid/PcdDataBaseHobGuid.h>\r
 #include <Guid/PcdDataBaseSignatureGuid.h>\r
 #include <Library/DebugLib.h>\r
@@ -28,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/PeiServicesLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
-\r
+#include <Library/MemoryAllocationLib.h>\r
 \r
 //\r
 // Please make sure the PCD Serivce PEIM Version is consistent with\r
@@ -43,6 +45,61 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   #error "Please make sure the version of PCD PEIM Service and the generated PCD PEI Database match."\r
 #endif\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token in the default token space.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetPcdInfoGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully.\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetPcdInfoGetInfoEx (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+PeiGetPcdInfoGetSku (\r
+  VOID\r
+  );\r
+\r
 //\r
 // PPI Interface Implementation Declaration.\r
 //\r
@@ -753,6 +810,27 @@ PeiPcdGetNextTokenSpace (
   IN OUT CONST EFI_GUID           **Guid\r
   );\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. \r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetPcdInfo (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+  );\r
 \r
 /* Internal Function definitions */\r
 /**\r
@@ -915,6 +993,21 @@ GetExPcdTokenNumber (
   IN UINTN                      ExTokenNumber\r
   );\r
 \r
+/**\r
+  Find the local token number according to system SKU ID.\r
+\r
+  @param LocalTokenNumber PCD token number\r
+  @param Size             The size of PCD entry.\r
+\r
+  @return Token number according to system SKU ID.\r
+\r
+**/\r
+UINT32\r
+GetSkuEnabledTokenNumber (\r
+  UINT32 LocalTokenNumber,\r
+  UINTN  Size\r
+  );\r
+\r
 /**\r
   The function registers the CallBackOnSet fucntion\r
   according to TokenNumber and EFI_GUID space.\r
@@ -942,8 +1035,10 @@ PeiRegisterCallBackWorker (
 \r
   @param  FileHandle  Handle of the file the external PCD database binary located.\r
 \r
+  @return Pointer to PCD database.\r
+\r
 **/\r
-VOID\r
+PEI_PCD_DATABASE *\r
 BuildPcdDatabase (\r
   IN EFI_PEI_FILE_HANDLE    FileHandle\r
   );\r
index 1fc584060f32965d6efbc48d72c78716818e19d5..1ea4ac7ceca47850000cdb6d9b29f8d07dc65ccf 100644 (file)
@@ -1516,4 +1516,89 @@ LibPatchPcdSetPtr (
   IN CONST  VOID        *Buffer\r
   );\r
 \r
+typedef enum {\r
+  PCD_TYPE_8,\r
+  PCD_TYPE_16,\r
+  PCD_TYPE_32,\r
+  PCD_TYPE_64,\r
+  PCD_TYPE_BOOL,\r
+  PCD_TYPE_PTR\r
+} PCD_TYPE;\r
+\r
+typedef struct {\r
+  ///\r
+  /// The returned information associated with the requested TokenNumber. If\r
+  /// TokenNumber is 0, then PcdType is set to PCD_TYPE_8.\r
+  ///\r
+  PCD_TYPE          PcdType;\r
+  ///\r
+  /// The size of the data in bytes associated with the TokenNumber specified. If\r
+  /// TokenNumber is 0, then PcdSize is set 0.\r
+  ///\r
+  UINTN             PcdSize;\r
+  ///\r
+  /// The null-terminated ASCII string associated with a given token. If the\r
+  /// TokenNumber specified was 0, then this field corresponds to the null-terminated\r
+  /// ASCII string associated with the token's namespace Guid. If NULL, there is no\r
+  /// name associated with this request.\r
+  ///\r
+  CHAR8             *PcdName;\r
+} PCD_INFO;\r
+\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  If TokenNumber is not in the default token space specified, then ASSERT().\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfoEx (\r
+  IN CONST  GUID            *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  );\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetSku (\r
+  VOID\r
+  );\r
+\r
 #endif\r
index 5a06966a9794c1e55c9d9268eef325d1e8fac4fd..2aa4c276c484b9a7af231e2de4ba1b8b33d6bd0c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Include file matches things in PI for multiple module types.\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
@@ -133,4 +133,33 @@ typedef struct {
   UINT64                RegionState;\r
 } EFI_SMRAM_DESCRIPTOR;\r
 \r
+typedef enum {\r
+  EFI_PCD_TYPE_8,\r
+  EFI_PCD_TYPE_16,\r
+  EFI_PCD_TYPE_32,\r
+  EFI_PCD_TYPE_64,\r
+  EFI_PCD_TYPE_BOOL,\r
+  EFI_PCD_TYPE_PTR\r
+} EFI_PCD_TYPE;\r
+\r
+typedef struct {\r
+  ///\r
+  /// The returned information associated with the requested TokenNumber. If\r
+  /// TokenNumber is 0, then PcdType is set to EFI_PCD_TYPE_8.\r
+  ///\r
+  EFI_PCD_TYPE      PcdType;\r
+  ///\r
+  /// The size of the data in bytes associated with the TokenNumber specified. If\r
+  /// TokenNumber is 0, then PcdSize is set 0.\r
+  ///\r
+  UINTN             PcdSize;\r
+  ///\r
+  /// The null-terminated ASCII string associated with a given token. If the\r
+  /// TokenNumber specified was 0, then this field corresponds to the null-terminated\r
+  /// ASCII string associated with the token's namespace Guid. If NULL, there is no\r
+  /// name associated with this request.\r
+  ///\r
+  CHAR8             *PcdName;\r
+} EFI_PCD_INFO;\r
+\r
 #endif\r
diff --git a/MdePkg/Include/Ppi/PcdInfo.h b/MdePkg/Include/Ppi/PcdInfo.h
new file mode 100644 (file)
index 0000000..731f873
--- /dev/null
@@ -0,0 +1,105 @@
+/** @file\r
+  Native Platform Configuration Database (PCD) INFO PPI\r
+\r
+  The PPI that provides additional information about items that reside in the PCD database.\r
+  \r
+  Different with the EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 specification,\r
+  the native PCD INFO PPI provide interfaces for dynamic and dynamic-ex type PCD. \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) 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
+  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_INFO_PPI_H__\r
+#define __PCD_INFO_PPI_H__\r
+\r
+extern EFI_GUID gGetPcdInfoPpiGuid;\r
+\r
+#define GET_PCD_INFO_PPI_GUID \\r
+  { 0x4d8b155b, 0xc059, 0x4c8f, { 0x89, 0x26,  0x6, 0xfd, 0x43, 0x31, 0xdb, 0x8a } }\r
+\r
+///\r
+/// The forward declaration for GET_PCD_INFO_PPI.\r
+///\r
+typedef struct _GET_PCD_INFO_PPI  GET_PCD_INFO_PPI;\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token in the default token space.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_PCD_INFO_PPI_GET_INFO) (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+);\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_PCD_INFO_PPI_GET_INFO_EX) (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+);\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *GET_PCD_INFO_PPI_GET_SKU) (\r
+  VOID\r
+);\r
+\r
+///\r
+/// This is the PCD service to use when querying for some additional data that can be contained in the\r
+/// PCD database.\r
+///\r
+struct _GET_PCD_INFO_PPI {\r
+  ///\r
+  /// Retrieve additional information associated with a PCD.\r
+  ///\r
+  GET_PCD_INFO_PPI_GET_INFO             GetInfo;\r
+  GET_PCD_INFO_PPI_GET_INFO_EX          GetInfoEx;\r
+  ///\r
+  /// Retrieve the currently set SKU Id.\r
+  ///\r
+  GET_PCD_INFO_PPI_GET_SKU              GetSku;\r
+};\r
+\r
+#endif\r
+\r
diff --git a/MdePkg/Include/Ppi/PiPcdInfo.h b/MdePkg/Include/Ppi/PiPcdInfo.h
new file mode 100644 (file)
index 0000000..586f707
--- /dev/null
@@ -0,0 +1,82 @@
+/** @file\r
+  Platform Configuration Database (PCD) Info Ppi defined in PI 1.2.1 Vol3.\r
+\r
+  The PPI that provides additional information about items that reside in the PCD database.\r
+\r
+  Copyright (c) 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
+  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
+  @par Revision Reference:\r
+  PI Version 1.2.1 Vol 3.\r
+**/\r
+\r
+#ifndef __PI_PCD_INFO_PPI_H__\r
+#define __PI_PCD_INFO_PPI_H__\r
+\r
+extern EFI_GUID gEfiGetPcdInfoPpiGuid;\r
+\r
+#define EFI_GET_PCD_INFO_PPI_GUID \\r
+  { 0xa60c6b59, 0xe459, 0x425d, { 0x9c, 0x69,  0xb, 0xcc, 0x9c, 0xb2, 0x7d, 0x81 } }\r
+\r
+///\r
+/// The forward declaration for EFI_GET_PCD_INFO_PPI.\r
+///\r
+typedef struct _EFI_GET_PCD_INFO_PPI  EFI_GET_PCD_INFO_PPI;\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_PCD_INFO_PPI_GET_INFO) (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+);\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *EFI_GET_PCD_INFO_PPI_GET_SKU) (\r
+  VOID\r
+);\r
+\r
+///\r
+/// This is the PCD service to use when querying for some additional data that can be contained in the\r
+/// PCD database.\r
+///\r
+struct _EFI_GET_PCD_INFO_PPI {\r
+  ///\r
+  /// Retrieve additional information associated with a PCD.\r
+  ///\r
+  EFI_GET_PCD_INFO_PPI_GET_INFO         GetInfo;\r
+  ///\r
+  /// Retrieve the currently set SKU Id.\r
+  ///\r
+  EFI_GET_PCD_INFO_PPI_GET_SKU          GetSku;\r
+};\r
+\r
+#endif\r
+\r
diff --git a/MdePkg/Include/Protocol/PcdInfo.h b/MdePkg/Include/Protocol/PcdInfo.h
new file mode 100644 (file)
index 0000000..00edd1b
--- /dev/null
@@ -0,0 +1,105 @@
+/** @file\r
+  Native Platform Configuration Database (PCD) INFO PROTOCOL.\r
+\r
+  The protocol that provides additional information about items that reside in the PCD database.\r
+\r
+  Different with the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 specification,\r
+  the native PCD INFO PROTOCOL provide interfaces for dynamic and dynamic-ex type PCD. \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) 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
+  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_INFO_H__\r
+#define __PCD_INFO_H__\r
+\r
+extern EFI_GUID gGetPcdInfoProtocolGuid;\r
+\r
+#define GET_PCD_INFO_PROTOCOL_GUID \\r
+  { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } }\r
+\r
+///\r
+/// The forward declaration for GET_PCD_INFO_PROTOCOL.\r
+///\r
+typedef struct _GET_PCD_INFO_PROTOCOL  GET_PCD_INFO_PROTOCOL;\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_PCD_INFO_PROTOCOL_GET_INFO) (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+);\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_PCD_INFO_PROTOCOL_GET_INFO_EX) (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+);\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *GET_PCD_INFO_PROTOCOL_GET_SKU) (\r
+  VOID\r
+);\r
+\r
+///\r
+/// This is the PCD service to use when querying for some additional data that can be contained in the\r
+/// PCD database.\r
+///\r
+struct _GET_PCD_INFO_PROTOCOL {\r
+  ///\r
+  /// Retrieve additional information associated with a PCD.\r
+  ///\r
+  GET_PCD_INFO_PROTOCOL_GET_INFO             GetInfo;\r
+  GET_PCD_INFO_PROTOCOL_GET_INFO_EX          GetInfoEx;\r
+  ///\r
+  /// Retrieve the currently set SKU Id.\r
+  ///\r
+  GET_PCD_INFO_PROTOCOL_GET_SKU              GetSku;\r
+};\r
+\r
+#endif\r
+\r
diff --git a/MdePkg/Include/Protocol/PiPcdInfo.h b/MdePkg/Include/Protocol/PiPcdInfo.h
new file mode 100644 (file)
index 0000000..3c43075
--- /dev/null
@@ -0,0 +1,83 @@
+/** @file\r
+  Platform Configuration Database (PCD) Info Protocol defined in PI 1.2.1 Vol3.\r
+\r
+  The protocol that provides additional information about items that reside in the PCD database.\r
+\r
+  Copyright (c) 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
+  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
+  @par Revision Reference:\r
+  PI Version 1.2.1 Vol 3.\r
+**/\r
+\r
+#ifndef __PI_PCD_INFO_H__\r
+#define __PI_PCD_INFO_H__\r
+\r
+extern EFI_GUID gEfiGetPcdInfoProtocolGuid;\r
+\r
+#define EFI_GET_PCD_INFO_PROTOCOL_GUID \\r
+  { 0xfd0f4478,  0xefd, 0x461d, { 0xba, 0x2d, 0xe5, 0x8c, 0x45, 0xfd, 0x5f, 0x5e } }\r
+\r
+///\r
+/// The forward declaration for EFI_GET_PCD_INFO_PROTOCOL.\r
+///\r
+typedef struct _EFI_GET_PCD_INFO_PROTOCOL  EFI_GET_PCD_INFO_PROTOCOL;\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+\r
+  @retval  EFI_SUCCESS      The PCD information was returned successfully\r
+  @retval  EFI_NOT_FOUND    The PCD service could not find the requested token number.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_PCD_INFO_PROTOCOL_GET_INFO) (\r
+  IN CONST  EFI_GUID        *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       EFI_PCD_INFO    *PcdInfo\r
+);\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *EFI_GET_PCD_INFO_PROTOCOL_GET_SKU) (\r
+  VOID\r
+);\r
+\r
+///\r
+/// Callers to this protocol must be at a TPL_APPLICATION task priority level.\r
+/// This is the PCD service to use when querying for some additional data that can be contained in the\r
+/// PCD database.\r
+///\r
+struct _EFI_GET_PCD_INFO_PROTOCOL {\r
+  ///\r
+  /// Retrieve additional information associated with a PCD.\r
+  ///\r
+  EFI_GET_PCD_INFO_PROTOCOL_GET_INFO    GetInfo;\r
+  ///\r
+  /// Retrieve the currently set SKU Id.\r
+  ///\r
+  EFI_GET_PCD_INFO_PROTOCOL_GET_SKU     GetSku;\r
+};\r
+\r
+#endif\r
+\r
index 4823f5ad6716da6fe006632e76e2b27f490ffd01..8333aaa3f96aa96aefbc3185c4562aeb08c296a5 100644 (file)
@@ -919,3 +919,69 @@ LibPatchPcdSetPtr (
   return (VOID *) Buffer;\r
 }\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  If TokenNumber is not in the default token space specified, then ASSERT().\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfoEx (\r
+  IN CONST  GUID            *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetSku (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+\r
+  return 0;\r
+}\r
+\r
index cd8212824fc74d773c2107221fd7ac87f8168dd3..bc87c4e6a153fd0aafc990ef283787aba277fe82 100644 (file)
@@ -18,17 +18,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Protocol/Pcd.h>\r
 #include <Protocol/PiPcd.h>\r
+#include <Protocol/PcdInfo.h>\r
+#include <Protocol/PiPcdInfo.h>\r
 \r
 #include <Library/PcdLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 \r
-PCD_PROTOCOL     *mPcd   = NULL;\r
-EFI_PCD_PROTOCOL *mPiPcd = NULL;\r
+PCD_PROTOCOL                *mPcd       = NULL;\r
+EFI_PCD_PROTOCOL            *mPiPcd     = NULL;\r
+GET_PCD_INFO_PROTOCOL       *mPcdInfo   = NULL;\r
+EFI_GET_PCD_INFO_PROTOCOL   *mPiPcdInfo = NULL;\r
 \r
 /**\r
   Retrieves the PI PCD protocol from the handle database.\r
+\r
+  @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL.\r
 **/\r
 EFI_PCD_PROTOCOL *\r
 EFIAPI\r
@@ -52,6 +58,8 @@ GetPiPcdProtocol (
 \r
 /**\r
   Retrieves the PCD protocol from the handle database.\r
+\r
+  @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL.\r
 **/\r
 PCD_PROTOCOL *\r
 EFIAPI\r
@@ -73,6 +81,45 @@ GetPcdProtocol (
   return mPcd;\r
 }\r
 \r
+/**\r
+  Retrieves the PI PCD info protocol from the handle database.\r
+\r
+  @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3.\r
+**/\r
+EFI_GET_PCD_INFO_PROTOCOL *\r
+GetPiPcdInfoProtocolPointer (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mPiPcdInfo == NULL) {\r
+    Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo);\r
+    ASSERT_EFI_ERROR (Status);\r
+    ASSERT (mPiPcdInfo != NULL);\r
+  }\r
+  return mPiPcdInfo;\r
+}\r
+\r
+/**\r
+  Retrieves the PCD info protocol from the handle database.\r
+\r
+  @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL.\r
+**/\r
+GET_PCD_INFO_PROTOCOL *\r
+GetPcdInfoProtocolPointer (\r
+  VOID\r
+  ) \r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mPcdInfo == NULL) {\r
+    Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo);\r
+    ASSERT_EFI_ERROR (Status);\r
+    ASSERT (mPcdInfo != NULL);\r
+  }\r
+  return mPcdInfo;\r
+}\r
 \r
 /**\r
   This function provides a means by which SKU support can be established in the PCD infrastructure.\r
@@ -1037,5 +1084,78 @@ LibPatchPcdSetPtr (
   return (VOID *) Buffer;\r
 }\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  If TokenNumber is not in the default token space specified, then ASSERT().\r
 \r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  Status = GetPcdInfoProtocolPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfoEx (\r
+  IN CONST  GUID            *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  Status = GetPiPcdInfoProtocolPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetSku (\r
+  VOID\r
+  )\r
+{\r
+  UINTN SkuId;\r
+\r
+  SkuId = GetPiPcdInfoProtocolPointer()->GetSku ();\r
+  ASSERT (SkuId < PCD_MAX_SKU_ID);\r
+\r
+  return SkuId;\r
+}\r
 \r
index db06967c9a059181871ce46ae19612b16829b67e..a520f069bd6b71aeaf8f0557093f1e21fb0c9c6f 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Instance of PCD Library using PCD Protocol.\r
 #\r
-# There are two PCD PPIs as follows:\r
+# There are two PCD PROTOCOLs as follows:\r
 #   1) PCD_PROTOCOL\r
 #      It is EDKII implementation which support Dynamic/DynamicEx Pcds.\r
 #   2) EFI_PCD_PROTOCOL\r
@@ -13,7 +13,7 @@
 # This library instance uses the PCD_PROTOCOL to handle dynamic PCD request and use\r
 # EFI_PCD_PROTOCOL to handle dynamicEx type PCD.\r
 #\r
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 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
@@ -54,6 +54,8 @@
 [Protocols]\r
   gPcdProtocolGuid                              ## CONSUMES\r
   gEfiPcdProtocolGuid                           ## CONSUMES\r
+  gGetPcdInfoProtocolGuid                       ## SOMETIMES_CONSUMES\r
+  gEfiGetPcdInfoProtocolGuid                    ## SOMETIMES_CONSUMES\r
 \r
 [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER]\r
   gEfiPcdProtocolGuid\r
index 0a7efdb44ec2160ff628985ff6cd06cef53c4091..a57751f412990038820a3ac2a84d7696570be38e 100644 (file)
@@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Ppi/Pcd.h>\r
 #include <Ppi/PiPcd.h>\r
+#include <Ppi/PcdInfo.h>\r
+#include <Ppi/PiPcdInfo.h>\r
 \r
 #include <Library/PeiServicesLib.h>\r
 #include <Library/PcdLib.h>\r
@@ -71,7 +73,53 @@ GetPiPcdPpiPointer (
   \r
   return PiPcdPpi;\r
 }  \r
+\r
+/**\r
+  Retrieve the GET_PCD_INFO_PPI pointer.\r
+\r
+  This function is to locate GET_PCD_INFO_PPI PPI via PeiService. \r
+  If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
+\r
+  @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI.\r
+\r
+**/\r
+GET_PCD_INFO_PPI *\r
+GetPcdInfoPpiPointer (\r
+  VOID\r
+  ) \r
+{\r
+  EFI_STATUS            Status;\r
+  GET_PCD_INFO_PPI      *PcdInfoPpi;\r
+  \r
+  Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return PcdInfoPpi;\r
+}\r
+\r
+/**\r
+  Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3.\r
+\r
+  This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService. \r
+  If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR().\r
+\r
+  @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI.\r
+\r
+**/\r
+EFI_GET_PCD_INFO_PPI *\r
+GetPiPcdInfoPpiPointer (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_GET_PCD_INFO_PPI  *PiPcdInfoPpi;\r
   \r
+  Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  return PiPcdInfoPpi;\r
+}  \r
+\r
 /**\r
   This function provides a means by which SKU support can be established in the PCD infrastructure.\r
 \r
@@ -1044,4 +1092,77 @@ LibPatchPcdSetPtr (
   return (VOID *) Buffer;\r
 }\r
 \r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
 \r
+  If TokenNumber is not in the default token space specified, then ASSERT().\r
+\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfo (\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Retrieve additional information associated with a PCD token.\r
+\r
+  This includes information such as the type of value the TokenNumber is associated with as well as possible\r
+  human readable name that is associated with the token.\r
+\r
+  If TokenNumber is not in the token space specified by Guid, then ASSERT().\r
+\r
+  @param[in]    Guid        The 128-bit unique value that designates the namespace from which to extract the value.\r
+  @param[in]    TokenNumber The PCD token number.\r
+  @param[out]   PcdInfo     The returned information associated with the requested TokenNumber.\r
+                            The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.\r
+**/\r
+VOID\r
+EFIAPI\r
+LibPcdGetInfoEx (\r
+  IN CONST  GUID            *Guid,\r
+  IN        UINTN           TokenNumber,\r
+  OUT       PCD_INFO        *PcdInfo\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Retrieve the currently set SKU Id.\r
+\r
+  If the sku id got >= PCD_MAX_SKU_ID, then ASSERT().\r
+\r
+  @return   The currently set SKU Id. If the platform has not set at a SKU Id, then the\r
+            default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU\r
+            Id is returned.\r
+**/\r
+UINTN\r
+EFIAPI\r
+LibPcdGetSku (\r
+  VOID\r
+  )\r
+{\r
+  UINTN SkuId;\r
+\r
+  SkuId = GetPiPcdInfoPpiPointer()->GetSku ();\r
+  ASSERT (SkuId < PCD_MAX_SKU_ID);\r
+\r
+  return SkuId;\r
+}\r
index 814c8f6a9bc6f3a0c632d0f6a6242ad868b2b793..b9d88eff82b0b916790c07b281d6656d52c1b949 100644 (file)
@@ -15,7 +15,7 @@
 #\r
 # PCD Library that uses the PCD PPI to access Dynamic and DynamicEx PCD entries\r
 #\r
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 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
@@ -57,7 +57,9 @@
 [Ppis]\r
   gPcdPpiGuid                                   ## CONSUMES\r
   gEfiPeiPcdPpiGuid                             ## CONSUMES\r
-  \r
+  gGetPcdInfoPpiGuid                            ## SOMETIMES_CONSUMES\r
+  gEfiGetPcdInfoPpiGuid                         ## SOMETIMES_CONSUMES\r
+\r
 [Depex.common.PEIM]\r
   gEfiPeiPcdPpiGuid\r
-  
\ No newline at end of file
+  \r
index 35bc7a41f28d30b62961070dc1ba66c5abd4c254..b02cf0b28c48299a5b3b02d7b6b6959751192f50 100644 (file)
   ## Include/Ppi/Pcd.h\r
   gPcdPpiGuid = { 0x6e81c58, 0x4ad7, 0x44bc, { 0x83, 0x90, 0xf1, 0x2, 0x65, 0xf7, 0x24, 0x80 } }\r
 \r
+  ## Include/Ppi/PcdInfo.h\r
+  gGetPcdInfoPpiGuid                 = { 0x4d8b155b, 0xc059, 0x4c8f, { 0x89, 0x26,  0x6, 0xfd, 0x43, 0x31, 0xdb, 0x8a } }\r
+\r
   #\r
   # PPIs defined in PI 1.2.\r
   #\r
   ## Include/Ppi/FirmwareVolumeInfo2.h\r
   gEfiPeiFirmwareVolumeInfo2PpiGuid  = { 0xea7ca24b, 0xded5, 0x4dad, { 0xa3, 0x89, 0xbf, 0x82, 0x7e, 0x8f, 0x9b, 0x38 } }\r
 \r
+\r
+  #\r
+  # PPIs defined in PI 1.2.1.\r
+  #\r
+\r
+  ## Include/Ppi/PiPcdInfo.h\r
+  gEfiGetPcdInfoPpiGuid              = { 0xa60c6b59, 0xe459, 0x425d, { 0x9c, 0x69,  0xb, 0xcc, 0x9c, 0xb2, 0x7d, 0x81 } }\r
+\r
 [Protocols]\r
+  ## Include/Protocol/Pcd.h\r
+  gPcdProtocolGuid               = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}\r
+\r
+  ## Include/Protocol/PcdInfo.h\r
+  gGetPcdInfoProtocolGuid        = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } }\r
+\r
   #\r
   # Protocols defined in PI1.0.\r
   #\r
   gEfiExtendedSalMcaLogServicesProtocolGuid = { 0xcb3fd86e, 0x38a3, 0x4c03, {0x9a, 0x5c, 0x90, 0xcf, 0xa3, 0xa2, 0xab, 0x7a } }\r
 \r
   #\r
-  # Protocols defined in PI1.2.1\r
+  # Protocols defined in PI 1.2.1\r
   #\r
+\r
   ## Include/Protocol/Security2.h\r
   gEfiSecurity2ArchProtocolGuid   = { 0x94ab2f58, 0x1438, 0x4ef1, {0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68 } }\r
 \r
-  #\r
-  # Protocols defined in PI 1.2.1\r
-  #\r
-\r
   ## Include/Protocol/SmmEndOfDxe.h\r
   gEfiSmmEndOfDxeProtocolGuid = { 0x24e70042, 0xd5c5, 0x4260, { 0x8c, 0x39, 0xa, 0xd3, 0xaa, 0x32, 0xe9, 0x3d }}\r
 \r
+  ## Include/Protocol/PiPcdInfo.h\r
+  gEfiGetPcdInfoProtocolGuid      = { 0xfd0f4478,  0xefd, 0x461d, { 0xba, 0x2d, 0xe5, 0x8c, 0x45, 0xfd, 0x5f, 0x5e } }\r
+\r
   #\r
   # Protocols defined in PI 1.3.\r
   #\r
   ## Include/Protocol/Hash.h\r
   gEfiHashProtocolGuid           = { 0xC5184932, 0xDBA5, 0x46DB, { 0xA5, 0xBA, 0xCC, 0x0B, 0xDA, 0x9C, 0x14, 0x35 }}\r
 \r
-  ## Include/Protocol/Pcd.h\r
-  gPcdProtocolGuid               = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}\r
-\r
   ## Include/Protocol/TcgService.h\r
   gEfiTcgProtocolGuid            = { 0xf541796d, 0xa62e, 0x4954, { 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd }}\r
 \r