[PATCH v3 33/46] pxe: Allow skipping the boot

Simon Glass sjg at chromium.org
Fri Dec 6 03:36:12 CET 2024


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 <sjg at chromium.org>
---

(no changes since v1)

 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 f7bbc1527af..3531ab1c71a 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -782,6 +782,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 */
@@ -1566,11 +1569,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;
+		}
 	}
 }
 
@@ -1621,6 +1628,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



More information about the U-Boot mailing list