svn commit: r335229 - in head/stand/efi: include libefi loader
Warner Losh
imp at FreeBSD.org
Fri Jun 15 19:07:27 UTC 2018
Author: imp
Date: Fri Jun 15 19:07:26 2018
New Revision: 335229
URL: https://svnweb.freebsd.org/changeset/base/335229
Log:
Provide a more direct interface to tell ZFS what the preferred handle
is. We tell the ZFS code now, and it checks rather than having a
callback to do the checks.
This will allow us to have a more graceful fallback code. In the
future, it's anticipated that we may fallback to a more global search
(or implement a command to do so) when reqeusted by the user, or we
detect a violation of the UEFI Boot Manager protocol severe enough to
warrant this backstop. For now, it just allows us to get rid of img as
a global.
Sponsored by: Netflix
Modified:
head/stand/efi/include/efizfs.h
head/stand/efi/libefi/efizfs.c
head/stand/efi/loader/main.c
Modified: head/stand/efi/include/efizfs.h
==============================================================================
--- head/stand/efi/include/efizfs.h Fri Jun 15 19:07:06 2018 (r335228)
+++ head/stand/efi/include/efizfs.h Fri Jun 15 19:07:26 2018 (r335229)
@@ -44,11 +44,11 @@ typedef struct zfsinfo
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);
-extern bool efizfs_get_guid_by_handle(EFI_HANDLE, uint64_t *);
+void efi_zfs_probe(void);
+EFI_HANDLE efizfs_get_handle_by_guid(uint64_t);
+bool efizfs_get_guid_by_handle(EFI_HANDLE, uint64_t *);
+zfsinfo_list_t *efizfs_get_zfsinfo_list(void);
+void efizfs_set_preferred(EFI_HANDLE);
#endif
Modified: head/stand/efi/libefi/efizfs.c
==============================================================================
--- head/stand/efi/libefi/efizfs.c Fri Jun 15 19:07:06 2018 (r335228)
+++ head/stand/efi/libefi/efizfs.c Fri Jun 15 19:07:26 2018 (r335229)
@@ -45,6 +45,14 @@ static zfsinfo_list_t zfsinfo;
uint64_t pool_guid;
+static EFI_HANDLE preferred;
+
+void
+efizfs_set_preferred(EFI_HANDLE h)
+{
+ preferred = h;
+}
+
zfsinfo_list_t *
efizfs_get_zfsinfo_list(void)
{
@@ -110,16 +118,13 @@ efi_zfs_probe(void)
*/
STAILQ_FOREACH(hd, hdi, pd_link) {
STAILQ_FOREACH(pd, &hd->pd_part, pd_link) {
-
snprintf(devname, sizeof(devname), "%s%dp%d:",
efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit);
-
- if (zfs_probe_dev(devname, &guid) == 0) {
- insert_zfs(pd->pd_handle, guid);
-
- if (efi_zfs_is_preferred(pd->pd_handle))
- pool_guid = guid;
- }
+ if (zfs_probe_dev(devname, &guid) == 0) {
+ insert_zfs(pd->pd_handle, guid);
+ if (pd->pd_handle == preferred)
+ pool_guid = guid;
+ }
}
}
Modified: head/stand/efi/loader/main.c
==============================================================================
--- head/stand/efi/loader/main.c Fri Jun 15 19:07:06 2018 (r335228)
+++ head/stand/efi/loader/main.c Fri Jun 15 19:07:26 2018 (r335229)
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#ifdef EFI_ZFS_BOOT
#include <libzfs.h>
-
#include "efizfs.h"
#endif
@@ -73,8 +72,6 @@ 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;
-
/*
* Number of seconds to wait for a keystroke before exiting with failure
* in the event no currdev is found. -2 means always break, -1 means
@@ -84,14 +81,6 @@ static EFI_LOADED_IMAGE *img;
*/
static int fail_timeout = 5;
-#ifdef EFI_ZFS_BOOT
-bool
-efi_zfs_is_preferred(EFI_HANDLE *h)
-{
- return (h == img->DeviceHandle);
-}
-#endif
-
static bool
has_keyboard(void)
{
@@ -424,6 +413,7 @@ main(int argc, CHAR16 *argv[])
UINT16 boot_current;
size_t sz;
UINT16 boot_order[100];
+ EFI_LOADED_IMAGE *img;
#if !defined(__arm__)
char buf[40];
#endif
@@ -441,6 +431,10 @@ main(int argc, CHAR16 *argv[])
/* Get our loaded image protocol interface structure. */
BS->HandleProtocol(IH, &imgid, (VOID**)&img);
+#ifdef EFI_ZFS_BOOT
+ /* Tell ZFS probe code where we booted from */
+ efizfs_set_preferred(img->DeviceHandle);
+#endif
/* Init the time source */
efi_time_init();
More information about the svn-src-head
mailing list