+EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiSignalPpiNotifyList[] = {\r
+ {\r
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+ &gEfiEndOfPeiSignalPpiGuid,\r
+ EndOfPeiSignalPpiNotifyCallback\r
+ }\r
+};\r
+\r
+/**\r
+ Main entry for PCD PEIM driver.\r
+\r
+ This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.\r
+\r
+ @param FileHandle Handle of the file being invoked.\r
+ @param PeiServices Describes the list of possible PEI Services.\r
+\r
+ @return Status of install PCD_PPI\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PcdPeimInit (\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ IN CONST EFI_PEI_SERVICES **PeiServices\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = PeiServicesRegisterForShadow (FileHandle);\r
+ if (Status == EFI_ALREADY_STARTED) {\r
+ //\r
+ // This is now starting in memory, the second time starting.\r
+ //\r
+ EFI_PEI_PPI_DESCRIPTOR *OldPpiList;\r
+ EFI_PEI_PPI_DESCRIPTOR *OldPpiList2;\r
+ VOID *Ppi;\r
+ VOID *Ppi2;\r
+\r
+ OldPpiList = NULL;\r
+ Status = PeiServicesLocatePpi (\r
+ &gPcdPpiGuid,\r
+ 0,\r
+ &OldPpiList,\r
+ &Ppi\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (OldPpiList != NULL) {\r
+ Status = PeiServicesReInstallPpi (OldPpiList, &mPpiList[0]);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ OldPpiList2 = NULL;\r
+ Status = PeiServicesLocatePpi (\r
+ &gGetPcdInfoPpiGuid,\r
+ 0,\r
+ &OldPpiList2,\r
+ &Ppi2\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (OldPpiList2 != NULL) {\r
+ Status = PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[0]);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ OldPpiList = NULL;\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiPcdPpiGuid,\r
+ 0,\r
+ &OldPpiList,\r
+ &Ppi\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (OldPpiList != NULL) {\r
+ Status = PeiServicesReInstallPpi (OldPpiList, &mPpiList[1]);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ OldPpiList2 = NULL;\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiGetPcdInfoPpiGuid,\r
+ 0,\r
+ &OldPpiList2,\r
+ &Ppi2\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (OldPpiList2 != NULL) {\r
+ Status = PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[1]);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ return Status;\r
+ }\r
+\r
+ 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
+ // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.\r
+ //\r
+ Status = PeiServicesInstallPpi (&mPpiList2[0]);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = PeiServicesNotifyPpi (&mEndOfPeiSignalPpiNotifyList[0]);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = PeiRegisterCallBackOnSet (\r
+ &gEfiMdeModulePkgTokenSpaceGuid,\r
+ PcdToken (PcdSetNvStoreDefaultId),\r
+ PcdSetNvStoreDefaultIdCallBack\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\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
+ return (UINTN)GetPcdDatabase ()->SystemSkuId;\r
+}\r
+\r
+/**\r
+ Sets the SKU value for subsequent calls to set or get PCD token values.\r
+\r
+ SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.\r
+ SetSku() is normally called only once by the system.\r
+\r
+ For each item (token), the database can hold a single value that applies to all SKUs,\r
+ or multiple values, where each value is associated with a specific SKU Id. Items with multiple,\r
+ SKU-specific values are called SKU enabled.\r
+\r
+ The SKU Id of zero is reserved as a default.\r
+ For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the\r
+ single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the\r
+ last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,\r
+ the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been\r
+ set for that Id, the results are unpredictable.\r
+\r
+ @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and\r
+ set values associated with a PCD token.\r
+\r
+**/\r