diff options
author | 2017-07-31 14:05:57 +0000 | |
---|---|---|
committer | 2017-07-31 14:05:57 +0000 | |
commit | a6480b793380926e1522f187cb04754f19a519ff (patch) | |
tree | 73e0d08633236eb60d86f4ea789d9c530d316d0d | |
parent | Back out previous commit but handle the case where the device path consists (diff) | |
download | wireguard-openbsd-a6480b793380926e1522f187cb04754f19a519ff.tar.xz wireguard-openbsd-a6480b793380926e1522f187cb04754f19a519ff.zip |
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/armv7/stand/efiboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/armv7/stand/efiboot/efiboot.c | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/sys/arch/armv7/stand/efiboot/conf.c b/sys/arch/armv7/stand/efiboot/conf.c index 293f6dc43c7..084ea3f9fb3 100644 --- a/sys/arch/armv7/stand/efiboot/conf.c +++ b/sys/arch/armv7/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.8 2017/07/29 19:38:01 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.9 2017/07/31 14:05:57 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -35,7 +35,7 @@ #include "efiboot.h" #include "efidev.h" -const char version[] = "0.7"; +const char version[] = "0.8"; int debug = 0; struct fs_ops file_system[] = { diff --git a/sys/arch/armv7/stand/efiboot/efiboot.c b/sys/arch/armv7/stand/efiboot/efiboot.c index c0647d2c82d..621c78a0a62 100644 --- a/sys/arch/armv7/stand/efiboot/efiboot.c +++ b/sys/arch/armv7/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.16 2017/07/29 19:38:01 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.17 2017/07/31 14:05:57 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -186,6 +186,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); @@ -211,6 +220,10 @@ efi_diskprobe(void) 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) { @@ -218,7 +231,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); |