]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
MdeModulePkg: Allow DxeIpl to load without permanent memory
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
index 3220ffb8eecb9816ade75f92318fafc86140e50a..10db496140ad0d6f5820f72c08fedb63572d6019 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Main Entry Point\r
   \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, 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
@@ -63,7 +63,8 @@ EFI_PEI_SERVICES  gPs = {
   PeiFfsGetVolumeInfo,\r
   PeiRegisterForShadow,\r
   PeiFfsFindSectionData3,\r
-  PeiFfsGetFileInfo2\r
+  PeiFfsGetFileInfo2,\r
+  PeiResetSystem2\r
 };\r
 \r
 /**\r
@@ -258,7 +259,11 @@ PeiCore (
       // Shadow PEI Core. When permanent memory is avaiable, shadow\r
       // PEI Core and PEIMs to get high performance.\r
       //\r
-      OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);\r
+      OldCoreData->ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) PeiCore;\r
+      if ((HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnS3Boot))\r
+          || (HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnBoot))) {\r
+        OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);\r
+      }\r
       \r
       //\r
       // PEI Core has now been shadowed to memory.  Restart PEI Core in memory.\r
@@ -415,10 +420,12 @@ PeiCore (
   //\r
   PeiDispatcher (SecCoreData, &PrivateData);\r
 \r
-  //\r
-  // Check if InstallPeiMemory service was called.\r
-  //\r
-  ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
+  if (PrivateData.HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) {\r
+    //\r
+    // Check if InstallPeiMemory service was called on non-S3 resume boot path.\r
+    //\r
+    ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
+  }\r
 \r
   //\r
   // Measure PEI Core execution time.\r
@@ -436,6 +443,17 @@ PeiCore (
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Report status code to indicate DXE IPL PPI could not be found.\r
+    //\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MAJOR,\r
+      (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_EC_DXEIPL_NOT_FOUND)\r
+      );\r
+    CpuDeadLoop ();\r
+  }\r
+\r
   //\r
   // Enter DxeIpl to load Dxe core.\r
   //\r