]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
OvmfPkg: AcpiS3SaveDxe: call S3Ready() at End-of-Dxe
[mirror_edk2.git] / OvmfPkg / AcpiS3SaveDxe / AcpiS3Save.c
index f05764af8bcb219911ed55f036c6142f8ad33392..5eb33e0587012be8fff50d69689d1d29e47d797a 100644 (file)
@@ -29,6 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/AcpiVariableCompatibility.h>\r
 #include <Guid/AcpiS3Context.h>\r
 #include <Guid/Acpi.h>\r
+#include <Guid/EventGroup.h>\r
 #include <Protocol/AcpiS3Save.h>\r
 #include <Protocol/S3SaveState.h>\r
 #include <Protocol/DxeSmmReadyToLock.h>\r
@@ -570,6 +571,40 @@ S3Ready (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Callback function executed when the EndOfDxe event group is signaled.\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
+VOID\r
+EFIAPI\r
+OnEndOfDxe (\r
+  IN EFI_EVENT Event,\r
+  IN VOID      *Context\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  //\r
+  // Our S3Ready() function ignores both of its parameters, and always\r
+  // succeeds.\r
+  //\r
+  Status = S3Ready (\r
+             NULL, // This\r
+             NULL  // LegacyMemoryAddress\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Close the event, deregistering the callback and freeing resources.\r
+  //\r
+  Status = gBS->CloseEvent (Event);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+\r
 /**\r
   The Driver Entry Point.\r
   \r
@@ -591,6 +626,7 @@ InstallAcpiS3Save (
   )\r
 {\r
   EFI_STATUS        Status;\r
+  EFI_EVENT         EndOfDxeEvent;\r
 \r
   if (!QemuFwCfgS3Enabled()) {\r
     return EFI_LOAD_ERROR;\r
@@ -612,5 +648,15 @@ InstallAcpiS3Save (
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  OnEndOfDxe,\r
+                  NULL, /* NotifyContext */\r
+                  &gEfiEndOfDxeEventGroupGuid,\r
+                  &EndOfDxeEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
   return Status;\r
 }\r