]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Update DxeCore to handle LoadFile DevicePath
authorLiming Gao <liming.gao@intel.com>
Thu, 2 Jul 2015 04:28:21 +0000 (04:28 +0000)
committerlgao4 <lgao4@Edk2>
Thu, 2 Jul 2015 04:28:21 +0000 (04:28 +0000)
UEFI Spec HTTP Boot Device Path, after retrieving the boot resource
information, the BootURI device path node will be updated to include
the BootURI information. It means the device path on the child handle
will be updated after the LoadFile() service is called.

To handle this case, DxeCore LoadImage() service is updated as the below:
1) Get Device handle based on Device Path
2) Call LoadFile() service (GetFileBufferByFilePath() API) to get Load File Buffer.
3) Retrieve DevicePath from Device handle

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17799 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Image/Image.c

index ea6b2c6a4268e4e8c40a03b398ea1eadeb778e74..5355940b58d775002c5604bb05c55d81fc2735b4 100644 (file)
@@ -1055,8 +1055,11 @@ CoreLoadImageCommon (
   UINT32                     AuthenticationStatus;\r
   EFI_DEVICE_PATH_PROTOCOL   *OriginalFilePath;\r
   EFI_DEVICE_PATH_PROTOCOL   *HandleFilePath;\r
   UINT32                     AuthenticationStatus;\r
   EFI_DEVICE_PATH_PROTOCOL   *OriginalFilePath;\r
   EFI_DEVICE_PATH_PROTOCOL   *HandleFilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL   *InputFilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL   *Node;\r
   UINTN                      FilePathSize;\r
   BOOLEAN                    ImageIsFromFv;\r
   UINTN                      FilePathSize;\r
   BOOLEAN                    ImageIsFromFv;\r
+  BOOLEAN                    ImageIsFromLoadFile;\r
 \r
   SecurityStatus = EFI_SUCCESS;\r
 \r
 \r
   SecurityStatus = EFI_SUCCESS;\r
 \r
@@ -1079,11 +1082,13 @@ CoreLoadImageCommon (
   ZeroMem (&FHand, sizeof (IMAGE_FILE_HANDLE));\r
   FHand.Signature  = IMAGE_FILE_HANDLE_SIGNATURE;\r
   OriginalFilePath = FilePath;\r
   ZeroMem (&FHand, sizeof (IMAGE_FILE_HANDLE));\r
   FHand.Signature  = IMAGE_FILE_HANDLE_SIGNATURE;\r
   OriginalFilePath = FilePath;\r
+  InputFilePath    = FilePath;\r
   HandleFilePath   = FilePath;\r
   DeviceHandle     = NULL;\r
   Status           = EFI_SUCCESS;\r
   AuthenticationStatus = 0;\r
   HandleFilePath   = FilePath;\r
   DeviceHandle     = NULL;\r
   Status           = EFI_SUCCESS;\r
   AuthenticationStatus = 0;\r
-  ImageIsFromFv    = FALSE;\r
+  ImageIsFromFv        = FALSE;\r
+  ImageIsFromLoadFile  = FALSE;\r
 \r
   //\r
   // If the caller passed a copy of the file, then just use it\r
 \r
   //\r
   // If the caller passed a copy of the file, then just use it\r
@@ -1104,6 +1109,33 @@ CoreLoadImageCommon (
     if (FilePath == NULL) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
     if (FilePath == NULL) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
+\r
+    //\r
+    // Try to get the image device handle by checking the match protocol.\r
+    //\r
+    Node   = NULL;\r
+    Status = CoreLocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &HandleFilePath, &DeviceHandle);\r
+    if (!EFI_ERROR (Status)) {\r
+      ImageIsFromFv = TRUE;\r
+    } else {\r
+      HandleFilePath = FilePath;\r
+      Status = CoreLocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &HandleFilePath, &DeviceHandle);\r
+      if (EFI_ERROR (Status)) {\r
+        if (!BootPolicy) {\r
+          HandleFilePath = FilePath;\r
+          Status = CoreLocateDevicePath (&gEfiLoadFile2ProtocolGuid, &HandleFilePath, &DeviceHandle);\r
+        }\r
+        if (EFI_ERROR (Status)) {\r
+          HandleFilePath = FilePath;\r
+          Status = CoreLocateDevicePath (&gEfiLoadFileProtocolGuid, &HandleFilePath, &DeviceHandle);\r
+          if (!EFI_ERROR (Status)) {\r
+            ImageIsFromLoadFile = TRUE;\r
+            Node = HandleFilePath;\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
     //\r
     // Get the source file buffer by its device path.\r
     //\r
     //\r
     // Get the source file buffer by its device path.\r
     //\r
@@ -1116,26 +1148,12 @@ CoreLoadImageCommon (
     if (FHand.Source == NULL) {\r
       Status = EFI_NOT_FOUND;\r
     } else {\r
     if (FHand.Source == NULL) {\r
       Status = EFI_NOT_FOUND;\r
     } else {\r
-      //\r
-      // Try to get the image device handle by checking the match protocol.\r
-      //\r
       FHand.FreeBuffer = TRUE;\r
       FHand.FreeBuffer = TRUE;\r
-      Status = CoreLocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &HandleFilePath, &DeviceHandle);\r
-      if (!EFI_ERROR (Status)) {\r
-        ImageIsFromFv = TRUE;\r
-      } else {\r
-        HandleFilePath = FilePath;\r
-        Status = CoreLocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &HandleFilePath, &DeviceHandle);\r
-        if (EFI_ERROR (Status)) {\r
-          if (!BootPolicy) {\r
-            HandleFilePath = FilePath;\r
-            Status = CoreLocateDevicePath (&gEfiLoadFile2ProtocolGuid, &HandleFilePath, &DeviceHandle);\r
-          }\r
-          if (EFI_ERROR (Status)) {\r
-            HandleFilePath = FilePath;\r
-            Status = CoreLocateDevicePath (&gEfiLoadFileProtocolGuid, &HandleFilePath, &DeviceHandle);\r
-          }\r
-        }\r
+      if (ImageIsFromLoadFile) {\r
+        //\r
+        // LoadFile () may cause the device path of the Handle be updated.\r
+        //\r
+        OriginalFilePath = AppendDevicePath (DevicePathFromHandle (DeviceHandle), Node);\r
       }\r
     }\r
   }\r
       }\r
     }\r
   }\r
@@ -1337,6 +1355,9 @@ Done:
   if (FHand.FreeBuffer) {\r
     CoreFreePool (FHand.Source);\r
   }\r
   if (FHand.FreeBuffer) {\r
     CoreFreePool (FHand.Source);\r
   }\r
+  if (OriginalFilePath != InputFilePath) {\r
+    CoreFreePool (OriginalFilePath);\r
+  }\r
 \r
   //\r
   // There was an error.  If there's an Image structure, free it\r
 \r
   //\r
   // There was an error.  If there's an Image structure, free it\r