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
This commit is contained in:
imp 2017-10-06 12:21:46 +00:00
parent 679de09379
commit cd98c7fb86
3 changed files with 15 additions and 8 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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();
@ -446,9 +457,6 @@ main(int argc, CHAR16 *argv[])
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++)
printf(" %S", argv[i]);