]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Enable/Disable S3BootScript dynamically.
authorChasel Chiu <chasel.chiu@intel.com>
Wed, 4 Sep 2019 00:43:22 +0000 (08:43 +0800)
committerChasel Chiu <chasel.chiu@intel.com>
Tue, 1 Oct 2019 00:14:45 +0000 (08:14 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2212

In binary model the same binary may have to support both
S3 enabled and disabled scenarios, however not all DXE
drivers linking PiDxeS3BootScriptLib can return error to
invoke library DESTRUCTOR for releasing resource.

To support this usage model below PCD is used to skip
S3BootScript functions when PCD set to FALSE:
  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable

Test: Verified on internal platform and S3BootScript
      functions can be skipped by PCD during boot time.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf

index c116727531d27ce882ec47f260608fb37fd050f2..9106e7d0f9f5dd864ad428fcedbdefac794ecfb6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Save the S3 data to S3 boot script.\r
 \r
-  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -124,6 +124,7 @@ VOID                             *mRegistrationSmmReadyToLock = NULL;
 BOOLEAN                          mS3BootScriptTableAllocated = FALSE;\r
 BOOLEAN                          mS3BootScriptTableSmmAllocated = FALSE;\r
 EFI_SMM_SYSTEM_TABLE2            *mBootScriptSmst = NULL;\r
+BOOLEAN                          mAcpiS3Enable = TRUE;\r
 \r
 /**\r
   This is an internal function to add a terminate node the entry, recalculate the table\r
@@ -436,6 +437,12 @@ S3BootScriptLibInitialize (
   BOOLEAN                        InSmm;\r
   EFI_PHYSICAL_ADDRESS           Buffer;\r
 \r
+  if (!PcdGetBool (PcdAcpiS3Enable)) {\r
+    mAcpiS3Enable = FALSE;\r
+    DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3 disabled.\n", gEfiCallerBaseName));\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
   S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr);\r
   //\r
   // The Boot script private data is not be initialized. create it\r
@@ -562,6 +569,10 @@ S3BootScriptLibDeinitialize (
 {\r
   EFI_STATUS                Status;\r
 \r
+  if (!mAcpiS3Enable) {\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
   DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBaseName));\r
 \r
   if (mEventDxeSmmReadyToLock != NULL) {\r
@@ -810,6 +821,10 @@ S3BootScriptGetEntryAddAddress (
 {\r
   UINT8*                         NewEntryPtr;\r
 \r
+  if (!mAcpiS3Enable) {\r
+    return NULL;\r
+  }\r
+\r
   if (mS3BootScriptTablePtr->SmmLocked) {\r
     //\r
     // We need check InSmm, because after SmmReadyToLock, only SMM driver is allowed to write boot script.\r
index 517ea69568511796a39f0df784493bd4a4324e79..2b894c99da554281a45adb4a9992ea9fa662d4f0 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # DXE S3 boot script Library.\r
 #\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -65,4 +65,4 @@
   ## SOMETIMES_PRODUCES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber   ## CONSUMES\r
-\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                                ## CONSUMES\r