]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
OvmfPkg: PlatformBdsLib: signal End-of-Dxe event group
[mirror_edk2.git] / OvmfPkg / Library / PlatformBdsLib / BdsPlatform.c
index de13c6b5c34a2ea7bb2af6eec6fbb744953ee008..ce299875cdd21f5a8642717746766a126bf96a7c 100644 (file)
@@ -1163,6 +1163,27 @@ Returns:
 }\r
 \r
 \r
+/**\r
+  Empty callback function executed when the EndOfDxe event group is signaled.\r
+\r
+  We only need this function because we'd like to signal EndOfDxe, and for that\r
+  we need to create an event, with a callback function.\r
+\r
+  @param[in] Event    Event whose notification function is being invoked.\r
+  @param[in] Context  The pointer to the notification function's context, which\r
+                      is implementation-dependent.\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+OnEndOfDxe (\r
+  IN EFI_EVENT Event,\r
+  IN VOID      *Context\r
+  )\r
+{\r
+}\r
+\r
+\r
 VOID\r
 EFIAPI\r
 PlatformBdsPolicyBehavior (\r
@@ -1197,12 +1218,28 @@ Returns:
 {\r
   EFI_STATUS                         Status;\r
   EFI_BOOT_MODE                      BootMode;\r
+  EFI_EVENT                          EndOfDxeEvent;\r
 \r
   DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));\r
 \r
   VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,\r
     ConnectRootBridge, NULL);\r
 \r
+  //\r
+  // We can't signal End-of-Dxe earlier than this. Namely, End-of-Dxe triggers\r
+  // the preparation of S3 system information. That logic has a hard dependency\r
+  // on the presence of the FACS ACPI table. Since our ACPI tables are only\r
+  // installed after PCI enumeration completes, we must not trigger the S3 save\r
+  // earlier, hence we can't signal End-of-Dxe earlier.\r
+  //\r
+  Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnEndOfDxe,\r
+                  NULL /* NotifyContext */, &gEfiEndOfDxeEventGroupGuid,\r
+                  &EndOfDxeEvent);\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->SignalEvent (EndOfDxeEvent);\r
+    gBS->CloseEvent (EndOfDxeEvent);\r
+  }\r
+\r
   if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {\r
     DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "\r
       "from disk since flash variables appear to be supported.\n"));\r