diff options
author | Matt Fleming <matt.fleming@intel.com> | 2013-05-10 14:16:46 +0100 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-05-10 14:21:51 +0100 |
commit | 717a819dd1cd43ba02db703598c172fb6b1819a8 (patch) | |
tree | 0d7dfabe983d858f2da3d37ee89a85f6776340e7 | |
parent | fe283b78c973268f2d1f0309826ceeb5c9e8978d (diff) | |
download | syslinux-717a819dd1cd43ba02db703598c172fb6b1819a8.tar.gz syslinux-717a819dd1cd43ba02db703598c172fb6b1819a8.tar.xz syslinux-717a819dd1cd43ba02db703598c172fb6b1819a8.zip |
efi: Lookup which file system we were loaded from
commit fe283b78c973 ("efi: Add network support") made the assumption
that we were always booting via PXE and therefore wanted to register
pxe_fs_ops with fs_init(). Obviously we need to lookup which file system
syslinux.efi was loaded from at runtime and register the correct ops
vector.
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | efi/main.c | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -1177,13 +1177,10 @@ static void efi_setcwd(CHAR16 *dp) EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table) { + EFI_PXE_BASE_CODE *pxe; EFI_LOADED_IMAGE *info; EFI_STATUS status = EFI_SUCCESS; -#if 0 - const struct fs_ops *ops[] = { &vfat_fs_ops, NULL }; -#else - const struct fs_ops *ops[] = { &pxe_fs_ops, NULL }; -#endif + const struct fs_ops *ops[] = { NULL, NULL }; unsigned long len = (unsigned long)__bss_end - (unsigned long)__bss_start; static struct efi_disk_private priv; SIMPLE_INPUT_INTERFACE *in; @@ -1204,8 +1201,22 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table) goto out; } - /* Use device handle to set up the volume root to proceed with ADV init */ - efi_set_volroot(info->DeviceHandle); + status = uefi_call_wrapper(BS->HandleProtocol, 3, info->DeviceHandle, + &PxeBaseCodeProtocol, (void **)&pxe); + if (status != EFI_SUCCESS) { + /* + * Use device handle to set up the volume root to + * proceed with ADV init. + */ + if (EFI_ERROR(efi_set_volroot(info->DeviceHandle))) { + Print(L"Failed to locate root device to prep for "); + Print(L"file operations & ADV initialization\n"); + goto out; + } + + ops[0] = &vfat_fs_ops; + } else + ops[0] = &pxe_fs_ops; /* setup timer for boot menu system support */ status = setup_default_timer(&timer_ev); @@ -1216,7 +1227,6 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table) /* TODO: once all errors are captured in efi_errno, bail out if necessary */ - /* XXX figure out what file system we're on */ priv.dev_handle = info->DeviceHandle; /* |