]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Pei/Pcd.c
MdeModulePkg PCD: Reinstall PCD service PPIS when memory available
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Pcd.c
index e552e151760a9cf48c129d24dcbed361deaf3cc4..f31e0be35f2f53bd9fc9ad646e60c5274d928277 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
   All Pcd Ppi services are implemented here.\r
 \r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -345,6 +339,75 @@ PcdPeimInit (
 {\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