]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PiSmmCore: Control S3 related functionality through flag.
authorEric Dong <eric.dong@intel.com>
Thu, 21 Mar 2019 00:40:19 +0000 (08:40 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 21 Mar 2019 07:19:17 +0000 (15:19 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=1590

Use PcdAcpiS3Enable to control whether need to enable S3 related
functionality in Pi SMM Core.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf

index d0bc65b5644e35b18c1793ca31e83910f2659ec8..0d57b7bed5fdf30d11fcef05bd4b52377f1633ee 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM Core Main Entry Point\r
 \r
-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2019, 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
@@ -77,6 +77,12 @@ BOOLEAN  mInLegacyBoot = FALSE;
 //\r
 BOOLEAN  mDuringS3Resume = FALSE;\r
 \r
+//\r
+// Flag to determine if platform enabled S3.\r
+// Get the value from PcdAcpiS3Enable.\r
+//\r
+BOOLEAN  mAcpiS3Enable = FALSE;\r
+\r
 //\r
 // Table of SMI Handlers that are registered by the SMM Core when it is initialized\r
 //\r
@@ -87,6 +93,13 @@ SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {
   { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,      NULL, FALSE },\r
   { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,           NULL, FALSE },\r
   { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,         NULL, TRUE },\r
+  { NULL,                       NULL,                                NULL, FALSE }\r
+};\r
+\r
+//\r
+// Table of SMI Handlers that are registered by the SMM Core when it is initialized\r
+//\r
+SMM_CORE_SMI_HANDLERS  mSmmCoreS3SmiHandlers[] = {\r
   { SmmS3SmmInitDoneHandler,    &gEdkiiS3SmmInitDoneGuid,            NULL, FALSE },\r
   { SmmEndOfS3ResumeHandler,    &gEdkiiEndOfS3ResumeGuid,            NULL, FALSE },\r
   { NULL,                       NULL,                                NULL, FALSE }\r
@@ -445,28 +458,30 @@ SmmEndOfDxeHandler (
              NULL\r
              );\r
 \r
-  //\r
-  // Locate SmmSxDispatch2 protocol.\r
-  //\r
-  Status = SmmLocateProtocol (\r
-             &gEfiSmmSxDispatch2ProtocolGuid,\r
-             NULL,\r
-             (VOID **)&SxDispatch\r
-             );\r
-  if (!EFI_ERROR (Status) && (SxDispatch != NULL)) {\r
+  if (mAcpiS3Enable) {\r
     //\r
-    // Register a S3 entry callback function to\r
-    // determine if it will be during S3 resume.\r
+    // Locate SmmSxDispatch2 protocol.\r
     //\r
-    EntryRegisterContext.Type  = SxS3;\r
-    EntryRegisterContext.Phase = SxEntry;\r
-    Status = SxDispatch->Register (\r
-                           SxDispatch,\r
-                           SmmS3EntryCallBack,\r
-                           &EntryRegisterContext,\r
-                           &S3EntryHandle\r
-                           );\r
-    ASSERT_EFI_ERROR (Status);\r
+    Status = SmmLocateProtocol (\r
+               &gEfiSmmSxDispatch2ProtocolGuid,\r
+               NULL,\r
+               (VOID **)&SxDispatch\r
+               );\r
+    if (!EFI_ERROR (Status) && (SxDispatch != NULL)) {\r
+      //\r
+      // Register a S3 entry callback function to\r
+      // determine if it will be during S3 resume.\r
+      //\r
+      EntryRegisterContext.Type  = SxS3;\r
+      EntryRegisterContext.Phase = SxEntry;\r
+      Status = SxDispatch->Register (\r
+                             SxDispatch,\r
+                             SmmS3EntryCallBack,\r
+                             &EntryRegisterContext,\r
+                             &S3EntryHandle\r
+                             );\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -883,6 +898,21 @@ SmmMain (
     ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
+  mAcpiS3Enable = PcdGetBool (PcdAcpiS3Enable);\r
+  if (mAcpiS3Enable) {\r
+    //\r
+    // Register all S3 related SMI Handlers required by the SMM Core\r
+    //\r
+    for (Index = 0; mSmmCoreS3SmiHandlers[Index].HandlerType != NULL; Index++) {\r
+      Status = SmiHandlerRegister (\r
+                 mSmmCoreS3SmiHandlers[Index].Handler,\r
+                 mSmmCoreS3SmiHandlers[Index].HandlerType,\r
+                 &mSmmCoreS3SmiHandlers[Index].DispatchHandle\r
+                 );\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  }\r
+\r
   RegisterSmramProfileHandler ();\r
   SmramProfileInstallProtocol ();\r
 \r
index f3ece221216c9aa71a25665d0e73d4bc39b8b6b7..62d39fef2387f757cbd6fdd04a835d5a26d66ec7 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This module provide an SMM CIS compliant implementation of SMM Core.\r
 #\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2019, 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
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPageType                   ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType                   ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask               ## CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                        ## CONSUMES\r
 \r
 [Guids]\r
   gAprioriGuid                                  ## SOMETIMES_CONSUMES   ## File\r