summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongbin1 Zhang <hongbin1.zhang@intel.com>2024-12-17 16:36:07 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-12-20 05:44:54 +0000
commit816a02cb3b1677840074e2eb17cf5f24b0de3870 (patch)
tree9086d049e0f38187f99489098a2b3e451b9e6a4b
parent47cb080ca4ef61977d90fc80547ac6c84e290f50 (diff)
downloadedk2-816a02cb3b1677840074e2eb17cf5f24b0de3870.tar.gz
StandaloneMmPkg/MmIpl : Add MM core fv location PPI support
MmIpl should locate MM core FV location PPI to find current MM FV location. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
-rw-r--r--StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c47
-rw-r--r--StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.h1
-rw-r--r--StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf1
3 files changed, 43 insertions, 6 deletions
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c
index 1a01d7a465..d8112b0fef 100644
--- a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c
+++ b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c
@@ -147,12 +147,47 @@ LocateMmCoreFv (
OUT VOID **MmCoreImageAddress
)
{
- EFI_STATUS Status;
- UINTN FvIndex;
- EFI_PEI_FV_HANDLE VolumeHandle;
- EFI_PEI_FILE_HANDLE FileHandle;
- EFI_PE32_SECTION *SectionData;
- EFI_FV_INFO VolumeInfo;
+ EFI_STATUS Status;
+ UINTN FvIndex;
+ EFI_PEI_FV_HANDLE VolumeHandle;
+ EFI_PEI_FILE_HANDLE FileHandle;
+ EFI_PE32_SECTION *SectionData;
+ EFI_FV_INFO VolumeInfo;
+ MM_CORE_FV_LOCATION_PPI *MmCoreFvLocation;
+
+ //
+ // The producer of the MmCoreFvLocation PPI is responsible for ensuring
+ // that it reports the correct Firmware Volume (FV) containing the MmCore.
+ // If the gMmCoreFvLocationPpiGuid is not found, the system will search
+ // all Firmware Volumes (FVs) to locate the FV that contains the MM Core.
+ //
+ Status = PeiServicesLocatePpi (&gMmCoreFvLocationPpiGuid, 0, NULL, (VOID **)&MmCoreFvLocation);
+ if (Status == EFI_SUCCESS) {
+ *MmFvBase = MmCoreFvLocation->Address;
+ *MmFvSize = MmCoreFvLocation->Size;
+ FileHandle = NULL;
+ Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_MM_CORE_STANDALONE, (VOID *)(UINTN)MmCoreFvLocation->Address, &FileHandle);
+ ASSERT_EFI_ERROR (Status);
+ if (Status == EFI_SUCCESS) {
+ ASSERT (FileHandle != NULL);
+ if (FileHandle != NULL) {
+ CopyGuid (MmCoreFileName, &((EFI_FFS_FILE_HEADER *)FileHandle)->Name);
+ //
+ // Search Section
+ //
+ Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, MmCoreImageAddress);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get MM Core section data.
+ //
+ SectionData = (EFI_PE32_SECTION *)((UINT8 *)*MmCoreImageAddress - sizeof (EFI_PE32_SECTION));
+ ASSERT (SectionData->Type == EFI_SECTION_PE32);
+ }
+ }
+
+ return EFI_SUCCESS;
+ }
//
// Search all FV
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.h b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.h
index 9301b8f3f5..e385c7768d 100644
--- a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.h
+++ b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.h
@@ -23,6 +23,7 @@
#include <Library/PeiServicesTablePointerLib.h>
#include <Ppi/MmControl.h>
#include <Ppi/MmCommunication.h>
+#include <Ppi/MmCoreFvLocationPpi.h>
#include <Protocol/MmCommunication.h>
#include <Library/MmPlatformHobProducerLib.h>
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf
index dfc181218e..f07f26ee41 100644
--- a/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf
+++ b/StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.inf
@@ -61,6 +61,7 @@
gEfiPeiMmControlPpiGuid
gEfiPeiMmCommunicationPpiGuid
gEfiEndOfPeiSignalPpiGuid
+ gMmCoreFvLocationPpiGuid
[Protocols]
gEfiMmEndOfPeiProtocol