On Fri, 12 May 2017 16:15:52 +0200 Michele Curti <michele.cu...@gmail.com> wrote: > On Fri, May 12, 2017 at 06:01:35PM +0900, YASUOKA Masahiko wrote: >> > And something like this? >> >> Yes. What we need to do is comparing the device path node before >> MEDIA_DEVICE_PATH type. So I rewrote it like >> >> media_idx = device_path_index(rootdp, MEDIA_DEVICE_PATH); >> for (...) >> if (device_path_ncmp(rootdp, dp, media_idx) == 0) >> bootdev = 1; >> >> ok? comment? >> > > The device order is correct, the laptop boots without problems,
Thank you for your test. > but executing "machine diskinfo" prints a source file now.. > > https://www.youtube.com/watch?v=EUao9Fq5Bww > > It seems gnu/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp It seems the problem which had been fixed previous is happening again. Does efidev.c have following $OpenBSD$? /* $OpenBSD: efidev.c,v 1.25 2017/05/11 01:37:24 yasuoka Exp $ */ Also let me update the diff. diff --git a/sys/arch/amd64/stand/efiboot/efiboot.c b/sys/arch/amd64/stand/efiboot/efiboot.c index efa371f2ecd..19df6b1dc64 100644 --- a/sys/arch/amd64/stand/efiboot/efiboot.c +++ b/sys/arch/amd64/stand/efiboot/efiboot.c @@ -52,7 +52,9 @@ static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL; static EFI_GUID devp_guid = DEVICE_PATH_PROTOCOL; u_long efi_loadaddr; -static int efi_device_path_cmp(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *, int); +static int efi_device_path_depth(EFI_DEVICE_PATH *dp, int); +static int efi_device_path_ncmp(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *, + int); static void efi_heap_init(void); static void efi_memprobe_internal(void); static void efi_video_init(void); @@ -159,7 +161,7 @@ struct disklist_lh efi_disklist; void efi_diskprobe(void) { - int i, bootdev; + int i, bootdev = 0, depth = -1; UINTN sz; EFI_STATUS status; EFI_HANDLE *handles = NULL; @@ -180,8 +182,10 @@ efi_diskprobe(void) if (handles == NULL || EFI_ERROR(status)) panic("BS->LocateHandle() returns %d", status); + if (efi_bootdp != NULL) + depth = efi_device_path_depth(efi_bootdp, MEDIA_DEVICE_PATH); + for (i = 0; i < sz / sizeof(EFI_HANDLE); i++) { - bootdev = 0; status = EFI_CALL(BS->HandleProtocol, handles[i], &blkio_guid, (void **)&blkio); if (EFI_ERROR(status)) @@ -193,53 +197,57 @@ efi_diskprobe(void) di = alloc(sizeof(struct diskinfo)); efid_init(di, blkio); - if (efi_bootdp == NULL) + if (efi_bootdp == NULL || depth == -1 || bootdev != 0) goto next; status = EFI_CALL(BS->HandleProtocol, handles[i], &devp_guid, (void **)&dp); if (EFI_ERROR(status)) goto next; - if (!efi_device_path_cmp(efi_bootdp, dp, HARDWARE_DEVICE_PATH)&& - !efi_device_path_cmp(efi_bootdp, dp, ACPI_DEVICE_PATH) && - !efi_device_path_cmp(efi_bootdp, dp, MESSAGING_DEVICE_PATH)) + if (efi_device_path_ncmp(efi_bootdp, dp, depth) == 0) { + TAILQ_INSERT_HEAD(&efi_disklist, di, list); bootdev = 1; + continue; + } next: - if (bootdev) - TAILQ_INSERT_HEAD(&efi_disklist, di, list); - else - TAILQ_INSERT_TAIL(&efi_disklist, di, list); + TAILQ_INSERT_TAIL(&efi_disklist, di, list); } free(handles, sz); } static int -efi_device_path_cmp(EFI_DEVICE_PATH *dpa, EFI_DEVICE_PATH *dpb, int dptype) +efi_device_path_depth(EFI_DEVICE_PATH *dp, int dptype) { - int cmp; - EFI_DEVICE_PATH *dp, *dpt_a = NULL, *dpt_b = NULL; + int i; - for (dp = dpa; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp)) { - if (DevicePathType(dp) == dptype) { - dpt_a = dp; - break; - } - } - for (dp = dpb; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp)) { - if (DevicePathType(dp) == dptype) { - dpt_b = dp; - break; - } + for (i = 0; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp), i++) { + if (DevicePathType(dp) == dptype) + return (i); } - if (dpt_a && dpt_b) { - cmp = DevicePathNodeLength(dpt_a) - DevicePathNodeLength(dpt_b); + return (-1); +} + +static int +efi_device_path_ncmp(EFI_DEVICE_PATH *dpa, EFI_DEVICE_PATH *dpb, int deptn) +{ + int i, cmp; + + for (i = 0; i < deptn; i++) { + if (IsDevicePathEnd(dpa) || IsDevicePathEnd(dpb)) + return ((IsDevicePathEnd(dpa) && IsDevicePathEnd(dpb)) + ? 0 : (IsDevicePathEnd(dpa))? -1 : 1); + cmp = DevicePathNodeLength(dpa) - DevicePathNodeLength(dpb); + if (cmp) + return (cmp); + cmp = memcmp(dpa, dpb, DevicePathNodeLength(dpa)); if (cmp) return (cmp); - return (memcmp(dpt_a, dpt_b, DevicePathNodeLength(dpt_a))); + dpa = NextDevicePathNode(dpa); + dpb = NextDevicePathNode(dpb); } - return ((uintptr_t)dpt_a - (uintptr_t)dpt_b); + return (0); } /***********************************************************************