]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Image/Image.c
MdeModulePkg/Core/Dxe: Remove extra connects for UEFI Applications
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Image / Image.c
index 93720c85cb2a7332bc7640c53dec5476b107dd2f..c49ddfcc81d16cae42ff0f315dfe8fc405c8d6bf 100644 (file)
@@ -788,6 +788,8 @@ Done:
 \r
   if (DstBufAlocated) {\r
     CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);\r
+    Image->ImageContext.ImageAddress = 0;\r
+    Image->ImageBasePage = 0;\r
   }\r
 \r
   if (Image->ImageContext.FixupData != NULL) {\r
@@ -1647,6 +1649,12 @@ CoreStartImage (
     //\r
     PERF_START (NULL, "StartImage:", NULL, Tick);\r
     PERF_END (NULL, "StartImage:", NULL, 0);\r
+\r
+    //\r
+    // Pop the current start image context\r
+    //\r
+    mCurrentImage = LastImage;\r
+\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
   Image->JumpContext = ALIGN_POINTER (Image->JumpBuffer, BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT);\r
@@ -1695,9 +1703,17 @@ CoreStartImage (
   mCurrentImage = LastImage;\r
 \r
   //\r
-  // Go connect any handles that were created or modified while the image executed.\r
+  // UEFI Specification - StartImage() - EFI 1.10 Extension\r
+  // To maintain compatibility with UEFI drivers that are written to the EFI\r
+  // 1.02 Specification, StartImage() must monitor the handle database before\r
+  // and after each image is started. If any handles are created or modified\r
+  // when an image is started, then EFI_BOOT_SERVICES.ConnectController() must\r
+  // be called with the Recursive parameter set to TRUE for each of the newly\r
+  // created or modified handles before StartImage() returns.\r
   //\r
-  CoreConnectHandlesByKey (HandleDatabaseKey);\r
+  if (Image->Type != EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {\r
+    CoreConnectHandlesByKey (HandleDatabaseKey);\r
+  }\r
 \r
   //\r
   // Handle the image's returned ExitData\r