diff options
author | Wei6 Xu <wei6.xu@intel.com> | 2024-05-14 00:56:58 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-08-28 15:25:27 +0000 |
commit | 18591343b224316df6f616441d69a954b8350e22 (patch) | |
tree | c01bce6b1adc84e0b10e41f3d301496743dff003 /StandaloneMmPkg | |
parent | 24e41d1fa3e08972ced64617df651b105411e13a (diff) | |
download | edk2-18591343b224316df6f616441d69a954b8350e22.tar.gz |
StandaloneMmPkg/Core: 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 <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
Diffstat (limited to 'StandaloneMmPkg')
-rw-r--r-- | StandaloneMmPkg/Core/StandaloneMmCore.c | 119 | ||||
-rw-r--r-- | StandaloneMmPkg/Core/StandaloneMmCore.h | 5 | ||||
-rw-r--r-- | StandaloneMmPkg/Core/StandaloneMmCore.inf | 1 | ||||
-rw-r--r-- | StandaloneMmPkg/Core/StandaloneMmCorePrivateData.h | 2 |
4 files changed, 30 insertions, 97 deletions
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c index 7e129832fc..49d3e6d407 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.c +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c @@ -20,11 +20,6 @@ MmDispatcher ( EFI_HANDLE mMmCpuHandle = NULL;
//
-// Physical pointer to private structure shared between MM IPL and the MM Core
-//
-MM_CORE_PRIVATE_DATA *gMmCorePrivate;
-
-//
// MM Core global variable for MM System Table. Only accessed as a physical structure in MMRAM.
//
EFI_MM_SYSTEM_TABLE gMmCoreMmst = {
@@ -86,6 +81,7 @@ MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = { { NULL, NULL, NULL, FALSE },
};
+BOOLEAN mMmEntryPointRegistered = FALSE;
UINTN mMmramRangeCount;
EFI_MMRAM_DESCRIPTOR *mMmramRanges;
MM_COMM_BUFFER *mMmCommunicationBuffer;
@@ -488,15 +484,6 @@ MmEntryPoint ( // PlatformHookBeforeMmDispatch ();
//
- // If a legacy boot has occurred, then make sure gMmCorePrivate is not accessed
- //
-
- //
- // TBD: Mark the InMm flag as TRUE
- //
- gMmCorePrivate->InMm = TRUE;
-
- //
// Check to see if this is a Synchronous MMI sent through the MM Communication
// Protocol or an Asynchronous MMI
//
@@ -570,11 +557,6 @@ MmEntryPoint ( // TBD: Do not use private data structure ?
//
- //
- // Clear the InMm flag as we are going to leave MM
- //
- gMmCorePrivate->InMm = FALSE;
-
DEBUG ((DEBUG_INFO, "MmEntryPoint Done\n"));
}
@@ -605,19 +587,19 @@ MmConfigurationMmNotify ( //
// Register the MM Entry Point provided by the MM Core with the MM COnfiguration protocol
//
- Status = MmConfiguration->RegisterMmEntry (MmConfiguration, (EFI_MM_ENTRY_POINT)(UINTN)gMmCorePrivate->MmEntryPoint);
+ Status = MmConfiguration->RegisterMmEntry (MmConfiguration, (EFI_MM_ENTRY_POINT)MmEntryPoint);
ASSERT_EFI_ERROR (Status);
//
// Set flag to indicate that the MM Entry Point has been registered which
// means that MMIs are now fully operational.
//
- gMmCorePrivate->MmEntryPointRegistered = TRUE;
+ mMmEntryPointRegistered = TRUE;
//
// Print debug message showing MM Core entry point address.
//
- DEBUG ((DEBUG_INFO, "MM Core registered MM Entry Point address %p\n", (VOID *)(UINTN)gMmCorePrivate->MmEntryPoint));
+ DEBUG ((DEBUG_INFO, "MM Core registered MM Entry Point address %p\n", MmEntryPoint));
return EFI_SUCCESS;
}
@@ -671,8 +653,6 @@ StandaloneMmMain ( VOID *MmHobStart;
UINTN HobSize;
VOID *Registration;
- EFI_HOB_GUID_TYPE *GuidHob;
- MM_CORE_DATA_HOB_DATA *DataInHob;
EFI_HOB_GUID_TYPE *MmramRangesHob;
EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData;
EFI_MMRAM_DESCRIPTOR *MmramRanges;
@@ -688,58 +668,20 @@ StandaloneMmMain ( );
//
- // Determine if the caller has passed a reference to a MM_CORE_PRIVATE_DATA
- // structure in the Hoblist. This choice will govern how boot information is
- // extracted later.
+ // Extract the MMRAM ranges from the MMRAM descriptor HOB
//
- GuidHob = GetNextGuidHob (&gMmCoreDataHobGuid, HobStart);
- if (GuidHob == NULL) {
- //
- // Allocate and zero memory for a MM_CORE_PRIVATE_DATA table and then
- // initialise it
- //
- gMmCorePrivate = (MM_CORE_PRIVATE_DATA *)AllocateRuntimePages (EFI_SIZE_TO_PAGES (sizeof (MM_CORE_PRIVATE_DATA)));
- SetMem ((VOID *)(UINTN)gMmCorePrivate, sizeof (MM_CORE_PRIVATE_DATA), 0);
- gMmCorePrivate->Signature = MM_CORE_PRIVATE_DATA_SIGNATURE;
- gMmCorePrivate->MmEntryPointRegistered = FALSE;
- gMmCorePrivate->InMm = FALSE;
- gMmCorePrivate->ReturnStatus = EFI_SUCCESS;
-
- //
- // Extract the MMRAM ranges from the MMRAM descriptor HOB
- //
- MmramRangesHob = GetNextGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, HobStart);
- if (MmramRangesHob == NULL) {
- return EFI_UNSUPPORTED;
- }
-
- MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
- ASSERT (MmramRangesHobData != NULL);
- MmramRanges = MmramRangesHobData->Descriptor;
- MmramRangeCount = (UINTN)MmramRangesHobData->NumberOfMmReservedRegions;
- ASSERT (MmramRanges);
- ASSERT (MmramRangeCount);
-
- //
- // Copy the MMRAM ranges into MM_CORE_PRIVATE_DATA table just in case any
- // code relies on them being present there
- //
- gMmCorePrivate->MmramRangeCount = (UINT64)MmramRangeCount;
- gMmCorePrivate->MmramRanges =
- (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (MmramRangeCount * sizeof (EFI_MMRAM_DESCRIPTOR));
- ASSERT (gMmCorePrivate->MmramRanges != 0);
- CopyMem (
- (VOID *)(UINTN)gMmCorePrivate->MmramRanges,
- MmramRanges,
- MmramRangeCount * sizeof (EFI_MMRAM_DESCRIPTOR)
- );
- } else {
- DataInHob = GET_GUID_HOB_DATA (GuidHob);
- gMmCorePrivate = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
- MmramRanges = (EFI_MMRAM_DESCRIPTOR *)(UINTN)gMmCorePrivate->MmramRanges;
- MmramRangeCount = (UINTN)gMmCorePrivate->MmramRangeCount;
+ MmramRangesHob = GetNextGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, HobStart);
+ if (MmramRangesHob == NULL) {
+ return EFI_UNSUPPORTED;
}
+ MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
+ ASSERT (MmramRangesHobData != NULL);
+ MmramRanges = MmramRangesHobData->Descriptor;
+ MmramRangeCount = (UINTN)MmramRangesHobData->NumberOfMmReservedRegions;
+ ASSERT (MmramRanges);
+ ASSERT (MmramRangeCount);
+
//
// Print the MMRAM ranges passed by the caller
//
@@ -765,19 +707,6 @@ StandaloneMmMain ( CopyMem (mMmramRanges, (VOID *)(UINTN)MmramRanges, mMmramRangeCount * sizeof (EFI_MMRAM_DESCRIPTOR));
//
- // Get Boot Firmware Volume address from the BFV Hob
- //
- BfvHob = GetFirstHob (EFI_HOB_TYPE_FV);
- if (BfvHob != NULL) {
- DEBUG ((DEBUG_INFO, "BFV address - 0x%x\n", BfvHob->BaseAddress));
- DEBUG ((DEBUG_INFO, "BFV size - 0x%x\n", BfvHob->Length));
- gMmCorePrivate->StandaloneBfvAddress = BfvHob->BaseAddress;
- }
-
- gMmCorePrivate->Mmst = (EFI_PHYSICAL_ADDRESS)(UINTN)&gMmCoreMmst;
- gMmCorePrivate->MmEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)MmEntryPoint;
-
- //
// No need to initialize memory service.
// It is done in the constructor of StandaloneMmCoreMemoryAllocationLib(),
// so that the library linked with StandaloneMmCore can use AllocatePool() in
@@ -810,12 +739,20 @@ StandaloneMmMain ( ASSERT_EFI_ERROR (Status);
//
- // Dispatch standalone BFV
+ // Get Boot Firmware Volume address from the BFV Hob
//
- DEBUG ((DEBUG_INFO, "Mm Dispatch StandaloneBfvAddress - 0x%08x\n", gMmCorePrivate->StandaloneBfvAddress));
- if (gMmCorePrivate->StandaloneBfvAddress != 0) {
- MmCoreFfsFindMmDriver ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)gMmCorePrivate->StandaloneBfvAddress, 0);
- MmDispatcher ();
+ BfvHob = GetFirstHob (EFI_HOB_TYPE_FV);
+ if (BfvHob != NULL) {
+ DEBUG ((DEBUG_INFO, "BFV address - 0x%x\n", BfvHob->BaseAddress));
+ DEBUG ((DEBUG_INFO, "BFV size - 0x%x\n", BfvHob->Length));
+ //
+ // Dispatch standalone BFV
+ //
+ if (BfvHob->BaseAddress != 0) {
+ DEBUG ((DEBUG_INFO, "Mm Dispatch StandaloneBfvAddress - 0x%08x\n", BfvHob->BaseAddress));
+ MmCoreFfsFindMmDriver ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BfvHob->BaseAddress, 0);
+ MmDispatcher ();
+ }
}
//
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.h b/StandaloneMmPkg/Core/StandaloneMmCore.h index 1d34bb643e..84d1632505 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.h +++ b/StandaloneMmPkg/Core/StandaloneMmCore.h @@ -175,9 +175,8 @@ typedef struct { //
// MM Core Global Variables
//
-extern MM_CORE_PRIVATE_DATA *gMmCorePrivate;
-extern EFI_MM_SYSTEM_TABLE gMmCoreMmst;
-extern LIST_ENTRY gHandleList;
+extern EFI_MM_SYSTEM_TABLE gMmCoreMmst;
+extern LIST_ENTRY gHandleList;
/**
Called to initialize the memory service.
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf index 726a946883..dd9af16ca4 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf @@ -71,7 +71,6 @@ gZeroGuid ## SOMETIMES_CONSUMES ## GUID
gEfiHobListGuid
gEfiHobMemoryAllocModuleGuid
- gMmCoreDataHobGuid
gMmFvDispatchGuid
gEfiEventLegacyBootGuid
gEfiEventExitBootServicesGuid
diff --git a/StandaloneMmPkg/Core/StandaloneMmCorePrivateData.h b/StandaloneMmPkg/Core/StandaloneMmCorePrivateData.h index 58d3bc3803..03b0261ef0 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCorePrivateData.h +++ b/StandaloneMmPkg/Core/StandaloneMmCorePrivateData.h @@ -11,8 +11,6 @@ #ifndef _STANDALONE_MM_CORE_PRIVATE_DATA_H_
#define _STANDALONE_MM_CORE_PRIVATE_DATA_H_
-#include <Guid/MmCoreData.h>
-
//
// Page management
//
|