summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDun Tan <dun.tan@intel.com>2024-10-21 17:38:56 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-11-05 08:30:16 +0000
commit3adb5071751d634ce4116fc566f8a131ecc080af (patch)
tree77e3f1fc645c25825b7d757ebc6d265dc95ee53b
parentd24bb10b1d9a5b2458efe54d48c81583ce8499bd (diff)
downloadedk2-3adb5071751d634ce4116fc566f8a131ecc080af.tar.gz
edk2-3adb5071751d634ce4116fc566f8a131ecc080af.tar.bz2
edk2-3adb5071751d634ce4116fc566f8a131ecc080af.zip
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>
-rw-r--r--StandaloneMmPkg/Core/StandaloneMmCore.c47
1 files 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