StandaloneMmPkg/Core: add a new InitializeMmHobList()

Separate a function called InitializeMmHobList() to gather
all the operations related to initializing HOB. It doesn't
change any code logic.

Signed-off-by: Dun Tan <dun.tan@intel.com>
This commit is contained in:
Dun Tan 2024-10-21 17:38:56 +08:00 committed by mergify[bot]
parent d24bb10b1d
commit 3adb507175

View File

@ -699,17 +699,22 @@ MigrateMemoryAllocationHobs (
} }
} }
/** Returns the HOB list size. /**
This function is responsible for initializing a new HOB list in MMRAM based on
the input HOB list.
@param [in] HobStart Pointer to the start of the HOB list. @param [in] HobStart Pointer to the start of the HOB list.
@retval Size of the HOB list. @retval Pointer to the new location of hob list in MMRAM.
**/ **/
UINTN VOID *
GetHobListSize ( InitializeMmHobList (
IN VOID *HobStart IN VOID *HobStart
) )
{ {
VOID *MmHobStart;
UINTN HobSize;
EFI_STATUS Status;
EFI_PEI_HOB_POINTERS Hob; EFI_PEI_HOB_POINTERS Hob;
ASSERT (HobStart != NULL); ASSERT (HobStart != NULL);
@ -722,7 +727,21 @@ GetHobListSize (
// //
// Need plus END_OF_HOB_LIST // Need plus END_OF_HOB_LIST
// //
return (UINTN)Hob.Raw - (UINTN)HobStart + sizeof (EFI_HOB_GENERIC_HEADER); HobSize = (UINTN)Hob.Raw - (UINTN)HobStart + sizeof (EFI_HOB_GENERIC_HEADER);
DEBUG ((DEBUG_INFO, "HobSize - 0x%x\n", HobSize));
MmHobStart = AllocatePool (HobSize);
DEBUG ((DEBUG_INFO, "MmHobStart - 0x%x\n", MmHobStart));
ASSERT (MmHobStart != NULL);
CopyMem (MmHobStart, HobStart, HobSize);
DEBUG ((DEBUG_INFO, "MmInstallConfigurationTable For HobList\n"));
Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
ASSERT_EFI_ERROR (Status);
MigrateMemoryAllocationHobs (MmHobStart);
return MmHobStart;
} }
/** /**
@ -746,8 +765,6 @@ StandaloneMmMain (
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN Index; UINTN Index;
VOID *MmHobStart;
UINTN HobSize;
VOID *Registration; VOID *Registration;
EFI_HOB_GUID_TYPE *MmramRangesHob; EFI_HOB_GUID_TYPE *MmramRangesHob;
EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData; EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData;
@ -800,21 +817,11 @@ StandaloneMmMain (
// It is done in the constructor of StandaloneMmCoreMemoryAllocationLib(), // It is done in the constructor of StandaloneMmCoreMemoryAllocationLib(),
// so that the library linked with StandaloneMmCore can use AllocatePool() in // so that the library linked with StandaloneMmCore can use AllocatePool() in
// the constructor. // the constructor.
//
DEBUG ((DEBUG_INFO, "MmInstallConfigurationTable For HobList\n"));
// //
// Install HobList // Install HobList
// //
HobSize = GetHobListSize (HobStart); gHobList = InitializeMmHobList (HobStart);
DEBUG ((DEBUG_INFO, "HobSize - 0x%x\n", HobSize));
MmHobStart = AllocatePool (HobSize);
DEBUG ((DEBUG_INFO, "MmHobStart - 0x%x\n", MmHobStart));
ASSERT (MmHobStart != NULL);
CopyMem (MmHobStart, HobStart, HobSize);
Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
ASSERT_EFI_ERROR (Status);
MigrateMemoryAllocationHobs (MmHobStart);
gHobList = MmHobStart;
// //
// Register notification for EFI_MM_CONFIGURATION_PROTOCOL registration and // Register notification for EFI_MM_CONFIGURATION_PROTOCOL registration and