git: 1e49aa7a984e - main - loader.efi: Add comments describing the boot protocol

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 26 Jun 2026 14:59:13 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=1e49aa7a984e0d4381538aa6cf16d37b20b000b9

commit 1e49aa7a984e0d4381538aa6cf16d37b20b000b9
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-06-26 14:45:31 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-06-26 14:54:35 +0000

    loader.efi: Add comments describing the boot protocol
    
    Add some comments about the boot protocol. Need to do a deeper dive into
    the networking code since it's the last set of code used here.
    
    Signed-off-by: Warner Losh <imp@FreeBSD.org>
    Differential Revision:  https://reviews.freebsd.org/D57800
---
 stand/efi/loader/main.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 1444b1eee17d..1d91c8dd26ac 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -641,17 +641,24 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
 
 #ifdef MD_IMAGE_SIZE
 	/*
-	 * If there is an embedded MD, try to use that.
+	 * Forth choice: If there is an embedded MD, try to use that.
 	 */
 	printf("Trying MD\n");
 	if (probe_md_currdev())
 		return (0);
 #endif /* MD_IMAGE_SIZE */
 
+	/*
+	 * Fifth choice: try all the partitions on the boot device.
+	 */
 	if (try_boot_device_partitions() == 0)
 		return (0);
 
 #ifdef EFI_ZFS_BOOT
+	/*
+	 * Sixth Choice: Probe the boot disk for ZFS and then probe the non-boot
+	 * disk if we have a relaxed boot poluicy.
+	 */
 	{
 		zfsinfo_list_t *zfsinfo = efizfs_get_zfsinfo_list();
 		zfsinfo_t *zi;
@@ -686,8 +693,8 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
 #endif /* EFI_ZFS_BOOT */
 
 	/*
-	 * Try the device handle from our loaded image first.  If that
-	 * fails, use the device path from the loaded image and see if
+	 * Seventh choice: Try the device handle from our loaded image first.
+	 * If that fails, use the device path from the loaded image and see if
 	 * any of the nodes in that path match one of the enumerated
 	 * handles. Currently, this handle list is only for netboot.
 	 */
@@ -697,6 +704,12 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
 			return (0);
 	}
 
+	/*
+	 * Eighth choice: look up the device handle... This loops through the
+	 * entries to find the device handle. The network protocols have long
+	 * strings of device nodes in the device path, and this may make
+	 * something work.
+	 */
 	copy = NULL;
 	devpath = efi_lookup_image_devpath(IH);
 	while (devpath != NULL) {
@@ -1256,7 +1269,7 @@ main(int argc, CHAR16 *argv[])
 #endif
 
         /* Get our loaded image protocol interface structure. */
-	(void) OpenProtocolByHandle(IH, &imgid, (void **)&boot_img);
+	(void)OpenProtocolByHandle(IH, &imgid, (void **)&boot_img);
 
 	/* Report the RSDP early. */
 	acpi_detect();