summaryrefslogtreecommitdiff
path: root/sys/arch/armv7
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2017-07-31 14:06:30 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2017-07-31 14:06:30 +0000
commit037c896b4ab4dc7c73b3394eb8208ae35baa123f (patch)
treecbdd65d59aec245a65bc031e9c0822e9396e0f18 /sys/arch/armv7
parent36e02f255607caeea61d91ebaa9ddac55595a107 (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@
Diffstat (limited to 'sys/arch/armv7')
-rw-r--r--sys/arch/armv7/stand/efiboot/conf.c4
-rw-r--r--sys/arch/armv7/stand/efiboot/efiboot.c17
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);