29 EFI_MM_SYSTEM_TABLE_REVISION,
30 sizeof (gMmCoreMmst.
Hdr)
86BOOLEAN mMmEntryPointRegistered =
FALSE;
88VOID *mInternalCommBufferCopy;
138 IN CONST VOID *Context OPTIONAL,
139 IN OUT VOID *CommBuffer OPTIONAL,
148 if (!mInExitBootServices) {
152 &gEfiEventExitBootServicesGuid,
158 mInExitBootServices =
TRUE;
178 IN CONST VOID *Context OPTIONAL,
179 IN OUT VOID *CommBuffer OPTIONAL,
188 if (!mInReadyToBoot) {
192 &gEfiEventReadyToBootGuid,
198 mInReadyToBoot =
TRUE;
222 IN CONST VOID *Context OPTIONAL,
223 IN OUT VOID *CommBuffer OPTIONAL,
231 DEBUG ((DEBUG_INFO,
"MmReadyToLockHandler\n"));
236 for (Index = 0; mMmCoreMmiHandlers[Index].HandlerType !=
NULL; Index++) {
237 if (mMmCoreMmiHandlers[Index].UnRegister) {
248 &gEfiMmReadyToLockProtocolGuid,
297 IN CONST VOID *Context OPTIONAL,
298 IN OUT VOID *CommBuffer OPTIONAL,
305 DEBUG ((DEBUG_INFO,
"MmEndOfPeiHandler\n"));
312 &gEfiMmEndOfPeiProtocol,
337 IN CONST VOID *Context OPTIONAL,
338 IN OUT VOID *CommBuffer OPTIONAL,
345 DEBUG ((DEBUG_INFO,
"MmEndOfDxeHandler\n"));
352 &gEfiMmEndOfDxeProtocolGuid,
370 UINT64 MmCoreImageLength;
379 while ((Hob.Raw =
GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) !=
NULL) {
385 &gEfiHobMemoryAllocModuleGuid
393 Hob.Raw = GET_NEXT_HOB (Hob);
396 if (Hob.Raw ==
NULL) {
407 ASSERT (LoadedImage !=
NULL);
408 if (LoadedImage ==
NULL) {
422 LoadedImage->
ImageSize = MmCoreImageLength;
432 &gEfiLoadedImageProtocolGuid,
451 mMmCommunicationBuffer =
NULL;
452 mInternalCommBufferCopy =
NULL;
455 ASSERT (GuidHob !=
NULL);
456 if (GuidHob ==
NULL) {
460 mMmCommunicationBuffer = (
MM_COMM_BUFFER *)GET_GUID_HOB_DATA (GuidHob);
463 "MM Communication Buffer is at %x, number of pages is %x\n",
464 mMmCommunicationBuffer->PhysicalStart,
465 mMmCommunicationBuffer->NumberOfPages
467 ASSERT (mMmCommunicationBuffer->PhysicalStart != 0 && mMmCommunicationBuffer->NumberOfPages != 0);
470 mMmCommunicationBuffer->PhysicalStart,
474 mMmCommunicationBuffer =
NULL;
475 DEBUG ((DEBUG_ERROR,
"MM Communication Buffer is invalid!\n"));
483 mMmCommunicationBuffer->NumberOfPages,
487 if (EFI_ERROR (Status)) {
491 mInternalCommBufferCopy = (VOID *)(
UINTN)Buffer;
492 DEBUG ((DEBUG_INFO,
"Internal Communication Buffer Copy is at %p\n", mInternalCommBufferCopy));
515 DEBUG ((DEBUG_INFO,
"MmEntryPoint ...\n"));
531 if ((mMmCommunicationBuffer !=
NULL) && (mInternalCommBufferCopy !=
NULL)) {
544 mInternalCommBufferCopy,
545 (VOID *)(
UINTN)mMmCommunicationBuffer->PhysicalStart,
549 (UINT8 *)mInternalCommBufferCopy + BufferSize,
558 CommunicateHeader->
Data,
568 (VOID *)(
UINTN)mMmCommunicationBuffer->PhysicalStart,
569 mInternalCommBufferCopy,
573 DEBUG ((DEBUG_ERROR,
"Returned buffer size is larger than the size of MM Communication Buffer\n"));
585 DEBUG ((DEBUG_ERROR,
"Input buffer size is larger than the size of MM Communication Buffer\n"));
590 DEBUG ((DEBUG_ERROR,
"No valid communication buffer, no Synchronous MMI will be processed\n"));
602 DEBUG ((DEBUG_INFO,
"MmEntryPoint Done\n"));
625 DEBUG ((DEBUG_INFO,
"MmConfigurationMmNotify(%g) - %x\n", Protocol, Interface));
627 MmConfiguration = Interface;
639 mMmEntryPointRegistered =
TRUE;
644 DEBUG ((DEBUG_INFO,
"MM Core registered MM Entry Point address %p\n",
MmEntryPoint));
664 MemoryAllocationHob =
NULL;
665 Hob.Raw =
GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, HobStart);
666 while (Hob.Raw !=
NULL) {
671 if (MemoryInMmram !=
NULL) {
674 "Migrate Memory Allocation Hob (%g) from %08x to %08p\n",
690 "Error - Memory Allocation Hob [%08x, %08x] doesn't have a GUID name specified\n",
697 Hob.Raw = GET_NEXT_HOB (Hob);
698 Hob.Raw =
GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
729 ASSERT (HobStart !=
NULL);
731 Hob.Raw = (UINT8 *)HobStart;
732 while (!END_OF_HOB_LIST (Hob)) {
733 Hob.Raw = GET_NEXT_HOB (Hob);
734 if (Hob.Header->
HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
738 for (Index = 0; Index < MmramRangeCount; Index++) {
739 MmramBase = MmramRanges[Index].PhysicalStart;
740 MmramEnd = MmramRanges[Index].PhysicalStart + MmramRanges[Index].PhysicalSize;
742 if ((MmramBase < ResourceHobEnd) && (MmramEnd > ResourceHobBase)) {
749 "The resource HOB range [0x%lx, 0x%lx] overlaps with MMRAM range\n",
763 DEBUG ((DEBUG_INFO,
"HobSize - 0x%x\n", HobSize));
766 DEBUG ((DEBUG_INFO,
"MmHobStart - 0x%x\n", MmHobStart));
767 ASSERT (MmHobStart !=
NULL);
768 CopyMem (MmHobStart, HobStart, HobSize);
770 DEBUG ((DEBUG_INFO,
"MmInstallConfigurationTable For HobList\n"));
804 UINTN MmramRangeCount;
807 ProcessLibraryConstructorList (HobStart, &gMmCoreMmst);
809 DEBUG ((DEBUG_INFO,
"MmMain - 0x%x\n", HobStart));
818 MmramRangesHob =
GetNextGuidHob (&gEfiSmmSmramMemoryGuid, HobStart);
819 if (MmramRangesHob ==
NULL) {
820 MmramRangesHob =
GetNextGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, HobStart);
821 if (MmramRangesHob ==
NULL) {
822 return EFI_UNSUPPORTED;
826 MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
827 ASSERT (MmramRangesHobData !=
NULL);
830 ASSERT (MmramRanges);
831 ASSERT (MmramRangeCount);
836 DEBUG ((DEBUG_INFO,
"MmramRangeCount - 0x%x\n", MmramRangeCount));
837 for (Index = 0; Index < MmramRangeCount; Index++) {
840 "MmramRanges[%d]: 0x%016lx - 0x%lx\n",
842 MmramRanges[Index].CpuStart,
843 MmramRanges[Index].PhysicalSize
862 DEBUG ((DEBUG_INFO,
"MmRegisterProtocolNotify - MmConfigurationMmProtocol\n"));
864 &gEfiMmConfigurationProtocolGuid,
874 if (BfvHob !=
NULL) {
876 DEBUG ((DEBUG_INFO,
"BFV size - 0x%x\n", BfvHob->
Length));
887 DEBUG ((DEBUG_INFO,
"Mm Dispatch StandaloneBfvAddress - 0x%08x\n", mBfv));
890 if (!
FeaturePcdGet (PcdRestartMmDispatcherOnceMmEntryRegistered)) {
900 for (Index = 0; mMmCoreMmiHandlers[Index].HandlerType !=
NULL; Index++) {
902 mMmCoreMmiHandlers[Index].Handler,
903 mMmCoreMmiHandlers[Index].HandlerType,
904 &mMmCoreMmiHandlers[Index].DispatchHandle
906 DEBUG ((DEBUG_INFO,
"MmiHandlerRegister - GUID %g - Status %d\n", mMmCoreMmiHandlers[Index].HandlerType, Status));
916 DEBUG ((DEBUG_INFO,
"MmMain Done!\n"));
VOID *EFIAPI GetFirstHob(IN UINT16 Type)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
VOID *EFIAPI GetHobList(VOID)
VOID EFIAPI CpuDeadLoop(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI PrintHobList(IN CONST VOID *HobStart, IN HOB_PRINT_HANDLER PrintHandler OPTIONAL)
#define EFI_LOADED_IMAGE_PROTOCOL_REVISION
#define OFFSET_OF(TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
EFI_STATUS(EFIAPI * EFI_MM_CPU_IO)(IN CONST EFI_MM_CPU_IO_PROTOCOL *This, IN EFI_MM_IO_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN OUT VOID *Buffer)
EFI_STATUS EFIAPI MmiHandlerRegister(IN EFI_MM_HANDLER_ENTRY_POINT Handler, IN CONST EFI_GUID *HandlerType OPTIONAL, OUT EFI_HANDLE *DispatchHandle)
EFI_STATUS EFIAPI MmiManage(IN CONST EFI_GUID *HandlerType, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI MmiHandlerUnRegister(IN EFI_HANDLE DispatchHandle)
#define FeaturePcdGet(TokenName)
VOID(EFIAPI * EFI_MM_ENTRY_POINT)(IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext)
#define MM_MMST_SIGNATURE
#define EFI_NOT_AVAILABLE_YET
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID *EFIAPI AllocatePages(IN UINTN Pages)
EFI_STATUS EFIAPI MmReadyToBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS MmDispatcher(VOID)
EFI_STATUS EFIAPI MmEndOfPeiHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI MmConfigurationMmNotify(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
VOID MmCoreInstallLoadedImage(VOID)
EFI_STATUS EFIAPI MmReadyToLockHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI MmEfiNotAvailableYetArg5(UINTN Arg1, UINTN Arg2, UINTN Arg3, UINTN Arg4, UINTN Arg5)
VOID MmCorePrepareCommunicationBuffer(VOID)
VOID * InitializeMmHobList(IN VOID *HobStart, IN EFI_MMRAM_DESCRIPTOR *MmramRanges, IN UINTN MmramRangeCount)
EFI_STATUS EFIAPI StandaloneMmMain(IN VOID *HobStart)
VOID MigrateMemoryAllocationHobs(IN VOID *HobStart)
VOID EFIAPI MmEntryPoint(IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext)
EFI_STATUS EFIAPI MmExitBootServiceHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI MmEndOfDxeHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
BOOLEAN EFIAPI MmIsBufferOutsideMmValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
EFI_STATUS EFIAPI MmDriverDispatchHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS MmCoreFfsFindMmDriver(IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, IN UINT32 Depth)
EFI_STATUS EFIAPI MmHandleProtocol(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, OUT VOID **Interface)
EFI_STATUS EFIAPI MmInstallProtocolInterface(IN OUT EFI_HANDLE *UserHandle, IN EFI_GUID *Protocol, IN EFI_INTERFACE_TYPE InterfaceType, IN VOID *Interface)
EFI_STATUS EFIAPI MmUninstallProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, IN VOID *Interface)
EFI_STATUS EFIAPI MmInstallConfigurationTable(IN CONST EFI_MM_SYSTEM_TABLE *SystemTable, IN CONST EFI_GUID *Guid, IN VOID *Table, IN UINTN TableSize)
EFI_STATUS EFIAPI MmLocateProtocol(IN EFI_GUID *Protocol, IN VOID *Registration OPTIONAL, OUT VOID **Interface)
EFI_STATUS EFIAPI MmLocateHandle(IN EFI_LOCATE_SEARCH_TYPE SearchType, IN EFI_GUID *Protocol OPTIONAL, IN VOID *SearchKey OPTIONAL, IN OUT UINTN *BufferSize, OUT EFI_HANDLE *Buffer)
EFI_STATUS EFIAPI MmRegisterProtocolNotify(IN CONST EFI_GUID *Protocol, IN EFI_MM_NOTIFY_FN Function, OUT VOID **Registration)
EFI_STATUS EFIAPI MmAllocatePages(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN NumberOfPages, OUT EFI_PHYSICAL_ADDRESS *Memory)
EFI_STATUS EFIAPI MmFreePages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
EFI_STATUS EFIAPI MmAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
EFI_STATUS EFIAPI MmFreePool(IN VOID *Buffer)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)
EFI_MM_STARTUP_THIS_AP MmStartupThisAp
EFI_PHYSICAL_ADDRESS BaseAddress
EFI_PHYSICAL_ADDRESS MemoryBaseAddress
EFI_MEMORY_TYPE MemoryType
EFI_HOB_MEMORY_ALLOCATION_HEADER MemoryAllocationHeader
EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_MEMORY_TYPE ImageDataType
The memory type that the data sections were loaded as.
EFI_MEMORY_TYPE ImageCodeType
The memory type that the code sections were loaded as.
UINT64 ImageSize
The size in bytes of the loaded image.
EFI_SYSTEM_TABLE * SystemTable
the image's EFI system table pointer.
VOID * ImageBase
The base address at which the image was loaded.
UINT32 NumberOfMmReservedRegions
EFI_MMRAM_DESCRIPTOR Descriptor[1]
BOOLEAN IsCommBufferValid