From owner-svn-src-head@freebsd.org Fri Oct 6 12:21:48 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 249DAE35F8D; Fri, 6 Oct 2017 12:21:48 +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 mx1.freebsd.org (Postfix) with ESMTPS id EE7F78115C; Fri, 6 Oct 2017 12:21:47 +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 v96CLlIb046240; Fri, 6 Oct 2017 12:21:47 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v96CLko0046237; Fri, 6 Oct 2017 12:21:46 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201710061221.v96CLko0046237@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 6 Oct 2017 12:21:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324360 - in head/sys/boot/efi: include libefi loader X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: in head/sys/boot/efi: include libefi loader X-SVN-Commit-Revision: 324360 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Oct 2017 12:21:48 -0000 Author: imp Date: Fri Oct 6 12:21:46 2017 New Revision: 324360 URL: https://svnweb.freebsd.org/changeset/base/324360 Log: Encapsulate ZFS preferences into efi_zfs_is_preferred Move the retrieval of the image information into loader's main instead of doing it in efizfs.c Differential Revision: https://reviews.freebsd.org/D12564 Submitted by: Eric McCorkle Modified: head/sys/boot/efi/include/efizfs.h head/sys/boot/efi/libefi/efizfs.c head/sys/boot/efi/loader/main.c Modified: head/sys/boot/efi/include/efizfs.h ============================================================================== --- head/sys/boot/efi/include/efizfs.h Fri Oct 6 12:20:24 2017 (r324359) +++ head/sys/boot/efi/include/efizfs.h Fri Oct 6 12:21:46 2017 (r324360) @@ -27,6 +27,7 @@ */ #include +#include #ifndef _EFIZFS_H_ #define _EFIZFS_H_ @@ -45,6 +46,7 @@ extern uint64_t pool_guid; extern void efi_zfs_probe(void); extern zfsinfo_list_t *efizfs_get_zfsinfo_list(void); +extern bool efi_zfs_is_preferred(EFI_HANDLE *h); extern EFI_HANDLE efizfs_get_handle_by_guid(uint64_t); #endif Modified: head/sys/boot/efi/libefi/efizfs.c ============================================================================== --- head/sys/boot/efi/libefi/efizfs.c Fri Oct 6 12:20:24 2017 (r324359) +++ head/sys/boot/efi/libefi/efizfs.c Fri Oct 6 12:21:46 2017 (r324360) @@ -81,12 +81,9 @@ efi_zfs_probe(void) { pdinfo_list_t *hdi; pdinfo_t *hd, *pd = NULL; - EFI_GUID imgid = LOADED_IMAGE_PROTOCOL; - EFI_LOADED_IMAGE *img; char devname[SPECNAMELEN + 1]; uint64_t guid; - BS->HandleProtocol(IH, &imgid, (VOID**)&img); hdi = efiblk_get_pdinfo_list(&efipart_hddev); STAILQ_INIT(&zfsinfo); @@ -105,7 +102,7 @@ efi_zfs_probe(void) if (zfs_probe_dev(devname, &guid) == 0) { insert_zfs(pd->pd_handle, guid); - if (pd->pd_handle == img->DeviceHandle) + if (efi_zfs_is_preferred(pd->pd_handle)) pool_guid = guid; } Modified: head/sys/boot/efi/loader/main.c ============================================================================== --- head/sys/boot/efi/loader/main.c Fri Oct 6 12:20:24 2017 (r324359) +++ head/sys/boot/efi/loader/main.c Fri Oct 6 12:21:46 2017 (r324360) @@ -72,6 +72,15 @@ EFI_GUID debugimg = DEBUG_IMAGE_INFO_TABLE_GUID; EFI_GUID fdtdtb = FDT_TABLE_GUID; EFI_GUID inputid = SIMPLE_TEXT_INPUT_PROTOCOL; +static EFI_LOADED_IMAGE *img; + +bool +efi_zfs_is_preferred(EFI_HANDLE *h) +{ + return (h == img->DeviceHandle); +} + + static int has_keyboard(void) { @@ -300,7 +309,6 @@ EFI_STATUS main(int argc, CHAR16 *argv[]) { char var[128]; - EFI_LOADED_IMAGE *img; EFI_GUID *guid; int i, j, vargood, howto; UINTN k; @@ -319,6 +327,9 @@ main(int argc, CHAR16 *argv[]) archsw.arch_zfs_probe = efi_zfs_probe; #endif + /* Get our loaded image protocol interface structure. */ + BS->HandleProtocol(IH, &imgid, (VOID**)&img); + /* Init the time source */ efi_time_init(); @@ -445,9 +456,6 @@ main(int argc, CHAR16 *argv[]) for (i = 0; devsw[i] != NULL; i++) if (devsw[i]->dv_init != NULL) (devsw[i]->dv_init)(); - - /* Get our loaded image protocol interface structure. */ - BS->HandleProtocol(IH, &imgid, (VOID**)&img); printf("Command line arguments:"); for (i = 0; i < argc; i++)