StandaloneMmPkg: Produce StandaloneMM Entry/Exit Notify Protocol.

Produce StandaloneMM Entry/Exit Notify Protocol for PlatformHook.
This replaces the SMM core platform hook implementation in the
traditional SMM (Edk2\MdeModulePkg\Include\Library\SmmCorePlatformHookLib.h).
Unlike traditional SMM, Standalone MM prefers a more generic method to
perform platform-specific tasks before and after the SMI handler. Therefore,
it introduces the gMmEntryNotifyProtocolGuid and gMmExitNotifyProtocolGuid
protocols to notify the SMM entry and exit. This approach is more flexible
for the platform, eliminating the need to place all tasks in
PlatformHookBeforeSmmDispatch() and PlatformHookAfterSmmDispatch(), thus
platform code can depend on the protocol notification to perform
platform-specific tasks.

Signed-off-by: Diat Siah Yap <diat.siah.yap@intel.com>
This commit is contained in:
Diat Siah Yap
2025-01-23 20:25:13 -08:00
committed by mergify[bot]
parent 8d0a57d65a
commit 6d1bdc2b55
3 changed files with 40 additions and 2 deletions

View File

@@ -505,6 +505,7 @@ MmEntryPoint (
EFI_MM_COMMUNICATE_HEADER *CommunicateHeader;
MM_COMM_BUFFER_STATUS *CommunicationStatus;
UINTN BufferSize;
EFI_HANDLE MmHandle;
DEBUG ((DEBUG_INFO, "MmEntryPoint ...\n"));
@@ -514,9 +515,22 @@ MmEntryPoint (
CopyMem (&gMmCoreMmst.MmStartupThisAp, MmEntryContext, sizeof (EFI_MM_ENTRY_CONTEXT));
//
// Call platform hook before Mm Dispatch
// Install a protocol to notify BeforeMmDispatch.
//
// PlatformHookBeforeMmDispatch ();
MmHandle = NULL;
Status = MmInstallProtocolInterface (
&MmHandle,
&gEfiMmEntryNotifyProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
);
if (!EFI_ERROR (Status)) {
MmUninstallProtocolInterface (
MmHandle,
&gEfiMmEntryNotifyProtocolGuid,
NULL
);
}
//
// Check to see if this is a Synchronous MMI sent through the MM Communication
@@ -589,6 +603,24 @@ MmEntryPoint (
//
MmiManage (NULL, NULL, NULL, NULL);
//
// Install a protocol to notify AfterMmDispatch.
//
MmHandle = NULL;
Status = MmInstallProtocolInterface (
&MmHandle,
&gEfiMmExitNotifyProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
);
if (!EFI_ERROR (Status)) {
MmUninstallProtocolInterface (
MmHandle,
&gEfiMmExitNotifyProtocolGuid,
NULL
);
}
//
// TBD: Do not use private data structure ?
//

View File

@@ -63,6 +63,8 @@
gEfiLoadedImageProtocolGuid ## PRODUCES
gEfiMmConfigurationProtocolGuid ## CONSUMES
gEfiMmEndOfPeiProtocol ## PRODUCES
gEfiMmEntryNotifyProtocolGuid ## PRODUCES
gEfiMmExitNotifyProtocolGuid ## PRODUCES
[Guids]
gAprioriGuid ## SOMETIMES_CONSUMES ## File

View File

@@ -43,6 +43,10 @@
gEventMmDispatchGuid = { 0x7e6efffa, 0x69b4, 0x4c1b, { 0xa4, 0xc7, 0xaf, 0xf9, 0xc9, 0x24, 0x4f, 0xee }}
[Protocols]
gEfiMmEntryNotifyProtocolGuid = { 0x9bfbcc5f, 0x6435, 0x46d3, { 0xb9, 0xa5, 0x70, 0xfb, 0xa4, 0x71, 0xe1, 0x26 }}
gEfiMmExitNotifyProtocolGuid = { 0x0e265f48, 0x47c0, 0x471f, { 0x9c, 0x83, 0xc6, 0xd6, 0x57, 0x64, 0x21, 0xa4 }}
[Ppis]
gMmCoreFvLocationPpiGuid = { 0x47a00618, 0x237a, 0x4386, { 0x8f, 0xc5, 0x2a, 0x86, 0xd8, 0xac, 0x41, 0x05 }}