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 <stdint.h>
+#include <stdbool.h>
 
 #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++)
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to