Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StandaloneMmPkg : Add MM core fv location PPI #6547

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 34 additions & 0 deletions StandaloneMmPkg/Include/Ppi/MmCoreFvLocationPpi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/** @file
MM Core FV location PPI header file.

MM Core FV location PPI is used by StandaloneMm IPL to find MM Core.

Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef MM_CORE_FV_LOCATION_PPI_H_
#define MM_CORE_FV_LOCATION_PPI_H_

#pragma pack(1)

///
/// Global ID for the MM_CORE_FV_LOCATION_PPI.
///
#define MM_CORE_FV_LOCATION_GUID \
{ \
0x47a00618, 0x237a, 0x4386, { 0x8f, 0xc5, 0x2a, 0x86, 0xd8, 0xac, 0x41, 0x05 } \
}

typedef struct {
EFI_PHYSICAL_ADDRESS Address;
UINT64 Size;
} MM_CORE_FV_LOCATION_PPI;

extern EFI_GUID gMmCoreFvLocationPpiGuid;

#pragma pack()

#endif
3 changes: 3 additions & 0 deletions StandaloneMmPkg/StandaloneMmPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

gEventMmDispatchGuid = { 0x7e6efffa, 0x69b4, 0x4c1b, { 0xa4, 0xc7, 0xaf, 0xf9, 0xc9, 0x24, 0x4f, 0xee }}

[Ppis]
gMmCoreFvLocationPpiGuid = { 0x47a00618, 0x237a, 0x4386, { 0x8f, 0xc5, 0x2a, 0x86, 0xd8, 0xac, 0x41, 0x05 }}

[PcdsFixedAtBuild, PcdsPatchableInModule]
## Maximum permitted encapsulation levels of sections in a firmware volume,
# in the MM phase. Minimum value is 1. Sections nested more deeply are rejected.
Expand Down
Loading