]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished.
authorEric Dong <eric.dong@intel.com>
Wed, 11 Oct 2017 01:29:52 +0000 (09:29 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 12 Oct 2017 02:17:56 +0000 (10:17 +0800)
Install EdkiiSmmEndOfS3ResumeProtocol when S3 resume finished.
S3ResumePei will send S3 resume finished event to SmmCore through
communication buffer.

V2 change:
 None.

V3 change:
1. Uninstall the protocol right after install it to avoid run out of memory.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf

index 9e4390e15a1cbe69d44d57b0221ed8faaa297ac4..b833763f9a00ea3dc650f02f2210652afd1ccbd0 100644 (file)
@@ -75,13 +75,14 @@ BOOLEAN  mInLegacyBoot = FALSE;
 // Table of SMI Handlers that are registered by the SMM Core when it is initialized\r
 //\r
 SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {\r
-  { SmmDriverDispatchHandler,   &gEfiEventDxeDispatchGuid,          NULL, TRUE  },\r
-  { SmmReadyToLockHandler,      &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE }, \r
-  { SmmLegacyBootHandler,       &gEfiEventLegacyBootGuid,           NULL, FALSE },\r
-  { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,     NULL, FALSE },\r
-  { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,          NULL, FALSE },\r
-  { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,        NULL, TRUE },\r
-  { NULL,                       NULL,                               NULL, FALSE }\r
+  { SmmDriverDispatchHandler,   &gEfiEventDxeDispatchGuid,           NULL, TRUE  },\r
+  { SmmReadyToLockHandler,      &gEfiDxeSmmReadyToLockProtocolGuid,  NULL, TRUE }, \r
+  { SmmLegacyBootHandler,       &gEfiEventLegacyBootGuid,            NULL, FALSE },\r
+  { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,      NULL, FALSE },\r
+  { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,           NULL, FALSE },\r
+  { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,         NULL, TRUE },\r
+  { SmmEndOfS3ResumeHandler,    &gEdkiiSmmEndOfS3ResumeProtocolGuid, NULL, FALSE },\r
+  { NULL,                       NULL,                                NULL, FALSE }\r
 };\r
 \r
 UINTN                           mFullSmramRangeCount;\r
@@ -382,6 +383,60 @@ SmmEndOfDxeHandler (
   return Status;\r
 }\r
 \r
+/**\r
+  Software SMI handler that is called when the EndOfS3Resume event is trigged.\r
+  This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that\r
+  S3 resume has finished.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmEndOfS3ResumeHandler (\r
+  IN     EFI_HANDLE  DispatchHandle,\r
+  IN     CONST VOID  *Context,        OPTIONAL\r
+  IN OUT VOID        *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN       *CommBufferSize  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  SmmHandle;\r
+\r
+  DEBUG ((EFI_D_INFO, "SmmEndOfS3ResumeHandler\n"));\r
+\r
+  //\r
+  // Install SMM EndOfS3Resume protocol\r
+  //\r
+  SmmHandle = NULL;\r
+  Status = SmmInstallProtocolInterface (\r
+             &SmmHandle,\r
+             &gEdkiiSmmEndOfS3ResumeProtocolGuid,\r
+             EFI_NATIVE_INTERFACE,\r
+             NULL\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Uninstall the protocol here because the comsume just hook the\r
+  // installation event.\r
+  //\r
+  Status = SmmUninstallProtocolInterface (\r
+           SmmHandle,\r
+           &gEdkiiSmmEndOfS3ResumeProtocolGuid,\r
+           NULL\r
+           );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
 /**\r
   Determine if two buffers overlap in memory.\r
 \r
index b6f815c68da0d1fc8e0f8e8fa065293358421980..6cc824b0475b4aa8d797c75c991b2cc91f8d2055 100644 (file)
@@ -32,6 +32,7 @@
 #include <Protocol/SmmExitBootServices.h>\r
 #include <Protocol/SmmLegacyBoot.h>\r
 #include <Protocol/SmmReadyToBoot.h>\r
+#include <Protocol/SmmEndOfS3Resume.h>\r
 \r
 #include <Guid/Apriori.h>\r
 #include <Guid/EventGroup.h>\r
@@ -801,6 +802,29 @@ SmmReadyToBootHandler (
   IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
   );\r
 \r
+/**\r
+  Software SMI handler that is called when the EndOfS3Resume event is trigged.\r
+  This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that\r
+  S3 resume has finished.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmEndOfS3ResumeHandler (\r
+  IN     EFI_HANDLE  DispatchHandle,\r
+  IN     CONST VOID  *Context,        OPTIONAL\r
+  IN OUT VOID        *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN       *CommBufferSize  OPTIONAL\r
+  );\r
+\r
 /**\r
   Place holder function until all the SMM System Table Service are available.\r
 \r
index 49ae6fbb57d13f109e5c582305cd19ec953b2124..a01ef7ed57b73496e8b089bed3868c611765c82c 100644 (file)
@@ -79,6 +79,7 @@
   gEdkiiSmmExitBootServicesProtocolGuid         ## SOMETIMES_PRODUCES\r
   gEdkiiSmmLegacyBootProtocolGuid               ## SOMETIMES_PRODUCES\r
   gEdkiiSmmReadyToBootProtocolGuid              ## PRODUCES\r
+  gEdkiiSmmEndOfS3ResumeProtocolGuid            ## SOMETIMES_PRODUCES\r
 \r
   gEfiSmmSwDispatch2ProtocolGuid                ## SOMETIMES_CONSUMES\r
   gEfiSmmSxDispatch2ProtocolGuid                ## SOMETIMES_CONSUMES\r