From: "Cohen, Eugene" <[email protected]> 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. V3: The V3 patch is developed based on the discussion at http://article.gmane.org/gmane.comp.bios.edk2.devel/5606, it installs custom guided section extraction guid PPI and decompression PPI on S3 resume boot path in memory discovered PPI notification. Cc: Liming Gao <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eugene Cohen <[email protected]> Signed-off-by: Star Zeng <[email protected]> Tested-by: Katie Dellaquila <[email protected]> --- MdeModulePkg/Core/DxeIplPeim/DxeIpl.h | 18 +++++ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 3 +- MdeModulePkg/Core/DxeIplPeim/DxeLoad.c | 115 +++++++++++++++++++++++++------- MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 10 +-- 4 files changed, 116 insertions(+), 30 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h index 75372ace8dd6..30e24bc85087 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h @@ -58,6 +58,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi; +/** + This function installs the PPIs that require permanent memory. + + @param PeiServices Indirect reference to the PEI Services Table. + @param NotifyDescriptor Address of the notification descriptor data structure. + @param Ppi Address of the PPI that was installed. + + @return EFI_SUCCESS The PPIs were installed successfully. + @return Others Some error occurs during the execution of this function. + +**/ +EFI_STATUS +EFIAPI +InstallIplPermanentMemoryPpis ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ); /** Searches DxeCore in all firmware Volumes and loads the first diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf index 04ad928c9f84..0e9badf81808 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf @@ -93,6 +93,7 @@ [Ppis] ## SOMETIMES_CONSUMES ## UNDEFINED # HOB gEfiVectorHandoffInfoPpiGuid + gEfiPeiMemoryDiscoveredPpiGuid ## SOMETIMES_CONSUMES [Guids] ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation" @@ -115,7 +116,7 @@ [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64] gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES [Depex] - gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiLoadFilePpiGuid AND gEfiPeiMasterBootModePpiGuid + gEfiPeiLoadFilePpiGuid AND gEfiPeiMasterBootModePpiGuid # # [BootMode] diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c index d7d693fdeb40..50b5440d1503 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c +++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c @@ -2,7 +2,8 @@ Last PEIM. Responsibility of this module is to load the DXE Core from a Firmware Volume. -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2016 HP Development Company, L.P. +Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -24,6 +25,12 @@ CONST EFI_DXE_IPL_PPI mDxeIplPpi = { DxeLoadCore }; +CONST EFI_PEI_PPI_DESCRIPTOR mDxeIplPpiList = { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gEfiDxeIplPpiGuid, + (VOID *) &mDxeIplPpi +}; + CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomGuidedSectionExtractionPpi = { CustomGuidedSectionExtract }; @@ -32,17 +39,10 @@ CONST EFI_PEI_DECOMPRESS_PPI mDecompressPpi = { Decompress }; -CONST EFI_PEI_PPI_DESCRIPTOR mPpiList[] = { - { - EFI_PEI_PPI_DESCRIPTOR_PPI, - &gEfiDxeIplPpiGuid, - (VOID *) &mDxeIplPpi - }, - { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiDecompressPpiGuid, - (VOID *) &mDecompressPpi - } +CONST EFI_PEI_PPI_DESCRIPTOR mDecompressPpiList = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiDecompressPpiGuid, + (VOID *) &mDecompressPpi }; CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = { @@ -51,10 +51,16 @@ CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = { NULL }; +CONST EFI_PEI_NOTIFY_DESCRIPTOR mMemoryDiscoveredNotifyList = { + (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiMemoryDiscoveredPpiGuid, + InstallIplPermanentMemoryPpis +}; + /** Entry point of DXE IPL PEIM. - - This function installs DXE IPL PPI and Decompress PPI. It also reloads + + This function installs DXE IPL PPI. It also reloads itself to memory on non-S3 resume boot path. @param FileHandle Handle of the file being invoked. @@ -73,10 +79,8 @@ PeimInitializeDxeIpl ( { EFI_STATUS Status; EFI_BOOT_MODE BootMode; - EFI_GUID *ExtractHandlerGuidTable; - UINTN ExtractHandlerNumber; - EFI_PEI_PPI_DESCRIPTOR *GuidPpi; - + VOID *Dummy; + BootMode = GetBootModeHob (); if (BootMode != BOOT_ON_S3_RESUME) { @@ -87,20 +91,81 @@ PeimInitializeDxeIpl ( // return Status; } - + // // Ensure that DXE IPL is shadowed to permanent memory. // ASSERT (Status == EFI_ALREADY_STARTED); + + // + // DXE core load requires permanent memory. + // + Status = PeiServicesLocatePpi ( + &gEfiPeiMemoryDiscoveredPpiGuid, + 0, + NULL, + (VOID **) &Dummy + ); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Now the permanent memory exists, install the PPIs for decompression + // and section extraction. + // + Status = InstallIplPermanentMemoryPpis (NULL, NULL, NULL); + ASSERT_EFI_ERROR (Status); + } else { + // + // Install memory discovered PPI notification to install PPIs for + // decompression and section extraction. + // + Status = PeiServicesNotifyPpi (&mMemoryDiscoveredNotifyList); + ASSERT_EFI_ERROR (Status); } - + + // + // Install DxeIpl PPI. + // + Status = PeiServicesInstallPpi (&mDxeIplPpiList); + ASSERT_EFI_ERROR(Status); + + return Status; +} + +/** + This function installs the PPIs that require permanent memory. + + @param PeiServices Indirect reference to the PEI Services Table. + @param NotifyDescriptor Address of the notification descriptor data structure. + @param Ppi Address of the PPI that was installed. + + @return EFI_SUCCESS The PPIs were installed successfully. + @return Others Some error occurs during the execution of this function. + +**/ +EFI_STATUS +EFIAPI +InstallIplPermanentMemoryPpis ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) +{ + EFI_STATUS Status; + EFI_GUID *ExtractHandlerGuidTable; + UINTN ExtractHandlerNumber; + EFI_PEI_PPI_DESCRIPTOR *GuidPpi; + // // Get custom extract guided section method guid list // ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable); - + // - // Install custom extraction guid PPI + // Install custom guided section extraction PPI // if (ExtractHandlerNumber > 0) { GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR)); @@ -113,11 +178,11 @@ PeimInitializeDxeIpl ( ASSERT_EFI_ERROR(Status); } } - + // - // Install DxeIpl and Decompress PPIs. + // Install Decompress PPI. // - Status = PeiServicesInstallPpi (mPpiList); + Status = PeiServicesInstallPpi (&mDecompressPpiList); ASSERT_EFI_ERROR(Status); return Status; diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c index d36f89c3dd0d..09b16492fe94 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -420,10 +420,12 @@ PeiCore ( // PeiDispatcher (SecCoreData, &PrivateData); - // - // Check if InstallPeiMemory service was called. - // - ASSERT(PrivateData.PeiMemoryInstalled == TRUE); + if (PrivateData.HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) { + // + // Check if InstallPeiMemory service was called on non-S3 resume boot path. + // + ASSERT(PrivateData.PeiMemoryInstalled == TRUE); + } // // Measure PEI Core execution time. -- 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

