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 could 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 19, 2024
1 parent abac712 commit 2034f51
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
44 changes: 38 additions & 6 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,44 @@ 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;

//
// MmIpl should locate MM Core FV location PPI to find the MM core FV.
//
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 2034f51

Please sign in to comment.