return Status;\r
}\r
\r
-/**\r
- Connect a Device Path and return the handle of the driver that support this DevicePath\r
-\r
- @param DevicePath Device Path of the File to connect\r
- @param Handle Handle of the driver that support this DevicePath\r
- @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath\r
-\r
- @retval EFI_SUCCESS A driver that matches the Device Path has been found\r
- @retval EFI_NOT_FOUND No handles match the search.\r
- @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL\r
-\r
-**/\r
+STATIC
EFI_STATUS\r
-BdsConnectDevicePath (\r
- IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,\r
- OUT EFI_HANDLE *Handle,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath\r
+BdsConnectAndUpdateDevicePath (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT EFI_HANDLE *Handle,
+ OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath
)\r
{\r
EFI_DEVICE_PATH* Remaining;\r
EFI_DEVICE_PATH* NewDevicePath;\r
EFI_STATUS Status;\r
\r
- if ((DevicePath == NULL) || (Handle == NULL)) {\r
+ if ((DevicePath == NULL) || (*DevicePath == NULL) || (Handle == NULL)) {
return EFI_INVALID_PARAMETER;\r
}\r
\r
do {\r
- Remaining = DevicePath;\r
+ Remaining = *DevicePath;
// The LocateDevicePath() function locates all devices on DevicePath that support Protocol and returns\r
// the handle to the device that is closest to DevicePath. On output, the device path pointer is modified\r
// to point to the remaining part of the device path\r
if (!EFI_ERROR (Status)) {\r
// Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver\r
// Binding Protocol are connected (such as DiskIo and SimpleFileSystem)\r
- Remaining = DevicePath;\r
+ Remaining = *DevicePath;
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &Remaining, Handle);\r
if (!EFI_ERROR (Status)) {\r
Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);\r
//TODO: Should we just return success and leave the caller decide if it is the expected RemainingPath\r
Status = EFI_SUCCESS;\r
} else {\r
- Status = TryRemovableDevice (DevicePath, Handle, &NewDevicePath);\r
+ Status = TryRemovableDevice (*DevicePath, Handle, &NewDevicePath);
if (!EFI_ERROR (Status)) {\r
- return BdsConnectDevicePath (NewDevicePath, Handle, RemainingDevicePath);\r
+ Status = BdsConnectAndUpdateDevicePath (&NewDevicePath, Handle, RemainingDevicePath);
+ *DevicePath = NewDevicePath;
+ return Status;
}\r
}\r
\r
return Status;\r
}\r
\r
+/**
+ Connect a Device Path and return the handle of the driver that support this DevicePath
+
+ @param DevicePath Device Path of the File to connect
+ @param Handle Handle of the driver that support this DevicePath
+ @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath
+
+ @retval EFI_SUCCESS A driver that matches the Device Path has been found
+ @retval EFI_NOT_FOUND No handles match the search.
+ @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL
+
+**/\r
+EFI_STATUS
+BdsConnectDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
+ OUT EFI_HANDLE *Handle,
+ OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath
+ )
+{
+ return BdsConnectAndUpdateDevicePath (&DevicePath, Handle, RemainingDevicePath);
+}
+
BOOLEAN\r
BdsFileSystemSupport (\r
IN EFI_DEVICE_PATH *DevicePath,\r
};\r
\r
EFI_STATUS\r
-BdsLoadImage (\r
- IN EFI_DEVICE_PATH *DevicePath,\r
+BdsLoadImageAndUpdateDevicePath (
+ IN OUT EFI_DEVICE_PATH **DevicePath,
IN EFI_ALLOCATE_TYPE Type,\r
IN OUT EFI_PHYSICAL_ADDRESS* Image,\r
OUT UINTN *FileSize\r
EFI_DEVICE_PATH *RemainingDevicePath;\r
BDS_FILE_LOADER* FileLoader;\r
\r
- Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);\r
+ Status = BdsConnectAndUpdateDevicePath (DevicePath, &Handle, &RemainingDevicePath);
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
FileLoader = FileLoaders;\r
while (FileLoader->Support != NULL) {\r
- if (FileLoader->Support (DevicePath, Handle, RemainingDevicePath)) {\r
- return FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath, Type, Image, FileSize);\r
+ if (FileLoader->Support (*DevicePath, Handle, RemainingDevicePath)) {
+ return FileLoader->LoadImage (*DevicePath, Handle, RemainingDevicePath, Type, Image, FileSize);
}\r
FileLoader++;\r
}\r
return EFI_UNSUPPORTED;\r
}\r
\r
+EFI_STATUS\r
+BdsLoadImage (
+ IN EFI_DEVICE_PATH *DevicePath,
+ IN EFI_ALLOCATE_TYPE Type,
+ IN OUT EFI_PHYSICAL_ADDRESS* Image,
+ OUT UINTN *FileSize
+ )
+{
+ return BdsLoadImageAndUpdateDevicePath (&DevicePath, Type, Image, FileSize);
+}
+
/**\r
Start an EFI Application from a Device Path\r
\r
EFI_LOADED_IMAGE_PROTOCOL* LoadedImage;\r
\r
// Find the nearest supported file loader\r
- Status = BdsLoadImage (DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize);\r
+ Status = BdsLoadImageAndUpdateDevicePath (&DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize);
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r