]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
ArmPkg/MmCommunicationDxe: relay architected PI events to MM context
[mirror_edk2.git] / ArmPkg / Drivers / MmCommunicationDxe / MmCommunication.c
index d06dcc4d2080cbb1db459adea79905d0a350ad3d..5f52afa0fed8d50044162d37da37f04bdb902f1c 100644 (file)
@@ -259,6 +259,43 @@ GetMmCompatibility ()
   return Status;\r
 }\r
 \r
+STATIC EFI_GUID* CONST mGuidedEventGuid[] = {\r
+  &gEfiEndOfDxeEventGroupGuid,\r
+  &gEfiEventExitBootServicesGuid,\r
+  &gEfiEventReadyToBootGuid,\r
+};\r
+\r
+STATIC EFI_EVENT mGuidedEvent[ARRAY_SIZE (mGuidedEventGuid)];\r
+\r
+/**\r
+  Event notification that is fired when GUIDed Event Group is signaled.\r
+\r
+  @param  Event                 The Event that is being processed, not used.\r
+  @param  Context               Event Context, not used.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+MmGuidedEventNotify (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+{\r
+  EFI_MM_COMMUNICATE_HEADER   Header;\r
+  UINTN                       Size;\r
+\r
+  //\r
+  // Use Guid to initialize EFI_SMM_COMMUNICATE_HEADER structure\r
+  //\r
+  CopyGuid (&Header.HeaderGuid, Context);\r
+  Header.MessageLength = 1;\r
+  Header.Data[0] = 0;\r
+\r
+  Size = sizeof (Header);\r
+  MmCommunicationCommunicate (&mMmCommunication, &Header, &Size);\r
+}\r
+\r
 /**\r
   The Entry Point for MM Communication\r
 \r
@@ -281,6 +318,7 @@ MmCommunicationInitialize (
   )\r
 {\r
   EFI_STATUS                 Status;\r
+  UINTN                      Index;\r
 \r
   // Check if we can make the MM call\r
   Status = GetMmCompatibility ();\r
@@ -345,8 +383,13 @@ MmCommunicationInitialize (
                   NULL,\r
                   &mSetVirtualAddressMapEvent\r
                   );\r
-  if (Status == EFI_SUCCESS) {\r
-    return Status;\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  for (Index = 0; Index < ARRAY_SIZE (mGuidedEventGuid); Index++) {\r
+    Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,\r
+                    MmGuidedEventNotify, mGuidedEventGuid[Index],\r
+                    mGuidedEventGuid[Index], &mGuidedEvent[Index]);\r
+    ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
   gBS->UninstallProtocolInterface (\r