]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
MdeModulePkg: Change use of EFI_D_* to DEBUG_*
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmMisc.c
index fc8775dfa419c774b4c57dca1eef715e32134be6..6e7af3e3d910d12cec4482b26c41dd0ceb71a1e6 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -208,9 +208,9 @@ BmSetMemoryTypeInformationVariable (
   //\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
@@ -253,7 +253,7 @@ BmSetMemoryTypeInformationVariable (
       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
@@ -276,14 +276,14 @@ BmSetMemoryTypeInformationVariable (
       // 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
@@ -385,7 +385,7 @@ BmPrintDp (
   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
@@ -439,8 +439,6 @@ EfiBootManagerDispatchDeferredImages (
   UINTN                              ImageSize;\r
   BOOLEAN                            BootOption;\r
   EFI_HANDLE                         ImageHandle;\r
-  UINTN                              ExitDataSize;\r
-  CHAR16                             *ExitData;\r
   UINTN                              ImageCount;\r
   UINTN                              LoadCount;\r
 \r
@@ -495,17 +493,24 @@ EfiBootManagerDispatchDeferredImages (
         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