diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-07-31 14:04:54 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-07-31 14:04:54 +0000 |
commit | 36e02f255607caeea61d91ebaa9ddac55595a107 (patch) | |
tree | 23ed27eff07392d92e72449b2c46e0b0b9bcaca5 | |
parent | 364d542d7197ac859946701018c0af8187797d67 (diff) |
Back out previous commit but handle the case where the device path consists
of a single MEDIA_DEVICE_PATH component specially to cater for U-Boot's
somewhat broken device path handling. Add comments to prevent confusion
in the future. Bump the version number once again.
ok brynet@
-rw-r--r-- | sys/arch/amd64/stand/efiboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/efiboot.c | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/sys/arch/amd64/stand/efiboot/conf.c b/sys/arch/amd64/stand/efiboot/conf.c index ba75269acc6..1c82abe5f48 100644 --- a/sys/arch/amd64/stand/efiboot/conf.c +++ b/sys/arch/amd64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.9 2017/07/29 19:52:29 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.10 2017/07/31 14:04:52 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -38,7 +38,7 @@ #include "efiboot.h" #include "efidev.h" -const char version[] = "3.34"; +const char version[] = "3.35"; #ifdef EFI_DEBUG int debug = 0; diff --git a/sys/arch/amd64/stand/efiboot/efiboot.c b/sys/arch/amd64/stand/efiboot/efiboot.c index 4114f9137b5..0ff0f53fc50 100644 --- a/sys/arch/amd64/stand/efiboot/efiboot.c +++ b/sys/arch/amd64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.21 2017/07/29 19:52:29 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.22 2017/07/31 14:04:53 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -185,6 +185,15 @@ efi_diskprobe(void) if (efi_bootdp != NULL) depth = efi_device_path_depth(efi_bootdp, MEDIA_DEVICE_PATH); + /* + * U-Boot incorrectly represents devices with a single + * MEDIA_DEVICE_PATH component. In that case include that + * component into the matching, otherwise we'll blindly select + * the first device. + */ + if (depth == 0) + depth = 1; + for (i = 0; i < sz / sizeof(EFI_HANDLE); i++) { status = EFI_CALL(BS->HandleProtocol, handles[i], &blkio_guid, (void **)&blkio); @@ -215,6 +224,10 @@ next: free(handles, sz); } +/* + * Determine the number of nodes up to, but not including, the first + * node of the specified type. + */ static int efi_device_path_depth(EFI_DEVICE_PATH *dp, int dptype) { @@ -222,7 +235,7 @@ efi_device_path_depth(EFI_DEVICE_PATH *dp, int dptype) for (i = 0; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp), i++) { if (DevicePathType(dp) == dptype) - return (i + 1); + return (i); } return (-1); |