svn commit: r347195 - in head/stand/efi: include libefi

Warner Losh imp at FreeBSD.org
Mon May 6 18:39:29 UTC 2019


Author: imp
Date: Mon May  6 18:39:27 2019
New Revision: 347195
URL: https://svnweb.freebsd.org/changeset/base/347195

Log:
  Abstract out efi_devpath_to_handle to search for a handle that matches
  the desired devpath.

Modified:
  head/stand/efi/include/efilib.h
  head/stand/efi/libefi/devpath.c
  head/stand/efi/libefi/efipart.c

Modified: head/stand/efi/include/efilib.h
==============================================================================
--- head/stand/efi/include/efilib.h	Mon May  6 18:39:22 2019	(r347194)
+++ head/stand/efi/include/efilib.h	Mon May  6 18:39:27 2019	(r347195)
@@ -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);

Modified: head/stand/efi/libefi/devpath.c
==============================================================================
--- head/stand/efi/libefi/devpath.c	Mon May  6 18:39:22 2019	(r347194)
+++ head/stand/efi/libefi/devpath.c	Mon May  6 18:39:27 2019	(r347195)
@@ -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);
+}

Modified: head/stand/efi/libefi/efipart.c
==============================================================================
--- head/stand/efi/libefi/efipart.c	Mon May  6 18:39:22 2019	(r347194)
+++ head/stand/efi/libefi/efipart.c	Mon May  6 18:39:27 2019	(r347195)
@@ -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


More information about the svn-src-head mailing list