]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/MmCommunicationDxe: relay architected PI events to MM context
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 5 Mar 2019 13:32:48 +0000 (14:32 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 11 Dec 2019 11:10:47 +0000 (11:10 +0000)
PI defines a few architected events that have significance in the MM
context as well as in the non-secure DXE context. So register notify
handlers for these events, and relay them into the standalone MM world.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Achin Gupta <achin.gupta@arm.com>
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf

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
index 450fc9bb541472aae1cba3eabeced26f8cb346a2..505228704ea5bb088bb2ab1e41f2f33da482a1ac 100644 (file)
 [Protocols]\r
   gEfiMmCommunicationProtocolGuid              ## PRODUCES\r
 \r
+[Guids]\r
+  gEfiEndOfDxeEventGroupGuid\r
+  gEfiEventExitBootServicesGuid\r
+  gEfiEventReadyToBootGuid\r
+\r
 [Pcd.common]\r
   gArmTokenSpaceGuid.PcdMmBufferBase\r
   gArmTokenSpaceGuid.PcdMmBufferSize\r