[syslinux:firmware] efi: Lookup which file system we were loaded from

syslinux-bot for Matt Fleming matt.fleming at intel.com
Fri May 10 06:27:05 PDT 2013


Commit-ID:  717a819dd1cd43ba02db703598c172fb6b1819a8
Gitweb:     http://www.syslinux.org/commit/717a819dd1cd43ba02db703598c172fb6b1819a8
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Fri, 10 May 2013 14:16:46 +0100
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Fri, 10 May 2013 14:21:51 +0100

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 at intel.com>

---
 efi/main.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/efi/main.c b/efi/main.c
index 31f0bff..27e7f8f 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -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;
 
 	/*


More information about the Syslinux-commits mailing list