Provide a way to skip booting the OS and just return. This will allow
bootstd to read out useful information.

Add debugging to help figure out the flow.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 boot/pxe_utils.c    | 12 ++++++++++--
 include/pxe_utils.h |  4 +++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index b811406102b..7106e532e03 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -788,6 +788,9 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
                printf("append: %s\n", finalbootargs);
        }
 
+       if (ctx->no_boot)
+               return 0;
+
        label_run_boot(ctx, label, kernel_addr, initrd_addr_str,
                       initrd_filesize, initrd_str);
        /* ignore the error value since we are going to fail anyway */
@@ -1572,11 +1575,15 @@ static void boot_unattempted_labels(struct pxe_context 
*ctx,
        struct list_head *pos;
        struct pxe_label *label;
 
+       log_debug("Booting unattempted labels\n");
        list_for_each(pos, &cfg->labels) {
                label = list_entry(pos, struct pxe_label, list);
 
-               if (!label->attempted)
-                       label_boot(ctx, label);
+               if (!label->attempted) {
+                       log_debug("attempt: %s\n", label->name);
+                       if (!label_boot(ctx, label))
+                               return;
+               }
        }
 }
 
@@ -1627,6 +1634,7 @@ void handle_pxe_menu(struct pxe_context *ctx, struct 
pxe_menu *cfg)
 
        if (err == 1) {
                err = label_boot(ctx, choice);
+               log_debug("label_boot() returns %d\n", err);
                if (!err)
                        return;
        } else if (err != -ENOENT) {
diff --git a/include/pxe_utils.h b/include/pxe_utils.h
index e8e03430a81..beadd221475 100644
--- a/include/pxe_utils.h
+++ b/include/pxe_utils.h
@@ -109,7 +109,8 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, 
const char *file_path,
  * @use_ipv6: TRUE : use IPv6 addressing, FALSE : use IPv4 addressing
  * @use_fallback: TRUE : use "fallback" option as default, FALSE : use
  *     "default" option as default
- * @bflow: Bootflow being booted, or NULL if none
+ * @no_boot: Stop show of actually booting and just return
+ * @bflow: Bootflow being booted, or NULL if none (must be valid if @no_boot)
  */
 struct pxe_context {
        /**
@@ -130,6 +131,7 @@ struct pxe_context {
        ulong pxe_file_size;
        bool use_ipv6;
        bool use_fallback;
+       bool no_boot;
        struct bootflow *bflow;
 };
 
-- 
2.34.1

Reply via email to