diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c index f5b4b6d7f27d..0b2983939e2e 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c @@ -32,34 +32,6 @@ MmMemLibInternalCalculateMaximumSupportAddress ( DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress = 0x%lx\n", mMmMemLibInternalMaximumSupportAddress)); } -/** - Initialize cached Mmram Ranges from HOB. - - @retval EFI_UNSUPPORTED The routine is unable to extract MMRAM information. - @retval EFI_SUCCESS MmRanges are populated successfully. - -**/ -EFI_STATUS -MmMemLibInternalPopulateMmramRanges ( - VOID - ) -{ - // Not implemented for AARCH64. - return EFI_SUCCESS; -} - -/** - Deinitialize cached Mmram Ranges. - -**/ -VOID -MmMemLibInternalFreeMmramRanges ( - VOID - ) -{ - // Not implemented for AARCH64. -} - /** Initialize valid non-Mmram Ranges from Resource HOB. diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c index b3c9debe984d..d393f6d931d7 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c @@ -15,9 +15,6 @@ #include -EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges; -UINTN mMmMemLibInternalMmramCount; - // // Maximum support address used to check input buffer // @@ -39,8 +36,6 @@ MmIsBufferOutsideMmValid ( IN UINT64 Length ) { - UINTN Index; - // // Check override. // NOTE: (B:0->L:4G) is invalid for IA32, but (B:1->L:4G-1)/(B:4G-1->L:1) is valid. @@ -62,28 +57,6 @@ MmIsBufferOutsideMmValid ( return FALSE; } - for (Index = 0; Index < mMmMemLibInternalMmramCount; Index++) { - if (((Buffer >= mMmMemLibInternalMmramRanges[Index].CpuStart) && - (Buffer < mMmMemLibInternalMmramRanges[Index].CpuStart + mMmMemLibInternalMmramRanges[Index].PhysicalSize)) || - ((mMmMemLibInternalMmramRanges[Index].CpuStart >= Buffer) && - (mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length))) - { - DEBUG (( - DEBUG_ERROR, - "MmIsBufferOutsideMmValid: Overlap: Buffer (0x%lx) - Length (0x%lx), ", - Buffer, - Length - )); - DEBUG (( - DEBUG_ERROR, - "CpuStart (0x%lx) - PhysicalSize (0x%lx)\n", - mMmMemLibInternalMmramRanges[Index].CpuStart, - mMmMemLibInternalMmramRanges[Index].PhysicalSize - )); - return FALSE; - } - } - return MmMemLibInternalIsValidNonMmramRange (Buffer, Length); } @@ -254,8 +227,6 @@ MemLibConstructor ( IN EFI_MM_SYSTEM_TABLE *MmSystemTable ) { - EFI_STATUS Status; - // // Calculate and save maximum support address // @@ -266,12 +237,7 @@ MemLibConstructor ( // MmMemLibInternalPopulateValidNonMmramRanges (); - // - // Initialize cached Mmram Ranges from HOB. - // - Status = MmMemLibInternalPopulateMmramRanges (); - - return Status; + return EFI_SUCCESS; } /** @@ -290,11 +256,6 @@ MemLibDestructor ( IN EFI_MM_SYSTEM_TABLE *MmSystemTable ) { - // - // Deinitialize cached Mmram Ranges. - // - MmMemLibInternalFreeMmramRanges (); - // // Deinitialize cached non-Mmram Ranges. // diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.h b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.h index a29489cb4025..952f55a38c04 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.h +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.h @@ -32,27 +32,6 @@ MmMemLibInternalCalculateMaximumSupportAddress ( VOID ); -/** - Initialize cached Mmram Ranges from HOB. - - @retval EFI_UNSUPPORTED The routine is unable to extract MMRAM information. - @retval EFI_SUCCESS MmRanges are populated successfully. - -**/ -EFI_STATUS -MmMemLibInternalPopulateMmramRanges ( - VOID - ); - -/** - Deinitialize cached Mmram Ranges. - -**/ -VOID -MmMemLibInternalFreeMmramRanges ( - VOID - ); - /** Initialize valid non-Mmram Ranges from Resource HOB. diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c index aa581591716d..a599f2e4c917 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c @@ -27,8 +27,6 @@ UINTN mValidNonMmramCount; // Maximum support address used to check input buffer // extern EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress; -extern EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges; -extern UINTN mMmMemLibInternalMmramCount; /** Calculate and save the maximum support address. @@ -74,71 +72,6 @@ MmMemLibInternalCalculateMaximumSupportAddress ( DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress = 0x%lx\n", mMmMemLibInternalMaximumSupportAddress)); } -/** - Initialize cached Mmram Ranges from HOB. - - @retval EFI_UNSUPPORTED The routine is unable to extract MMRAM information. - @retval EFI_SUCCESS MmRanges are populated successfully. - -**/ -EFI_STATUS -MmMemLibInternalPopulateMmramRanges ( - VOID - ) -{ - VOID *HobStart; - EFI_HOB_GUID_TYPE *MmramRangesHob; - EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData; - EFI_MMRAM_DESCRIPTOR *MmramDescriptors; - - HobStart = GetHobList (); - DEBUG ((DEBUG_INFO, "%a - 0x%x\n", __func__, HobStart)); - - // - // Search for a Hob containing the MMRAM ranges - // - MmramRangesHob = GetFirstGuidHob (&gEfiSmmSmramMemoryGuid); - if (MmramRangesHob == 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; - - mMmMemLibInternalMmramRanges = AllocatePool (mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR)); - if (mMmMemLibInternalMmramRanges) { - CopyMem ( - mMmMemLibInternalMmramRanges, - MmramDescriptors, - mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR) - ); - } - - return EFI_SUCCESS; -} - -/** - Deinitialize cached Mmram Ranges. - -**/ -VOID -MmMemLibInternalFreeMmramRanges ( - VOID - ) -{ - if (mMmMemLibInternalMmramRanges != NULL) { - FreePool (mMmMemLibInternalMmramRanges); - } -} - /** Merge continuous memory map entries whose type is EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory,