/** @file\r
Save the S3 data to S3 boot script.\r
\r
- Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 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\r
- of the BSD License which accompanies this distribution. The\r
- full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
#include "InternalBootScriptLib.h"\r
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
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
{\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
// Here we do not count the reserved memory for runtime script table.\r
PageNumber = (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));\r
TableLength = mS3BootScriptTablePtr->TableLength;\r
- if ((UINTN) EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (UINTN) (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {\r
+ if (EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {\r
//\r
// The buffer is too small to hold the table, Reallocate the buffer\r
//\r
//\r
// Check if the memory range reserved for S3 Boot Script table is large enough to hold the node.\r
//\r
- if ((UINTN) (mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= (UINTN) EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {\r
+ if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {\r
NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;\r
mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;\r
//\r
{\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
IN VOID *BitMask,\r
IN VOID *BitValue,\r
IN UINTN Duration,\r
- IN UINTN LoopTimes\r
+ IN UINT64 LoopTimes\r
)\r
{\r
UINT8 Length;\r
// calculate the Position offset\r
//\r
if (Position != NULL) {\r
- PositionOffset = (UINTN) ((UINT8 *)Position - S3TableBase);\r
+ PositionOffset = (UINTN)Position - (UINTN)S3TableBase;\r
\r
//\r
// If the BeforeOrAfter is FALSE, that means to insert the node right after the node.\r