diff options
Diffstat (limited to 'StandaloneMmPkg/Core/StandaloneMmCore.c')
-rw-r--r-- | StandaloneMmPkg/Core/StandaloneMmCore.c | 119 |
1 files changed, 28 insertions, 91 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 ();
+ }
}
//
|