From 0f89005d71b79cb795adf5806845a9790df44839 Mon Sep 17 00:00:00 2001 From: Wei6 Xu Date: Tue, 14 May 2024 01:22:03 +0800 Subject: StandaloneMmMemLib: Drop MM_CORE_PRIVATE_DATA MM_CORE_PRIVATE_DATA is not used as shared structures between MM IPL and MM Core, therefore clean up the code related to gMmCorePrivate. Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Ray Ni Cc: Jiaxin Wu Signed-off-by: Wei6 Xu --- .../StandaloneMmMemLib/StandaloneMmMemLib.inf | 1 - .../X86StandaloneMmMemLibInternal.c | 43 ++++++---------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf index ed3cdf1994..696b8e0689 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf @@ -51,5 +51,4 @@ MemoryAllocationLib [Guids] - gMmCoreDataHobGuid ## SOMETIMES_CONSUMES ## HOB gEfiMmPeiMmramMemoryReserveGuid ## SOMETIMES_CONSUMES ## HOB diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c index 0b4b1174de..c8ffe43cd1 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c @@ -20,7 +20,6 @@ #include #include -#include #include // @@ -87,9 +86,6 @@ MmMemLibInternalPopulateMmramRanges ( ) { VOID *HobStart; - EFI_HOB_GUID_TYPE *GuidHob; - MM_CORE_DATA_HOB_DATA *DataInHob; - MM_CORE_PRIVATE_DATA *MmCorePrivateData; EFI_HOB_GUID_TYPE *MmramRangesHob; EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData; EFI_MMRAM_DESCRIPTOR *MmramDescriptors; @@ -98,38 +94,21 @@ MmMemLibInternalPopulateMmramRanges ( DEBUG ((DEBUG_INFO, "%a - 0x%x\n", __func__, HobStart)); // - // Extract MM Core Private context from the Hob. If absent search for - // a Hob containing the MMRAM ranges + // Search for a Hob containing the MMRAM ranges // - GuidHob = GetNextGuidHob (&gMmCoreDataHobGuid, HobStart); - if (GuidHob == NULL) { - MmramRangesHob = GetFirstGuidHob (&gEfiMmPeiMmramMemoryReserveGuid); - if (MmramRangesHob == NULL) { - return EFI_UNSUPPORTED; - } - - MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob); - if ((MmramRangesHobData == NULL) || (MmramRangesHobData->Descriptor == NULL)) { - return EFI_UNSUPPORTED; - } - - mMmMemLibInternalMmramCount = MmramRangesHobData->NumberOfMmReservedRegions; - MmramDescriptors = MmramRangesHobData->Descriptor; - } else { - DataInHob = GET_GUID_HOB_DATA (GuidHob); - if (DataInHob == NULL) { - return EFI_UNSUPPORTED; - } - - MmCorePrivateData = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address; - if ((MmCorePrivateData == NULL) || (MmCorePrivateData->MmramRanges == 0)) { - return EFI_UNSUPPORTED; - } + MmramRangesHob = GetFirstGuidHob (&gEfiMmPeiMmramMemoryReserveGuid); + if (MmramRangesHob == NULL) { + return EFI_UNSUPPORTED; + } - mMmMemLibInternalMmramCount = (UINTN)MmCorePrivateData->MmramRangeCount; - MmramDescriptors = (EFI_MMRAM_DESCRIPTOR *)(UINTN)MmCorePrivateData->MmramRanges; + MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob); + if ((MmramRangesHobData == NULL) || (MmramRangesHobData->Descriptor == NULL)) { + return EFI_UNSUPPORTED; } + mMmMemLibInternalMmramCount = MmramRangesHobData->NumberOfMmReservedRegions; + MmramDescriptors = MmramRangesHobData->Descriptor; + mMmMemLibInternalMmramRanges = AllocatePool (mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR)); if (mMmMemLibInternalMmramRanges) { CopyMem ( -- cgit v1.2.3