]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone
authorStar Zeng <star.zeng@intel.com>
Fri, 8 Dec 2017 10:06:25 +0000 (18:06 +0800)
committerStar Zeng <star.zeng@intel.com>
Sat, 3 Mar 2018 06:20:38 +0000 (14:20 +0800)
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@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 d2f0207b5c83b78e39fde30176787131fb24a2f6..686b9b45a5564f710554e2eb4b1b3823a6931cd9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM Core Main Entry Point\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -87,6 +87,7 @@ SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {
   { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,      NULL, FALSE },\r
   { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,           NULL, FALSE },\r
   { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,         NULL, TRUE },\r
+  { SmmS3SmmInitDoneHandler,    &gEdkiiS3SmmInitDoneGuid,            NULL, FALSE },\r
   { SmmEndOfS3ResumeHandler,    &gEdkiiEndOfS3ResumeGuid,            NULL, FALSE },\r
   { NULL,                       NULL,                                NULL, FALSE }\r
 };\r
@@ -471,6 +472,65 @@ SmmEndOfDxeHandler (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Software SMI handler that is called when the S3SmmInitDone signal is triggered.\r
+  This function installs the SMM S3SmmInitDone Protocol so SMM Drivers are informed that\r
+  S3 SMM initialization has been done.\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
+SmmS3SmmInitDoneHandler (\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 ((DEBUG_INFO, "SmmS3SmmInitDoneHandler\n"));\r
+\r
+  if (!mDuringS3Resume) {\r
+    DEBUG ((DEBUG_ERROR, "It is not during S3 resume\n"));\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Install SMM S3SmmInitDone protocol\r
+  //\r
+  SmmHandle = NULL;\r
+  Status = SmmInstallProtocolInterface (\r
+             &SmmHandle,\r
+             &gEdkiiS3SmmInitDoneGuid,\r
+             EFI_NATIVE_INTERFACE,\r
+             NULL\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Uninstall the protocol here because the comsumer just hook the\r
+  // installation event.\r
+  //\r
+  Status = SmmUninstallProtocolInterface (\r
+           SmmHandle,\r
+           &gEdkiiS3SmmInitDoneGuid,\r
+           NULL\r
+           );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
 /**\r
   Software SMI handler that is called when the EndOfS3Resume signal is triggered.\r
   This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that\r
index 8c10d833e2aebe1f98e1745067d3ce67d28daa41..2f6032646f46d59fecab8ad68332467d0a5bbc05 100644 (file)
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by SmmCore module.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -42,6 +42,7 @@
 #include <Guid/LoadModuleAtFixedAddress.h>\r
 #include <Guid/SmiHandlerProfile.h>\r
 #include <Guid/EndOfS3Resume.h>\r
+#include <Guid/S3SmmInitDone.h>\r
 \r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
@@ -810,6 +811,29 @@ SmmReadyToBootHandler (
   IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
   );\r
 \r
+/**\r
+  Software SMI handler that is called when the S3SmmInitDone signal is triggered.\r
+  This function installs the SMM S3SmmInitDone Protocol so SMM Drivers are informed that\r
+  S3 SMM initialization has been done.\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
+SmmS3SmmInitDoneHandler (\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
   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
index 5c04e851f94b858c4d969d69be969ae4e7e4ae40..09cffb879e6f510eddec20f7ce5055f4e1e11536 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This module provide an SMM CIS compliant implementation of SMM Core.\r
 #\r
-# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
   ## SOMETIMES_PRODUCES   ## GUID # SmiHandlerRegister\r
   gSmiHandlerProfileGuid\r
   gEdkiiEndOfS3ResumeGuid ## SOMETIMES_PRODUCES ## GUID # Install protocol\r
+  gEdkiiS3SmmInitDoneGuid ## SOMETIMES_PRODUCES ## GUID # Install protocol\r
 \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   PiSmmCoreExtra.uni\r