Abstract out efi_devpath_to_handle to search for a handle that matches
the desired devpath.
This commit is contained in:
parent
44c35a8446
commit
f7192df893
@ -95,6 +95,7 @@ UINTN efi_devpath_length(EFI_DEVICE_PATH *);
|
||||
EFI_DEVICE_PATH *efi_name_to_devpath(const char *path);
|
||||
EFI_DEVICE_PATH *efi_name_to_devpath16(CHAR16 *path);
|
||||
void efi_devpath_free(EFI_DEVICE_PATH *dp);
|
||||
EFI_HANDLE efi_devpath_to_handle(EFI_DEVICE_PATH *path, EFI_HANDLE *handles, unsigned nhandles);
|
||||
|
||||
int efi_status_to_errno(EFI_STATUS);
|
||||
EFI_STATUS errno_to_efi_status(int errno);
|
||||
|
@ -269,3 +269,25 @@ efi_devpath_length(EFI_DEVICE_PATH *path)
|
||||
path = NextDevicePathNode(path);
|
||||
return ((UINTN)path - (UINTN)start) + DevicePathNodeLength(path);
|
||||
}
|
||||
|
||||
EFI_HANDLE
|
||||
efi_devpath_to_handle(EFI_DEVICE_PATH *path, EFI_HANDLE *handles, unsigned nhandles)
|
||||
{
|
||||
unsigned i;
|
||||
EFI_DEVICE_PATH *media, *devpath;
|
||||
EFI_HANDLE h;
|
||||
|
||||
media = efi_devpath_to_media_path(path);
|
||||
if (media == NULL)
|
||||
return (NULL);
|
||||
for (i = 0; i < nhandles; i++) {
|
||||
h = handles[i];
|
||||
devpath = efi_lookup_devpath(h);
|
||||
if (devpath == NULL)
|
||||
continue;
|
||||
if (!efi_devpath_match_node(media, efi_devpath_to_media_path(devpath)))
|
||||
continue;
|
||||
return (h);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -140,23 +140,12 @@ efiblk_get_pdinfo(struct devdesc *dev)
|
||||
pdinfo_t *
|
||||
efiblk_get_pdinfo_by_device_path(EFI_DEVICE_PATH *path)
|
||||
{
|
||||
unsigned i;
|
||||
EFI_DEVICE_PATH *media, *devpath;
|
||||
EFI_HANDLE h;
|
||||
|
||||
media = efi_devpath_to_media_path(path);
|
||||
if (media == NULL)
|
||||
h = efi_devpath_to_handle(path, efipart_handles, efipart_nhandles);
|
||||
if (h == NULL)
|
||||
return (NULL);
|
||||
for (i = 0; i < efipart_nhandles; i++) {
|
||||
h = efipart_handles[i];
|
||||
devpath = efi_lookup_devpath(h);
|
||||
if (devpath == NULL)
|
||||
continue;
|
||||
if (!efi_devpath_match_node(media, efi_devpath_to_media_path(devpath)))
|
||||
continue;
|
||||
return (efiblk_get_pdinfo_by_handle(h));
|
||||
}
|
||||
return (NULL);
|
||||
return (efiblk_get_pdinfo_by_handle(h));
|
||||
}
|
||||
|
||||
static bool
|
||||
|
Loading…
Reference in New Issue
Block a user