/** @file\r
Implementation for EFI_HII_DATABASE_PROTOCOL.\r
\r
-Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
if (!EFI_ERROR (Status)){\r
ConfigSize = StrSize(ConfigAltResp);\r
if (ConfigSize > gConfigRespSize){\r
- gConfigRespSize = ConfigSize;\r
+ //\r
+ // Do 25% overallocation to minimize the number of memory allocations after ReadyToBoot.\r
+ // Since lots of allocation after ReadyToBoot may change memory map and cause S4 resume issue.\r
+ //\r
+ gConfigRespSize = ConfigSize + (ConfigSize >> 2);\r
if (gRTConfigRespBuffer != NULL){\r
FreePool(gRTConfigRespBuffer);\r
+ DEBUG ((DEBUG_WARN, "[HiiDatabase]: Memory allocation is required after ReadyToBoot, which may change memory map and cause S4 resume issue.\n"));\r
}\r
- gRTConfigRespBuffer = (EFI_STRING)AllocateRuntimeZeroPool(ConfigSize);\r
+ gRTConfigRespBuffer = (EFI_STRING) AllocateRuntimeZeroPool (gConfigRespSize);\r
if (gRTConfigRespBuffer == NULL){\r
FreePool(ConfigAltResp);\r
- DEBUG ((DEBUG_ERROR, "Not enough memory resource to get the ConfigResp string.\n"));\r
+ DEBUG ((DEBUG_ERROR, "[HiiDatabase]: No enough memory resource to store the ConfigResp string.\n"));\r
return EFI_OUT_OF_RESOURCES;\r
}\r
} else {\r
ASSERT(Status == EFI_BUFFER_TOO_SMALL);\r
\r
if(DatabaseInfoSize > gDatabaseInfoSize ) {\r
- gDatabaseInfoSize = DatabaseInfoSize;\r
+ //\r
+ // Do 25% overallocation to minimize the number of memory allocations after ReadyToBoot.\r
+ // Since lots of allocation after ReadyToBoot may change memory map and cause S4 resume issue.\r
+ //\r
+ gDatabaseInfoSize = DatabaseInfoSize + (DatabaseInfoSize >> 2);\r
if (gRTDatabaseInfoBuffer != NULL){\r
FreePool(gRTDatabaseInfoBuffer);\r
+ DEBUG ((DEBUG_WARN, "[HiiDatabase]: Memory allocation is required after ReadyToBoot, which may change memory map and cause S4 resume issue.\n"));\r
}\r
- gRTDatabaseInfoBuffer = AllocateRuntimeZeroPool(DatabaseInfoSize);\r
+ gRTDatabaseInfoBuffer = AllocateRuntimeZeroPool (gDatabaseInfoSize);\r
if (gRTDatabaseInfoBuffer == NULL){\r
- DEBUG ((DEBUG_ERROR, "Not enough memory resource to get the HiiDatabase info.\n"));\r
+ DEBUG ((DEBUG_ERROR, "[HiiDatabase]: No enough memory resource to store the HiiDatabase info.\n"));\r
return EFI_OUT_OF_RESOURCES;\r
}\r
} else {\r