From e06f8144fb9569dce10ef1279c62a5e3b5216c0d Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 26 May 2016 22:13:40 +0000 Subject: [PATCH] Use routines from the recently added devpath.c. These efipart layer did several devpath related operations inline. This just switches it over to using shared code for working with device paths. Sponsored by: Cisco Systems --- sys/boot/efi/libefi/efipart.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/sys/boot/efi/libefi/efipart.c b/sys/boot/efi/libefi/efipart.c index e8691c51a586..11b7a1a3c604 100644 --- a/sys/boot/efi/libefi/efipart.c +++ b/sys/boot/efi/libefi/efipart.c @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL; -static EFI_GUID devpath_guid = DEVICE_PATH_PROTOCOL; static int efipart_init(void); static int efipart_strategy(void *, int, daddr_t, size_t, size_t, char *, @@ -85,7 +84,6 @@ efipart_init(void) UINTN sz; u_int n, nin, nout; int err; - size_t devpathlen; sz = 0; hin = NULL; @@ -112,20 +110,11 @@ efipart_init(void) return (ENOMEM); for (n = 0; n < nin; n++) { - status = BS->HandleProtocol(hin[n], &devpath_guid, - (void **)&devpath); - if (EFI_ERROR(status)) { + devpath = efi_lookup_devpath(hin[n]); + if (devpath == NULL) { continue; } - node = devpath; - devpathlen = DevicePathNodeLength(node); - while (!IsDevicePathEnd(NextDevicePathNode(node))) { - node = NextDevicePathNode(node); - devpathlen += DevicePathNodeLength(node); - } - devpathlen += DevicePathNodeLength(NextDevicePathNode(node)); - status = BS->HandleProtocol(hin[n], &blkio_guid, (void**)&blkio); if (EFI_ERROR(status)) @@ -140,14 +129,10 @@ efipart_init(void) * we try to find the parent device and add that instead as * that will be the CD filesystem. */ + node = efi_devpath_last_node(devpath); if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_CDROM_DP) { - devpathcpy = malloc(devpathlen); - memcpy(devpathcpy, devpath, devpathlen); - node = devpathcpy; - while (!IsDevicePathEnd(NextDevicePathNode(node))) - node = NextDevicePathNode(node); - SetDevicePathEndNode(node); + devpathcpy = efi_devpath_trim(devpath); tmpdevpath = devpathcpy; status = BS->LocateDevicePath(&blkio_guid, &tmpdevpath, &handle);