/** @file\r
Misc library functions.\r
\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
//\r
// Use a heuristic to adjust the Memory Type Information for the next boot\r
//\r
- DEBUG ((EFI_D_INFO, "Memory Previous Current Next \n"));\r
- DEBUG ((EFI_D_INFO, " Type Pages Pages Pages \n"));\r
- DEBUG ((EFI_D_INFO, "====== ======== ======== ========\n"));\r
+ DEBUG ((DEBUG_INFO, "Memory Previous Current Next \n"));\r
+ DEBUG ((DEBUG_INFO, " Type Pages Pages Pages \n"));\r
+ DEBUG ((DEBUG_INFO, "====== ======== ======== ========\n"));\r
\r
for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {\r
\r
MemoryTypeInformationModified = TRUE;\r
}\r
\r
- DEBUG ((EFI_D_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));\r
+ DEBUG ((DEBUG_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));\r
}\r
\r
//\r
// entry/resume cycle will not fail.\r
//\r
if (MemoryTypeInformationModified) {\r
- DEBUG ((EFI_D_INFO, "Memory Type Information settings change.\n"));\r
+ DEBUG ((DEBUG_INFO, "Memory Type Information settings change.\n"));\r
if (Boot && PcdGetBool (PcdResetOnMemoryTypeInformationChange)) {\r
- DEBUG ((EFI_D_INFO, "...Warm Reset!!!\n"));\r
+ DEBUG ((DEBUG_INFO, "...Warm Reset!!!\n"));\r
gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
}\r
}\r
} else {\r
- DEBUG ((EFI_D_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));\r
+ DEBUG ((DEBUG_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));\r
}\r
}\r
FreePool (PreviousMemoryTypeInformation);\r
CHAR16 *Str;\r
\r
Str = ConvertDevicePathToText (DevicePath, FALSE, FALSE);\r
- DEBUG ((EFI_D_INFO, "%s", Str));\r
+ DEBUG ((DEBUG_INFO, "%s", Str));\r
if (Str != NULL) {\r
FreePool (Str);\r
}\r
UINTN ImageSize;\r
BOOLEAN BootOption;\r
EFI_HANDLE ImageHandle;\r
- UINTN ExitDataSize;\r
- CHAR16 *ExitData;\r
UINTN ImageCount;\r
UINTN LoadCount;\r
\r
0,\r
&ImageHandle\r
);\r
- if (!EFI_ERROR (Status)) {\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created\r
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.\r
+ // If the caller doesn't have the option to defer the execution of an image, we should\r
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.\r
+ //\r
+ if (Status == EFI_SECURITY_VIOLATION) {\r
+ gBS->UnloadImage (ImageHandle);\r
+ }\r
+ } else {\r
LoadCount++;\r
//\r
// Before calling the image, enable the Watchdog Timer for\r
// a 5 Minute period\r
//\r
gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
- Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);\r
- if (ExitData != NULL) {\r
- FreePool (ExitData);\r
- }\r
+ gBS->StartImage (ImageHandle, NULL, NULL);\r
\r
//\r
// Clear the Watchdog Timer after the image returns.\r