StandaloneMmPkg/MmIpl: build MM communication buffer HOB

MM communication buffer HOB data is for StandaloneMm Core and
MM communicate DXE driver.

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>
This commit is contained in:
Hongbin1 Zhang 2024-05-07 10:48:24 +08:00 committed by mergify[bot]
parent e363c0b729
commit d7e6b863a1
4 changed files with 83 additions and 0 deletions

View File

@ -8,6 +8,65 @@
#include "StandaloneMmIplPei.h"
/**
Build communication buffer HOB.
@return MM_COMM_BUFFER Pointer of MM communication buffer
**/
MM_COMM_BUFFER *
MmIplBuildCommBufferHob (
VOID
)
{
EFI_STATUS Status;
MM_COMM_BUFFER *MmCommBuffer;
UINT64 MmCommBufferPages;
MmCommBufferPages = PcdGet32 (PcdMmCommBufferPages);
MmCommBuffer = BuildGuidHob (&gMmCommBufferHobGuid, sizeof (MM_COMM_BUFFER));
ASSERT (MmCommBuffer != NULL);
//
// Set MM communicate buffer size
//
MmCommBuffer->NumberOfPages = MmCommBufferPages;
//
// Allocate runtime memory for MM communicate buffer
//
MmCommBuffer->PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateRuntimePages (MmCommBufferPages);
if (MmCommBuffer->PhysicalStart == 0) {
DEBUG ((DEBUG_ERROR, "Fail to allocate MM communication buffer\n"));
ASSERT (MmCommBuffer->PhysicalStart != 0);
}
//
// Build MM unblock memory region HOB for MM communication buffer
//
Status = MmUnblockMemoryRequest (MmCommBuffer->PhysicalStart, MmCommBufferPages);
ASSERT_EFI_ERROR (Status);
//
// Allocate runtime memory for MM communication status parameters :
// ReturnStatus, ReturnBufferSize, IsCommBufferValid
//
MmCommBuffer->Status = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateRuntimePages (EFI_SIZE_TO_PAGES (sizeof (MM_COMM_BUFFER_STATUS)));
if (MmCommBuffer->Status == 0) {
DEBUG ((DEBUG_ERROR, "Fail to allocate memory for MM communication status\n"));
ASSERT (MmCommBuffer->Status != 0);
}
//
// Build MM unblock memory region HOB for MM communication status
//
Status = MmUnblockMemoryRequest (MmCommBuffer->Status, EFI_SIZE_TO_PAGES (sizeof (MM_COMM_BUFFER_STATUS)));
ASSERT_EFI_ERROR (Status);
return MmCommBuffer;
}
/**
The Entry Point for MM IPL at PEI stage.
@ -27,5 +86,13 @@ StandaloneMmIplPeiEntry (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
MM_COMM_BUFFER *MmCommBuffer;
//
// Build communication buffer HOB.
//
MmCommBuffer = MmIplBuildCommBufferHob ();
ASSERT (MmCommBuffer != NULL);
return EFI_SUCCESS;
}

View File

@ -9,4 +9,10 @@
#ifndef STANDALONE_MM_IPL_PEI_H_
#define STANDALONE_MM_IPL_PEI_H_
#include <Guid/MmCommBuffer.h>
#include <Library/HobLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/MmUnblockMemoryLib.h>
#endif

View File

@ -29,15 +29,22 @@
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
StandaloneMmPkg/StandaloneMmPkg.dec
[LibraryClasses]
PeimEntryPoint
DebugLib
HobLib
MemoryAllocationLib
MmUnblockMemoryLib
[Guids]
gMmCommBufferHobGuid
[Ppis]
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMmCommBufferPages
[Depex]
TRUE

View File

@ -63,7 +63,10 @@
MmPlatformHobProducerLib|StandaloneMmPkg/Library/MmPlatformHobProducerLibNull/MmPlatformHobProducerLibNull.inf
[LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
[LibraryClasses.AARCH64, LibraryClasses.ARM]
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf