Skip to content

Commit

Permalink
Merge branch 'master' into add_fspi_wrapper_peim
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 20, 2024
2 parents b098944 + 816a02c commit 924d27e
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 10 deletions.
56 changes: 52 additions & 4 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/MmFoundationHob.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,49 @@ GetRemainingHobSize (
}
}

/**
Check if FV HOB was created.
Check if FV HOB was created on HOB list,
if yes, skip building MM Core FV HOB,
if No, continue to build MM Core FV HOB
@param[in] HobList HOB list.
@param[in] HobSize HOB size.
@retval TRUE Skip building MM Core FV HOB.
FALSE Continue to build MM Core FV HOB.
**/
BOOLEAN
IsFvHobExist (
IN UINT8 *HobList,
IN UINTN HobSize
)
{
EFI_PEI_HOB_POINTERS Hob;
UINTN HobLength;

if ((HobList == NULL) || (HobSize == 0)) {
return FALSE;
}

Hob.Raw = (UINT8 *)HobList;
HobLength = GET_HOB_LENGTH (Hob);
//
// Parse the HOB list until end of list or matching type is found.
//
while (HobLength <= HobSize) {
if (Hob.Header->HobType == EFI_HOB_TYPE_FV) {
return TRUE;
}

Hob.Raw = GET_NEXT_HOB (Hob);
HobLength += GET_HOB_LENGTH (Hob);
}

return FALSE;
}

/**
Create the MM foundation specific HOB list which StandaloneMm Core needed.
Expand Down Expand Up @@ -892,11 +935,16 @@ CreateMmFoundationHobList (
UsedSize += HobLength;

//
// BFV address for StandaloneMm Core
// Skip to report FV that contains MmCore when Platform reports FV
//
HobLength = GetRemainingHobSize (*FoundationHobSize, UsedSize);
MmIplBuildFvHob (FoundationHobList + UsedSize, &HobLength, MmFvBase, MmFvSize);
UsedSize += HobLength;
if (!IsFvHobExist (PlatformHobList, PlatformHobSize)) {
//
// BFV address for StandaloneMm Core
//
HobLength = GetRemainingHobSize (*FoundationHobSize, UsedSize);
MmIplBuildFvHob (FoundationHobList + UsedSize, &HobLength, MmFvBase, MmFvSize);
UsedSize += HobLength;
}

//
// Build MM ACPI S3 Enable HOB
Expand Down
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

0 comments on commit 924d27e

Please sign in to comment.