Skip to content

Commit

Permalink
StandaloneMmPkg/MmIpl : Add MM core fv location PPI support
Browse files Browse the repository at this point in the history
MmIpl should locate MM core FV location PPI to find current MM
FV location.

Signed-off-by: Hongbin1 Zhang <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Star Zeng <[email protected]>
Cc: Jiaxin Wu <[email protected]>
Cc: Wei6 Xu <[email protected]>
Cc: Sami Mujawar <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Supreeth Venkatesh <[email protected]>
  • Loading branch information
hongbin123 committed Dec 20, 2024
1 parent e543936 commit 3ff61d1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
47 changes: 41 additions & 6 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
gEfiPeiMmControlPpiGuid
gEfiPeiMmCommunicationPpiGuid
gEfiEndOfPeiSignalPpiGuid
gMmCoreFvLocationPpiGuid

[Protocols]
gEfiMmEndOfPeiProtocol
Expand Down

0 comments on commit 3ff61d1

Please sign in to comment.