]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: AcpiS3SaveDxe: call S3Ready() at End-of-Dxe
authorLaszlo Ersek <lersek@redhat.com>
Sun, 26 Jul 2015 08:02:07 +0000 (08:02 +0000)
committerjljusten <jljusten@Edk2>
Sun, 26 Jul 2015 08:02:07 +0000 (08:02 +0000)
Call S3Ready() whenever the first of the following occurs:
- a driver signals End-of-Dxe,
- a driver calls EFI_ACPI_S3_SAVE_PROTOCOL.S3Save().

S3Ready() already contains a static, function scope "latch" that causes it
to exit early when called for the second time or later.

(At the moment, the only platform in the edk2 tree that includes this
driver is OvmfPkg. That platform does not signal End-of-Dxe (yet).)

http://thread.gmane.org/gmane.comp.bios.tianocore.devel/16088/focus=16146
Suggested-by: Yao Jiewen <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18034 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf

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/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
 #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
   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
 /**\r
   The Driver Entry Point.\r
   \r
@@ -591,6 +626,7 @@ InstallAcpiS3Save (
   )\r
 {\r
   EFI_STATUS        Status;\r
   )\r
 {\r
   EFI_STATUS        Status;\r
+  EFI_EVENT         EndOfDxeEvent;\r
 \r
   if (!QemuFwCfgS3Enabled()) {\r
     return EFI_LOAD_ERROR;\r
 \r
   if (!QemuFwCfgS3Enabled()) {\r
     return EFI_LOAD_ERROR;\r
@@ -612,5 +648,15 @@ InstallAcpiS3Save (
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
                   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
   return Status;\r
 }\r
index ae56a2079c1c64c415d931157394b2d5faa8aebe..81da2fb80c9c0ae55ff754b92b81171e1ec4bfed 100644 (file)
@@ -58,6 +58,7 @@
   gEfiAcpiS3ContextGuid                         # ALWAYS_CONSUMED\r
   gEfiAcpi20TableGuid                           # ALWAYS_CONSUMED  System Table\r
   gEfiAcpi10TableGuid                           # ALWAYS_CONSUMED  System Table\r
   gEfiAcpiS3ContextGuid                         # ALWAYS_CONSUMED\r
   gEfiAcpi20TableGuid                           # ALWAYS_CONSUMED  System Table\r
   gEfiAcpi10TableGuid                           # ALWAYS_CONSUMED  System Table\r
+  gEfiEndOfDxeEventGroupGuid                    ## CONSUMES  ## Event\r
 \r
 [Protocols]\r
   gEfiAcpiS3SaveProtocolGuid                    # PROTOCOL ALWAYS_PRODUCED\r
 \r
 [Protocols]\r
   gEfiAcpiS3SaveProtocolGuid                    # PROTOCOL ALWAYS_PRODUCED\r