]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Allow DxeIpl to load without permanent memory
authorCohen, Eugene <eugene@hp.com>
Tue, 8 Dec 2015 14:42:52 +0000 (14:42 +0000)
committerStar Zeng <star.zeng@intel.com>
Mon, 30 May 2016 01:31:53 +0000 (09:31 +0800)
PI1.4a spec added "For S3 resume boot modes DXE IPL must be
prepared to execute without permanent memory installed and
invoke the S3 resume modules."

To follow PI1.4a spec, this patch is to update DxeIpl and
PeiCore to enable S3 resume from temporary memory.
The normal boot path still enforces the permanent memory
requirement.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eugene Cohen <eugene@hp.com>
Signed-off-by: Star Zeng <star.zeng@intel.com>
Tested-by: Katie Dellaquila <katie.dellaquila@hp.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c

index 75372ace8dd6890c0d53da50bfed0e1893a9fd08..72d2532f50a0c08e7afb87ddb4da74162522b80d 100644 (file)
@@ -2,7 +2,7 @@
   Master header file for DxeIpl PEIM. All source files in this module should\r
   include this file for common definitions.\r
 \r
-Copyright (c) 2006 - 2013, 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
@@ -58,6 +58,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi;\r
 \r
+/**\r
+   This function installs the PPIs that require permanent memory.\r
+\r
+   @param  PeiServices      Indirect reference to the PEI Services Table.\r
+   @param  NotifyDescriptor Address of the notification descriptor data structure.\r
+   @param  Ppi              Address of the PPI that was installed.\r
+\r
+   @return EFI_SUCCESS      The PPIs were installed successfully.\r
+   @return Others           Some error occurs during the execution of this function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InstallIplPermanentMemoryPpis (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,\r
+  IN VOID                       *Ppi\r
+  );\r
 \r
 /**\r
    Searches DxeCore in all firmware Volumes and loads the first\r
index 04ad928c9f84fc4c4fb53c51b43304963232aa74..79f70d1a7c3c665e90bcafceb095d09e30194dc4 100644 (file)
@@ -5,7 +5,7 @@
 #  PPI to discover and dispatch the DXE Foundation and components that are\r
 #  needed to run the DXE Foundation.\r
 #\r
-#  Copyright (c) 2006 - 2015, 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
@@ -93,6 +93,7 @@
   ## SOMETIMES_CONSUMES\r
   ## UNDEFINED # HOB\r
   gEfiVectorHandoffInfoPpiGuid\r
+  gEfiPeiMemoryDiscoveredPpiGuid    ## SOMETIMES_CONSUMES\r
 \r
 [Guids]\r
   ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack               ## SOMETIMES_CONSUMES\r
 \r
 [Depex]\r
-  gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiLoadFilePpiGuid AND gEfiPeiMasterBootModePpiGuid\r
+  gEfiPeiLoadFilePpiGuid AND gEfiPeiMasterBootModePpiGuid\r
 \r
 #\r
 # [BootMode]\r
index d7d693fdeb40350c8a3f9d1acad1fe0303cbd188..50b5440d15035ffe3cd121e51301ed2d55db2c10 100644 (file)
@@ -2,7 +2,8 @@
   Last PEIM.\r
   Responsibility of this module is to load the DXE Core from a Firmware Volume.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2016 HP Development Company, L.P.\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
@@ -24,6 +25,12 @@ CONST EFI_DXE_IPL_PPI mDxeIplPpi = {
   DxeLoadCore\r
 };\r
 \r
+CONST EFI_PEI_PPI_DESCRIPTOR mDxeIplPpiList = {\r
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+  &gEfiDxeIplPpiGuid,\r
+  (VOID *) &mDxeIplPpi\r
+};\r
+\r
 CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomGuidedSectionExtractionPpi = {\r
   CustomGuidedSectionExtract\r
 };\r
@@ -32,17 +39,10 @@ CONST EFI_PEI_DECOMPRESS_PPI mDecompressPpi = {
   Decompress\r
 };\r
 \r
-CONST EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {\r
-  {\r
-    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
-    &gEfiDxeIplPpiGuid,\r
-    (VOID *) &mDxeIplPpi\r
-  },\r
-  {\r
-    (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-    &gEfiPeiDecompressPpiGuid,\r
-    (VOID *) &mDecompressPpi\r
-  }\r
+CONST EFI_PEI_PPI_DESCRIPTOR mDecompressPpiList = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiDecompressPpiGuid,\r
+  (VOID *) &mDecompressPpi\r
 };\r
 \r
 CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {\r
@@ -51,10 +51,16 @@ CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {
   NULL\r
 };\r
 \r
+CONST EFI_PEI_NOTIFY_DESCRIPTOR mMemoryDiscoveredNotifyList = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiMemoryDiscoveredPpiGuid,\r
+  InstallIplPermanentMemoryPpis\r
+};\r
+\r
 /**\r
   Entry point of DXE IPL PEIM.\r
-  \r
-  This function installs DXE IPL PPI and Decompress PPI.  It also reloads\r
+\r
+  This function installs DXE IPL PPI.  It also reloads\r
   itself to memory on non-S3 resume boot path.\r
 \r
   @param  FileHandle  Handle of the file being invoked.\r
@@ -73,10 +79,8 @@ PeimInitializeDxeIpl (
 {\r
   EFI_STATUS                                Status;\r
   EFI_BOOT_MODE                             BootMode;\r
-  EFI_GUID                                  *ExtractHandlerGuidTable;\r
-  UINTN                                     ExtractHandlerNumber;\r
-  EFI_PEI_PPI_DESCRIPTOR                    *GuidPpi;\r
-  \r
+  VOID                                      *Dummy;\r
+\r
   BootMode = GetBootModeHob ();\r
 \r
   if (BootMode != BOOT_ON_S3_RESUME) {\r
@@ -87,20 +91,81 @@ PeimInitializeDxeIpl (
       // \r
       return Status;\r
     }\r
-    \r
+\r
     //\r
     // Ensure that DXE IPL is shadowed to permanent memory.\r
     //\r
     ASSERT (Status == EFI_ALREADY_STARTED);\r
+\r
+    //\r
+    // DXE core load requires permanent memory.\r
+    //\r
+    Status = PeiServicesLocatePpi (\r
+               &gEfiPeiMemoryDiscoveredPpiGuid,\r
+               0,\r
+               NULL,\r
+               (VOID **) &Dummy\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    //\r
+    // Now the permanent memory exists, install the PPIs for decompression\r
+    // and section extraction.\r
+    //\r
+    Status = InstallIplPermanentMemoryPpis (NULL, NULL, NULL);\r
+    ASSERT_EFI_ERROR (Status);    \r
+  } else {\r
+    //\r
+    // Install memory discovered PPI notification to install PPIs for\r
+    // decompression and section extraction.\r
+    //\r
+    Status = PeiServicesNotifyPpi (&mMemoryDiscoveredNotifyList);\r
+    ASSERT_EFI_ERROR (Status);\r
   }\r
-     \r
+\r
+  //\r
+  // Install DxeIpl PPI.\r
+  //\r
+  Status = PeiServicesInstallPpi (&mDxeIplPpiList);\r
+  ASSERT_EFI_ERROR(Status);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+   This function installs the PPIs that require permanent memory.\r
+\r
+   @param  PeiServices      Indirect reference to the PEI Services Table.\r
+   @param  NotifyDescriptor Address of the notification descriptor data structure.\r
+   @param  Ppi              Address of the PPI that was installed.\r
+\r
+   @return EFI_SUCCESS      The PPIs were installed successfully.\r
+   @return Others           Some error occurs during the execution of this function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InstallIplPermanentMemoryPpis (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,\r
+  IN VOID                       *Ppi\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_GUID                      *ExtractHandlerGuidTable;\r
+  UINTN                         ExtractHandlerNumber;\r
+  EFI_PEI_PPI_DESCRIPTOR        *GuidPpi;\r
+\r
   //\r
   // Get custom extract guided section method guid list \r
   //\r
   ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);\r
-  \r
+\r
   //\r
-  // Install custom extraction guid PPI\r
+  // Install custom guided section extraction PPI\r
   //\r
   if (ExtractHandlerNumber > 0) {\r
     GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR));\r
@@ -113,11 +178,11 @@ PeimInitializeDxeIpl (
       ASSERT_EFI_ERROR(Status);\r
     }\r
   }\r
-  \r
+\r
   //\r
-  // Install DxeIpl and Decompress PPIs.\r
+  // Install Decompress PPI.\r
   //\r
-  Status = PeiServicesInstallPpi (mPpiList);\r
+  Status = PeiServicesInstallPpi (&mDecompressPpiList);\r
   ASSERT_EFI_ERROR(Status);\r
 \r
   return Status;\r
index d36f89c3dd0d99eefca999a897ef0ab984d1fdf1..10db496140ad0d6f5820f72c08fedb63572d6019 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Main Entry Point\r
   \r
-Copyright (c) 2006 - 2015, 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
@@ -420,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