]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootflow: bootmeth_efi: Handle fdt not available.
authorShantur Rathore <i@shantur.com>
Sun, 19 Nov 2023 16:55:00 +0000 (16:55 +0000)
committerTom Rini <trini@konsulko.com>
Sat, 9 Dec 2023 18:16:08 +0000 (13:16 -0500)
While booting with efi, if fdt isn't available externally,
just use the built-in one.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Shantur Rathore <i@shantur.com>
boot/bootmeth_efi.c
include/bootflow.h

index fd224f7c91a50f69d58a962b71906f9061af0f30..e884dc62937fe5ca1efef0466a9b15bf192c1878 100644 (file)
@@ -313,6 +313,7 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
                 */
        } else {
                log_debug("No device tree available\n");
+               bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
        }
 
        return 0;
@@ -391,6 +392,7 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
                bflow->fdt_addr = fdt_addr;
        } else {
                log_debug("No device tree available\n");
+               bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
        }
 
        bflow->state = BOOTFLOWST_READY;
@@ -429,13 +431,11 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
                        return log_msg_ret("read", ret);
 
                /*
-                * use the provided device tree if available, else fall back to
-                * the control FDT
+                * use the provided device tree if not using the built-in fdt
                 */
-               if (bflow->fdt_fname)
+               if (bflow->flags & ~BOOTFLOWF_USE_BUILTIN_FDT)
                        fdt = bflow->fdt_addr;
-               else
-                       fdt = (ulong)map_to_sysmem(gd->fdt_blob);
+
        } else {
                /*
                 * This doesn't actually work for network devices:
@@ -452,7 +452,14 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
         * At some point we can add a real interface to bootefi so we can call
         * this directly. For now, go through the CLI, like distro boot.
         */
-       snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
+       if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
+               log_debug("Booting with built-in fdt\n");
+               snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
+       } else {
+               log_debug("Booting with external fdt\n");
+               snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
+       }
+
        if (run_command(cmd, 0))
                return log_msg_ret("run", -EINVAL);
 
index fede8f22a2b8caf6eb52331d95be2338dcadfc5b..42112874f647c2e0bc7ac32c32a73606595b811e 100644 (file)
@@ -45,10 +45,12 @@ enum bootflow_state_t {
  *     CONFIG_OF_HAS_PRIOR_STAGE is enabled
  * @BOOTFLOWF_STATIC_BUF: Indicates that @bflow->buf is statically set, rather
  *     than being allocated by malloc().
+ * @BOOTFLOWF_USE_BUILTIN_FDT : Indicates that current bootflow uses built-in FDT
  */
 enum bootflow_flags_t {
        BOOTFLOWF_USE_PRIOR_FDT = 1 << 0,
        BOOTFLOWF_STATIC_BUF    = 1 << 1,
+       BOOTFLOWF_USE_BUILTIN_FDT       = 1 << 2,
 };
 
 /**