+ //\r
+ // Try to find if there is the boot file in this DevicePath\r
+ //\r
+ NextDevicePath = NextDevicePathNode (ShortFormDevicePath);\r
+ if (!IsDevicePathEnd (NextDevicePath)) {\r
+ FullDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePath);\r
+ //\r
+ // Connect the full device path, so that Simple File System protocol\r
+ // could be installed for this USB device.\r
+ //\r
+ BdsLibConnectDevicePath (FullDevicePath);\r
+ Status = gBS->LoadImage (\r
+ TRUE,\r
+ gImageHandle,\r
+ FullDevicePath,\r
+ NULL,\r
+ 0,\r
+ &ImageHandle\r
+ );\r
+ FreePool (FullDevicePath);\r
+ } else {\r
+ FullDevicePath = UsbIoDevicePath;\r
+ Status = EFI_NOT_FOUND;\r
+ }\r
+\r
+ //\r
+ // If we didn't find an image directly, we need to try as if it is a removable device boot option\r
+ // and load the image according to the default boot behavior for removable device.\r
+ //\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // check if there is a bootable removable media could be found in this device path ,\r
+ // and get the bootable media handle\r
+ //\r
+ Handle = BdsLibGetBootableHandle(UsbIoDevicePath);\r
+ if (Handle == NULL) {\r
+ continue;\r
+ }\r
+ //\r
+ // Load the default boot file \EFI\BOOT\boot{machinename}.EFI from removable Media\r
+ // machinename is ia32, ia64, x64, ...\r
+ //\r
+ FullDevicePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
+ if (FullDevicePath != NULL) {\r
+ Status = gBS->LoadImage (\r
+ TRUE,\r
+ gImageHandle,\r
+ FullDevicePath,\r
+ NULL,\r
+ 0,\r
+ &ImageHandle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // The DevicePath failed, and it's not a valid\r
+ // removable media device.\r
+ //\r
+ continue;\r
+ }\r
+ } else {\r
+ continue;\r
+ }\r
+ }\r