MmiHandlerUnRegister\r
};\r
\r
-//\r
-// Flag to determine if the platform has performed a legacy boot.\r
-// If this flag is TRUE, then the runtime code and runtime data associated with the\r
-// MM IPL are converted to free memory, so the MM Core must guarantee that is\r
-// does not touch of the code/data associated with the MM IPL if this flag is TRUE.\r
-//\r
-BOOLEAN mInLegacyBoot = FALSE;\r
-\r
//\r
// Table of MMI Handlers that are registered by the MM Core when it is initialized\r
//\r
MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = {\r
{ MmReadyToLockHandler, &gEfiDxeMmReadyToLockProtocolGuid, NULL, TRUE },\r
{ MmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, FALSE },\r
- { MmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE },\r
{ MmExitBootServiceHandler,&gEfiEventExitBootServicesGuid, NULL, FALSE },\r
{ MmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },\r
{ NULL, NULL, NULL, FALSE },\r
return EFI_NOT_AVAILABLE_YET;\r
}\r
\r
-/**\r
- Software MMI handler that is called when a Legacy Boot event is signaled. The MM\r
- Core uses this signal to know that a Legacy Boot has been performed and that\r
- gMmCorePrivate that is shared between the UEFI and MM execution environments can\r
- not be accessed from MM anymore since that structure is considered free memory by\r
- a legacy OS.\r
-\r
- @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().\r
- @param Context Points to an optional handler context which was specified when the handler was registered.\r
- @param CommBuffer A pointer to a collection of data in memory that will\r
- be conveyed from a non-MM environment into an MM environment.\r
- @param CommBufferSize The size of the CommBuffer.\r
-\r
- @return Status Code\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-MmLegacyBootHandler (\r
- IN EFI_HANDLE DispatchHandle,\r
- IN CONST VOID *Context, OPTIONAL\r
- IN OUT VOID *CommBuffer, OPTIONAL\r
- IN OUT UINTN *CommBufferSize OPTIONAL\r
- )\r
-{\r
- EFI_HANDLE MmHandle;\r
- EFI_STATUS Status = EFI_SUCCESS;\r
-\r
- if (!mInLegacyBoot) {\r
- MmHandle = NULL;\r
- Status = MmInstallProtocolInterface (\r
- &MmHandle,\r
- &gEfiEventLegacyBootGuid,\r
- EFI_NATIVE_INTERFACE,\r
- NULL\r
- );\r
- }\r
- mInLegacyBoot = TRUE;\r
- return Status;\r
-}\r
-\r
/**\r
Software MMI handler that is called when a ExitBoot Service event is signaled.\r
\r
{\r
EFI_STATUS Status;\r
EFI_MM_COMMUNICATE_HEADER *CommunicateHeader;\r
- BOOLEAN InLegacyBoot;\r
\r
DEBUG ((DEBUG_INFO, "MmEntryPoint ...\n"));\r
\r
//\r
// If a legacy boot has occured, then make sure gMmCorePrivate is not accessed\r
//\r
- InLegacyBoot = mInLegacyBoot;\r
- if (!InLegacyBoot) {\r
- //\r
- // TBD: Mark the InMm flag as TRUE\r
- //\r
- gMmCorePrivate->InMm = TRUE;\r
\r
+ //\r
+ // TBD: Mark the InMm flag as TRUE\r
+ //\r
+ gMmCorePrivate->InMm = TRUE;\r
+\r
+ //\r
+ // Check to see if this is a Synchronous MMI sent through the MM Communication\r
+ // Protocol or an Asynchronous MMI\r
+ //\r
+ if (gMmCorePrivate->CommunicationBuffer != 0) {\r
//\r
- // Check to see if this is a Synchronous MMI sent through the MM Communication\r
- // Protocol or an Asynchronous MMI\r
+ // Synchronous MMI for MM Core or request from Communicate protocol\r
//\r
- if (gMmCorePrivate->CommunicationBuffer != 0) {\r
+ if (!MmIsBufferOutsideMmValid ((UINTN)gMmCorePrivate->CommunicationBuffer, gMmCorePrivate->BufferSize)) {\r
+ //\r
+ // If CommunicationBuffer is not in valid address scope, return EFI_INVALID_PARAMETER\r
//\r
- // Synchronous MMI for MM Core or request from Communicate protocol\r
+ gMmCorePrivate->CommunicationBuffer = 0;\r
+ gMmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER;\r
+ } else {\r
+ CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)gMmCorePrivate->CommunicationBuffer;\r
+ gMmCorePrivate->BufferSize -= OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);\r
+ Status = MmiManage (\r
+ &CommunicateHeader->HeaderGuid,\r
+ NULL,\r
+ CommunicateHeader->Data,\r
+ (UINTN *)&gMmCorePrivate->BufferSize\r
+ );\r
//\r
- if (!MmIsBufferOutsideMmValid ((UINTN)gMmCorePrivate->CommunicationBuffer, gMmCorePrivate->BufferSize)) {\r
- //\r
- // If CommunicationBuffer is not in valid address scope, return EFI_INVALID_PARAMETER\r
- //\r
- gMmCorePrivate->CommunicationBuffer = 0;\r
- gMmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER;\r
- } else {\r
- CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)gMmCorePrivate->CommunicationBuffer;\r
- gMmCorePrivate->BufferSize -= OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);\r
- Status = MmiManage (\r
- &CommunicateHeader->HeaderGuid,\r
- NULL,\r
- CommunicateHeader->Data,\r
- (UINTN *)&gMmCorePrivate->BufferSize\r
- );\r
- //\r
- // Update CommunicationBuffer, BufferSize and ReturnStatus\r
- // Communicate service finished, reset the pointer to CommBuffer to NULL\r
- //\r
- gMmCorePrivate->BufferSize += OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);\r
- gMmCorePrivate->CommunicationBuffer = 0;\r
- gMmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
- }\r
+ // Update CommunicationBuffer, BufferSize and ReturnStatus\r
+ // Communicate service finished, reset the pointer to CommBuffer to NULL\r
+ //\r
+ gMmCorePrivate->BufferSize += OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);\r
+ gMmCorePrivate->CommunicationBuffer = 0;\r
+ gMmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
}\r
}\r
\r
//\r
\r
//\r
- // If a legacy boot has occured, then make sure gMmCorePrivate is not accessed\r
+ // Clear the InMm flag as we are going to leave MM\r
//\r
- if (!InLegacyBoot) {\r
- //\r
- // Clear the InMm flag as we are going to leave MM\r
- //\r
- gMmCorePrivate->InMm = FALSE;\r
- }\r
+ gMmCorePrivate->InMm = FALSE;\r
\r
DEBUG ((DEBUG_INFO, "MmEntryPoint Done\n"));\r
}\r