TianoCore EDK2 master
Loading...
Searching...
No Matches
StandaloneMmCore.c File Reference
#include "StandaloneMmCore.h"

Go to the source code of this file.

Functions

EFI_STATUS MmDispatcher (VOID)
 
EFI_STATUS EFIAPI MmEfiNotAvailableYetArg5 (UINTN Arg1, UINTN Arg2, UINTN Arg3, UINTN Arg4, UINTN Arg5)
 
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 MmReadyToBootHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
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 MmEndOfPeiHandler (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)
 
VOID MmCoreInstallLoadedImage (VOID)
 
VOID MmCorePrepareCommunicationBuffer (VOID)
 
VOID EFIAPI MmEntryPoint (IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext)
 
EFI_STATUS EFIAPI MmConfigurationMmNotify (IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
 
VOID MigrateMemoryAllocationHobs (IN VOID *HobStart)
 
VOID * InitializeMmHobList (IN VOID *HobStart, IN EFI_MMRAM_DESCRIPTOR *MmramRanges, IN UINTN MmramRangeCount)
 
EFI_STATUS EFIAPI StandaloneMmMain (IN VOID *HobStart)
 

Variables

EFI_HANDLE mMmCpuHandle = NULL
 
EFI_MM_SYSTEM_TABLE gMmCoreMmst
 
MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers []
 
BOOLEAN mMmEntryPointRegistered = FALSE
 
MM_COMM_BUFFERmMmCommunicationBuffer
 
VOID * mInternalCommBufferCopy
 
EFI_FIRMWARE_VOLUME_HEADERmBfv = NULL
 

Detailed Description

MM Core Main Entry Point

Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file StandaloneMmCore.c.

Function Documentation

◆ InitializeMmHobList()

VOID * InitializeMmHobList ( IN VOID *  HobStart,
IN EFI_MMRAM_DESCRIPTOR MmramRanges,
IN UINTN  MmramRangeCount 
)

This function is responsible for validating the input HOB list and initializing a new HOB list in MMRAM based on the input HOB list.

Parameters
[in]HobStartPointer to the start of the HOB list.
[in]MmramRangesPointer to the Mmram ranges.
[in]MmramRangeCountCount of Mmram ranges.
Return values
Pointerto the new location of hob list in MMRAM.

Definition at line 713 of file StandaloneMmCore.c.

◆ MigrateMemoryAllocationHobs()

VOID MigrateMemoryAllocationHobs ( IN VOID *  HobStart)

Migrate MemoryBaseAddress in memory allocation HOBs with BootServiceData type and non-zero GUID name from Boot Service memory to MMRAM.

Parameters
[in]HobStartPointer to the start of the HOB list.

Definition at line 656 of file StandaloneMmCore.c.

◆ MmConfigurationMmNotify()

EFI_STATUS EFIAPI MmConfigurationMmNotify ( IN CONST EFI_GUID Protocol,
IN VOID *  Interface,
IN EFI_HANDLE  Handle 
)

Register the MM Entry Point provided by the MM Core with the MM Configuration protocol.

Parameters
[in]ProtocolPointer to the protocol.
[in]InterfacePointer to the MM Configuration protocol.
[in]HandleHandle.
Return values
EFI_SUCCESSSuccess.

Definition at line 616 of file StandaloneMmCore.c.

◆ MmCoreInstallLoadedImage()

VOID MmCoreInstallLoadedImage ( VOID  )

Install LoadedImage protocol for MM Core.

Definition at line 364 of file StandaloneMmCore.c.

◆ MmCorePrepareCommunicationBuffer()

VOID MmCorePrepareCommunicationBuffer ( VOID  )

Prepare communication buffer for MMI.

Definition at line 443 of file StandaloneMmCore.c.

◆ MmDispatcher()

EFI_STATUS MmDispatcher ( VOID  )

This is the main Dispatcher for MM and it exits when there are no more drivers to run. Drain the mScheduledQueue and load and start a PE image for each driver. Search the mDiscoveredList to see if any driver can be placed on the mScheduledQueue. If no drivers are placed on the mScheduledQueue exit the function.

Return values
EFI_SUCCESSAll of the MM Drivers that could be dispatched have been run and the MM Entry Point has been registered.
EFI_NOT_READYThe MM Driver that registered the MM Entry Point was just dispatched.
EFI_NOT_FOUNDThere are no MM Drivers available to be dispatched.
EFI_ALREADY_STARTEDThe MM Dispatcher is already running

Definition at line 379 of file Dispatcher.c.

◆ MmEfiNotAvailableYetArg5()

EFI_STATUS EFIAPI MmEfiNotAvailableYetArg5 ( UINTN  Arg1,
UINTN  Arg2,
UINTN  Arg3,
UINTN  Arg4,
UINTN  Arg5 
)

Place holder function until all the MM System Table Service are available.

Note: This function is only used by MMRAM invocation. It is never used by DXE invocation.

Parameters
Arg1Undefined
Arg2Undefined
Arg3Undefined
Arg4Undefined
Arg5Undefined
Returns
EFI_NOT_AVAILABLE_YET

Definition at line 107 of file StandaloneMmCore.c.

◆ MmEndOfDxeHandler()

EFI_STATUS EFIAPI MmEndOfDxeHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software MMI handler that is called when the EndOfDxe event is signaled. This function installs the MM EndOfDxe Protocol so MM Drivers are informed that platform code will invoke 3rd part code.

Parameters
DispatchHandleThe unique handle assigned to this handler by MmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-MM environment into an MM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 335 of file StandaloneMmCore.c.

◆ MmEndOfPeiHandler()

EFI_STATUS EFIAPI MmEndOfPeiHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software MMI handler that is called when the EndOfPei event is signaled. This function installs the MM EndOfPei Protocol so MM Drivers are informed that EndOfPei event is signaled.

Parameters
DispatchHandleThe unique handle assigned to this handler by MmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-MM environment into an MM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 295 of file StandaloneMmCore.c.

◆ MmEntryPoint()

VOID EFIAPI MmEntryPoint ( IN CONST EFI_MM_ENTRY_CONTEXT MmEntryContext)

The main entry point to MM Foundation.

Note: This function is only used by MMRAM invocation. It is never used by DXE invocation.

Parameters
MmEntryContextProcessor information and functionality needed by MM Foundation.

Definition at line 506 of file StandaloneMmCore.c.

◆ MmExitBootServiceHandler()

EFI_STATUS EFIAPI MmExitBootServiceHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software MMI handler that is called when a ExitBoot Service event is signaled.

Parameters
DispatchHandleThe unique handle assigned to this handler by MmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-MM environment into an MM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 136 of file StandaloneMmCore.c.

◆ MmReadyToBootHandler()

EFI_STATUS EFIAPI MmReadyToBootHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software MMI handler that is called when a ExitBoot Service event is signaled.

Parameters
DispatchHandleThe unique handle assigned to this handler by MmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-MM environment into an MM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 176 of file StandaloneMmCore.c.

◆ MmReadyToLockHandler()

EFI_STATUS EFIAPI MmReadyToLockHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software MMI handler that is called when the DxeMmReadyToLock protocol is added or if gEfiEventReadyToBootGuid is signaled. This function unregisters the Software SMIs that are nor required after MMRAM is locked and installs the MM Ready To Lock Protocol so MM Drivers are informed that MMRAM is about to be locked.

Parameters
DispatchHandleThe unique handle assigned to this handler by MmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-MM environment into an MM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 220 of file StandaloneMmCore.c.

◆ StandaloneMmMain()

EFI_STATUS EFIAPI StandaloneMmMain ( IN VOID *  HobStart)

The Entry Point for MM Core

Install DXE Protocols and reload MM Core into MMRAM and register MM Core EntryPoint on the MMI vector.

Note: This function is called for both DXE invocation and MMRAM invocation.

Parameters
HobStartPointer to the start of the HOB list.
Return values
EFI_SUCCESSSuccess.
EFI_UNSUPPORTEDUnsupported operation.

Definition at line 794 of file StandaloneMmCore.c.

Variable Documentation

◆ gMmCoreMmst

EFI_MM_SYSTEM_TABLE gMmCoreMmst

Definition at line 25 of file StandaloneMmCore.c.

◆ mBfv

Definition at line 89 of file StandaloneMmCore.c.

◆ mInternalCommBufferCopy

VOID* mInternalCommBufferCopy

Definition at line 88 of file StandaloneMmCore.c.

◆ mMmCommunicationBuffer

MM_COMM_BUFFER* mMmCommunicationBuffer

Definition at line 87 of file StandaloneMmCore.c.

◆ mMmCoreMmiHandlers

MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[]
Initial value:
= {
{ MmDriverDispatchHandler, &gEventMmDispatchGuid, NULL, FALSE },
{ MmReadyToLockHandler, &gEfiDxeMmReadyToLockProtocolGuid, NULL, TRUE },
{ MmEndOfPeiHandler, &gEfiMmEndOfPeiProtocol, NULL, FALSE },
{ MmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, FALSE },
{ MmExitBootServiceHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE },
{ MmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },
{ NULL, NULL, NULL, FALSE },
}
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
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 EFIAPI MmEndOfPeiHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
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 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)
EFI_STATUS EFIAPI MmDriverDispatchHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: Dispatcher.c:736

Definition at line 76 of file StandaloneMmCore.c.

◆ mMmCpuHandle

EFI_HANDLE mMmCpuHandle = NULL

Definition at line 20 of file StandaloneMmCore.c.

◆ mMmEntryPointRegistered

BOOLEAN mMmEntryPointRegistered = FALSE

Definition at line 86 of file StandaloneMmCore.c.