]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Dxe/Pcd.c
MdePkg and MdeModulePkg Pcd: Add the new EFI_GET_PCD_INFO_PROTOCOL and EFI_GET_PCD_IN...
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Pcd.c
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