From 3adb5071751d634ce4116fc566f8a131ecc080af Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Mon, 21 Oct 2024 17:38:56 +0800 Subject: 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 --- StandaloneMmPkg/Core/StandaloneMmCore.c | 47 +++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c index 5a3694b58c..3a8842fc16 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.c +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c @@ -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 -GetHobListSize ( +VOID * +InitializeMmHobList ( IN VOID *HobStart ) { + VOID *MmHobStart; + UINTN HobSize; + EFI_STATUS Status; EFI_PEI_HOB_POINTERS Hob; ASSERT (HobStart != NULL); @@ -722,7 +727,21 @@ GetHobListSize ( // // 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; UINTN Index; - VOID *MmHobStart; - UINTN HobSize; VOID *Registration; EFI_HOB_GUID_TYPE *MmramRangesHob; EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData; @@ -800,21 +817,11 @@ StandaloneMmMain ( // It is done in the constructor of StandaloneMmCoreMemoryAllocationLib(), // so that the library linked with StandaloneMmCore can use AllocatePool() in // the constructor. - - DEBUG ((DEBUG_INFO, "MmInstallConfigurationTable For HobList\n")); + // // // Install HobList // - HobSize = GetHobListSize (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; + gHobList = InitializeMmHobList (HobStart); // // Register notification for EFI_MM_CONFIGURATION_PROTOCOL registration and -- cgit