aboutsummaryrefslogtreecommitdiff
path: root/stand/efi/boot1
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2019-05-06 18:38:46 +0000
committerWarner Losh <imp@FreeBSD.org>2019-05-06 18:38:46 +0000
commit4cf36aa1017f9e1ca75544f6e5393a80dd9c0bea (patch)
tree3b8c6dddcbe217178a994cc802901dd63a492fad /stand/efi/boot1
parent6b6e2954dd65ec08e73efb0f2e8bfb2278a07dc6 (diff)
downloadsrc-4cf36aa1017f9e1ca75544f6e5393a80dd9c0bea.tar.gz
src-4cf36aa1017f9e1ca75544f6e5393a80dd9c0bea.zip
Reach over and pull in devpath.c from libefi
This allows us to remove three nearly identical functions because the differences don't matter, and the size difference is trivial.
Notes
Notes: svn path=/head/; revision=347193
Diffstat (limited to 'stand/efi/boot1')
-rw-r--r--stand/efi/boot1/Makefile3
-rw-r--r--stand/efi/boot1/boot1.c64
2 files changed, 4 insertions, 63 deletions
diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile
index 7b945461e8d3..eb17b41eaa3f 100644
--- a/stand/efi/boot1/Makefile
+++ b/stand/efi/boot1/Makefile
@@ -25,7 +25,7 @@ CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
CWARNFLAGS.zfs_module.c += -Wno-unused-function
# architecture-specific loader code
-SRCS+= boot1.c self_reloc.c start.S ufs_module.c
+SRCS+= boot1.c self_reloc.c start.S ufs_module.c devpath.c
.if ${MK_LOADER_ZFS} != "no"
SRCS+= zfs_module.c
CFLAGS.zfs_module.c+= -I${ZFSSRC}
@@ -50,6 +50,7 @@ CFLAGS+= -DEFI_DEBUG
.PATH: ${EFISRC}/loader/arch/${MACHINE}
.PATH: ${EFISRC}/loader
.PATH: ${LDRSRC}
+.PATH: ${EFISRC}/libefi
CFLAGS+= -I${LDRSRC}
FILES= ${BOOT1}.efi ${BOOT1}.efifat
diff --git a/stand/efi/boot1/boot1.c b/stand/efi/boot1/boot1.c
index cc20cee468ff..5b3b1d6d18cf 100644
--- a/stand/efi/boot1/boot1.c
+++ b/stand/efi/boot1/boot1.c
@@ -79,66 +79,6 @@ Free(void *buf, const char *file __unused, int line __unused)
}
/*
- * nodes_match returns TRUE if the imgpath isn't NULL and the nodes match,
- * FALSE otherwise.
- */
-static BOOLEAN
-nodes_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath)
-{
- size_t len;
-
- if (imgpath == NULL || imgpath->Type != devpath->Type ||
- imgpath->SubType != devpath->SubType)
- return (FALSE);
-
- len = DevicePathNodeLength(imgpath);
- if (len != DevicePathNodeLength(devpath))
- return (FALSE);
-
- return (memcmp(imgpath, devpath, (size_t)len) == 0);
-}
-
-/*
- * device_paths_match returns TRUE if the imgpath isn't NULL and all nodes
- * in imgpath and devpath match up to their respective occurrences of a
- * media node, FALSE otherwise.
- */
-static BOOLEAN
-device_paths_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath)
-{
-
- if (imgpath == NULL)
- return (FALSE);
-
- while (!IsDevicePathEnd(imgpath) && !IsDevicePathEnd(devpath)) {
- if (IsDevicePathType(imgpath, MEDIA_DEVICE_PATH) &&
- IsDevicePathType(devpath, MEDIA_DEVICE_PATH))
- return (TRUE);
-
- if (!nodes_match(imgpath, devpath))
- return (FALSE);
-
- imgpath = NextDevicePathNode(imgpath);
- devpath = NextDevicePathNode(devpath);
- }
-
- return (FALSE);
-}
-
-/*
- * devpath_last returns the last non-path end node in devpath.
- */
-static EFI_DEVICE_PATH *
-devpath_last(EFI_DEVICE_PATH *devpath)
-{
-
- while (!IsDevicePathEnd(NextDevicePathNode(devpath)))
- devpath = NextDevicePathNode(devpath);
-
- return (devpath);
-}
-
-/*
* load_loader attempts to load the loader image data.
*
* It tries each module and its respective devices, identified by mod->probe,
@@ -225,7 +165,7 @@ try_boot(void)
buf = NULL;
}
- if ((status = BS->LoadImage(TRUE, IH, devpath_last(dev->devpath),
+ if ((status = BS->LoadImage(TRUE, IH, efi_devpath_last_node(dev->devpath),
loaderbuf, loadersize, &loaderhandle)) != EFI_SUCCESS) {
printf("Failed to load image provided by %s, size: %zu, (%lu)\n",
mod->name, loadersize, EFI_ERROR_CODE(status));
@@ -321,7 +261,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, BOOLEAN *preferred)
if (!blkio->Media->LogicalPartition)
return (EFI_UNSUPPORTED);
- *preferred = device_paths_match(imgpath, devpath);
+ *preferred = efi_devpath_match(imgpath, devpath);
/* Run through each module, see if it can load this partition */
for (i = 0; i < NUM_BOOT_MODULES; i++) {