|
|
|
@@ -19,11 +19,6 @@ MmDispatcher (
|
|
|
|
//
|
|
|
|
//
|
|
|
|
EFI_HANDLE mMmCpuHandle = NULL;
|
|
|
|
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.
|
|
|
|
// MM Core global variable for MM System Table. Only accessed as a physical structure in MMRAM.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -86,6 +81,7 @@ MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = {
|
|
|
|
{ NULL, NULL, NULL, FALSE },
|
|
|
|
{ NULL, NULL, NULL, FALSE },
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOLEAN mMmEntryPointRegistered = FALSE;
|
|
|
|
UINTN mMmramRangeCount;
|
|
|
|
UINTN mMmramRangeCount;
|
|
|
|
EFI_MMRAM_DESCRIPTOR *mMmramRanges;
|
|
|
|
EFI_MMRAM_DESCRIPTOR *mMmramRanges;
|
|
|
|
MM_COMM_BUFFER *mMmCommunicationBuffer;
|
|
|
|
MM_COMM_BUFFER *mMmCommunicationBuffer;
|
|
|
|
@@ -487,15 +483,6 @@ MmEntryPoint (
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// PlatformHookBeforeMmDispatch ();
|
|
|
|
// 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
|
|
|
|
// Check to see if this is a Synchronous MMI sent through the MM Communication
|
|
|
|
// Protocol or an Asynchronous MMI
|
|
|
|
// Protocol or an Asynchronous MMI
|
|
|
|
@@ -570,11 +557,6 @@ MmEntryPoint (
|
|
|
|
// TBD: Do not use private data structure ?
|
|
|
|
// 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"));
|
|
|
|
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
|
|
|
|
// 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);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Set flag to indicate that the MM Entry Point has been registered which
|
|
|
|
// Set flag to indicate that the MM Entry Point has been registered which
|
|
|
|
// means that MMIs are now fully operational.
|
|
|
|
// means that MMIs are now fully operational.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
gMmCorePrivate->MmEntryPointRegistered = TRUE;
|
|
|
|
mMmEntryPointRegistered = TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Print debug message showing MM Core entry point address.
|
|
|
|
// 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;
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -671,8 +653,6 @@ StandaloneMmMain (
|
|
|
|
VOID *MmHobStart;
|
|
|
|
VOID *MmHobStart;
|
|
|
|
UINTN HobSize;
|
|
|
|
UINTN HobSize;
|
|
|
|
VOID *Registration;
|
|
|
|
VOID *Registration;
|
|
|
|
EFI_HOB_GUID_TYPE *GuidHob;
|
|
|
|
|
|
|
|
MM_CORE_DATA_HOB_DATA *DataInHob;
|
|
|
|
|
|
|
|
EFI_HOB_GUID_TYPE *MmramRangesHob;
|
|
|
|
EFI_HOB_GUID_TYPE *MmramRangesHob;
|
|
|
|
EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData;
|
|
|
|
EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData;
|
|
|
|
EFI_MMRAM_DESCRIPTOR *MmramRanges;
|
|
|
|
EFI_MMRAM_DESCRIPTOR *MmramRanges;
|
|
|
|
@@ -688,58 +668,20 @@ StandaloneMmMain (
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Determine if the caller has passed a reference to a MM_CORE_PRIVATE_DATA
|
|
|
|
// Extract the MMRAM ranges from the MMRAM descriptor HOB
|
|
|
|
// structure in the Hoblist. This choice will govern how boot information is
|
|
|
|
|
|
|
|
// extracted later.
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
GuidHob = GetNextGuidHob (&gMmCoreDataHobGuid, HobStart);
|
|
|
|
MmramRangesHob = GetNextGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, HobStart);
|
|
|
|
if (GuidHob == NULL) {
|
|
|
|
if (MmramRangesHob == NULL) {
|
|
|
|
//
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
// Print the MMRAM ranges passed by the caller
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -764,19 +706,6 @@ StandaloneMmMain (
|
|
|
|
ASSERT (mMmramRanges != NULL);
|
|
|
|
ASSERT (mMmramRanges != NULL);
|
|
|
|
CopyMem (mMmramRanges, (VOID *)(UINTN)MmramRanges, mMmramRangeCount * sizeof (EFI_MMRAM_DESCRIPTOR));
|
|
|
|
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.
|
|
|
|
// No need to initialize memory service.
|
|
|
|
// It is done in the constructor of StandaloneMmCoreMemoryAllocationLib(),
|
|
|
|
// It is done in the constructor of StandaloneMmCoreMemoryAllocationLib(),
|
|
|
|
@@ -810,12 +739,20 @@ StandaloneMmMain (
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
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));
|
|
|
|
BfvHob = GetFirstHob (EFI_HOB_TYPE_FV);
|
|
|
|
if (gMmCorePrivate->StandaloneBfvAddress != 0) {
|
|
|
|
if (BfvHob != NULL) {
|
|
|
|
MmCoreFfsFindMmDriver ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)gMmCorePrivate->StandaloneBfvAddress, 0);
|
|
|
|
DEBUG ((DEBUG_INFO, "BFV address - 0x%x\n", BfvHob->BaseAddress));
|
|
|
|
MmDispatcher ();
|
|
|
|
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 ();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|