From owner-svn-src-all@freebsd.org Fri Jun 7 02:05:24 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 983F415C599C; Fri, 7 Jun 2019 02:05:24 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8F9688FF0C; Fri, 7 Jun 2019 02:05:23 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 75A17252C0; Fri, 7 Jun 2019 02:05:23 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5725NCg081363; Fri, 7 Jun 2019 02:05:23 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5725NR3081362; Fri, 7 Jun 2019 02:05:23 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201906070205.x5725NR3081362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 7 Jun 2019 02:05:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348768 - head/stand/efi/boot1 X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/stand/efi/boot1 X-SVN-Commit-Revision: 348768 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8F9688FF0C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.95)[-0.945,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2019 02:05:24 -0000 Author: imp Date: Fri Jun 7 02:05:22 2019 New Revision: 348768 URL: https://svnweb.freebsd.org/changeset/base/348768 Log: Rework the reporting of the priority. Simplify the code a bit and rework how we report the results of the probing. Reviewed by: tsoome@ Differential Revision: https://reviews.freebsd.org/D20537 Modified: head/stand/efi/boot1/boot1.c Modified: head/stand/efi/boot1/boot1.c ============================================================================== --- head/stand/efi/boot1/boot1.c Fri Jun 7 01:38:51 2019 (r348767) +++ head/stand/efi/boot1/boot1.c Fri Jun 7 02:05:22 2019 (r348768) @@ -101,7 +101,7 @@ Calloc(size_t n1, size_t n2, const char *file, int lin */ static EFI_STATUS load_loader(const boot_module_t **modp, dev_info_t **devinfop, void **bufp, - size_t *bufsize, BOOLEAN preferred) + size_t *bufsize, int preferred) { UINTN i; dev_info_t *dev; @@ -141,10 +141,9 @@ try_boot(void) EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; - status = load_loader(&mod, &dev, &loaderbuf, &loadersize, TRUE); + status = load_loader(&mod, &dev, &loaderbuf, &loadersize, 1); if (status != EFI_SUCCESS) { - status = load_loader(&mod, &dev, &loaderbuf, &loadersize, - FALSE); + status = load_loader(&mod, &dev, &loaderbuf, &loadersize, 0); if (status != EFI_SUCCESS) { printf("Failed to load '%s'\n", PATH_LOADER_EFI); return (status); @@ -232,108 +231,81 @@ errout: /* * probe_handle determines if the passed handle represents a logical partition * if it does it uses each module in order to probe it and if successful it - * returns EFI_SUCCESS. + * returns 0. */ -static EFI_STATUS -probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, BOOLEAN *preferred) +static int +probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath) { dev_info_t *devinfo; EFI_BLOCK_IO *blkio; EFI_DEVICE_PATH *devpath; EFI_STATUS status; UINTN i; + int preferred; /* Figure out if we're dealing with an actual partition. */ status = BS->HandleProtocol(h, &DevicePathGUID, (void **)&devpath); if (status == EFI_UNSUPPORTED) - return (status); + return (0); if (status != EFI_SUCCESS) { DPRINTF("\nFailed to query DevicePath (%lu)\n", EFI_ERROR_CODE(status)); - return (status); + return (-1); } #ifdef EFI_DEBUG { CHAR16 *text = efi_devpath_name(devpath); - DPRINTF("probing: %S\n", text); + DPRINTF("probing: %S ", text); efi_free_devpath_name(text); } #endif status = BS->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio); if (status == EFI_UNSUPPORTED) - return (status); + return (0); if (status != EFI_SUCCESS) { DPRINTF("\nFailed to query BlockIoProtocol (%lu)\n", EFI_ERROR_CODE(status)); - return (status); + return (-1); } if (!blkio->Media->LogicalPartition) - return (EFI_UNSUPPORTED); + return (0); - *preferred = efi_devpath_same_disk(imgpath, devpath); + preferred = efi_devpath_same_disk(imgpath, devpath); /* Run through each module, see if it can load this partition */ devinfo = malloc(sizeof(*devinfo)); if (devinfo == NULL) { DPRINTF("\nFailed to allocate devinfo\n"); - return (EFI_UNSUPPORTED); + return (-1); } devinfo->dev = blkio; devinfo->devpath = devpath; devinfo->devhandle = h; - devinfo->preferred = *preferred; + devinfo->preferred = preferred; devinfo->next = NULL; for (i = 0; i < NUM_BOOT_MODULES; i++) { devinfo->devdata = NULL; + status = boot_modules[i]->probe(devinfo); if (status == EFI_SUCCESS) - return (EFI_SUCCESS); + return (preferred + 1); } free(devinfo); - return (EFI_UNSUPPORTED); + return (0); } -/* - * probe_handle_status calls probe_handle and outputs the returned status - * of the call. - */ -static void -probe_handle_status(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath) -{ - EFI_STATUS status; - BOOLEAN preferred; +const char *prio_str[] = { + "error", + "not supported", + "good", + "better" +}; - preferred = FALSE; - status = probe_handle(h, imgpath, &preferred); - - DPRINTF("probe: "); - switch (status) { - case EFI_UNSUPPORTED: - printf("."); - DPRINTF(" not supported\n"); - break; - case EFI_SUCCESS: - if (preferred) { - printf("%c", '*'); - DPRINTF(" supported (preferred)\n"); - } else { - printf("%c", '+'); - DPRINTF(" supported\n"); - } - break; - default: - printf("x"); - DPRINTF(" error (%lu)\n", EFI_ERROR_CODE(status)); - break; - } - DSTALL(500000); -} - EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) { @@ -348,6 +320,7 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) UINT16 boot_current; size_t sz; UINT16 boot_order[100]; + int rv; /* Basic initialization*/ ST = Xsystab; @@ -449,8 +422,14 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) printf(" Probing %zu block devices...", nhandles); DPRINTF("\n"); - for (i = 0; i < nhandles; i++) - probe_handle_status(handles[i], imgpath); + for (i = 0; i < nhandles; i++) { + rv = probe_handle(handles[i], imgpath); +#ifdef EFI_DEBUG + printf("%c", "x.+*"[rv + 1]); +#else + printf("%s\n", prio_str[rv + 1]); +#endif + } printf(" done\n"); /* Status summary. */