diff options
author | 2017-07-31 14:06:29 +0000 | |
---|---|---|
committer | 2017-07-31 14:06:29 +0000 | |
commit | c94e725747c6790376a2c129efd3720499007be3 (patch) | |
tree | e8da09e0e50b0295f573ebb22b7b7d47096a4336 | |
parent | Back out previous commit but handle the case where the device path consists (diff) | |
download | wireguard-openbsd-c94e725747c6790376a2c129efd3720499007be3.tar.xz wireguard-openbsd-c94e725747c6790376a2c129efd3720499007be3.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/arm64/stand/efiboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/arm64/stand/efiboot/efiboot.c | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/sys/arch/arm64/stand/efiboot/conf.c b/sys/arch/arm64/stand/efiboot/conf.c index 4f9e6028a52..7351350e548 100644 --- a/sys/arch/arm64/stand/efiboot/conf.c +++ b/sys/arch/arm64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.5 2017/07/29 19:51:50 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.6 2017/07/31 14:06:29 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -35,7 +35,7 @@ #include "efiboot.h" #include "efidev.h" -const char version[] = "0.5"; +const char version[] = "0.6"; int debug = 0; struct fs_ops file_system[] = { diff --git a/sys/arch/arm64/stand/efiboot/efiboot.c b/sys/arch/arm64/stand/efiboot/efiboot.c index faf9f382a4f..defb4e3ab4f 100644 --- a/sys/arch/arm64/stand/efiboot/efiboot.c +++ b/sys/arch/arm64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.9 2017/07/29 19:51:50 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.10 2017/07/31 14:06:29 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -192,6 +192,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); @@ -217,6 +226,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) { @@ -224,7 +237,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); |