[PATCH v3 24/43] sandbox: Generalise SPL booting

Simon Glass sjg at chromium.org
Fri Oct 21 02:23:01 CEST 2022


At present sandbox only supports jumping to a file, to get to the next
U-Boot phase. We want to support other methods, so update the code to
use an enum for the method. Also use the

Use board_boot_order() to set the order, so we can add more options.
Also add the MMC methods into the BOOT_DEVICE enum so that booting
from MMC can be supported.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 arch/sandbox/cpu/spl.c         | 33 +++++++++++++++++++++------------
 arch/sandbox/include/asm/spl.h |  3 +++
 include/spl.h                  |  9 +++++++++
 3 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 9c59cc26163..2678370481a 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -49,13 +49,13 @@ void board_init_f(ulong flag)
 	preloader_console_init();
 }
 
-u32 spl_boot_device(void)
+void board_boot_order(u32 *spl_boot_list)
 {
-	return BOOT_DEVICE_BOARD;
+	spl_boot_list[0] = BOOT_DEVICE_BOARD;
 }
 
-static int spl_board_load_image(struct spl_image_info *spl_image,
-				struct spl_boot_device *bootdev)
+static int spl_board_load_file(struct spl_image_info *spl_image,
+			       struct spl_boot_device *bootdev)
 {
 	char fname[256];
 	int ret;
@@ -74,10 +74,11 @@ static int spl_board_load_image(struct spl_image_info *spl_image,
 	if (!spl_image->arg)
 		return log_msg_ret("exec", -ENOMEM);
 	strcpy(spl_image->arg, fname);
+	spl_image->flags = SPL_SANDBOXF_ARG_IS_FNAME;
 
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_image);
+SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_file);
 
 void spl_board_init(void)
 {
@@ -96,13 +97,21 @@ void spl_board_init(void)
 
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
-	const char *fname = spl_image->arg;
-
-	if (fname) {
-		os_fd_restore();
-		os_spl_to_uboot(fname);
-	} else {
-		printf("No filename provided for U-Boot\n");
+	switch (spl_image->flags) {
+	case SPL_SANDBOXF_ARG_IS_FNAME: {
+		const char *fname = spl_image->arg;
+
+		if (fname) {
+			os_fd_restore();
+			os_spl_to_uboot(fname);
+		} else {
+			log_err("No filename provided for U-Boot\n");
+		}
+		break;
+	}
+	default:
+		log_err("Invalid flags\n");
+		break;
 	}
 	hang();
 }
diff --git a/arch/sandbox/include/asm/spl.h b/arch/sandbox/include/asm/spl.h
index bf5a585622b..312aef72086 100644
--- a/arch/sandbox/include/asm/spl.h
+++ b/arch/sandbox/include/asm/spl.h
@@ -7,6 +7,9 @@
 #define __asm_spl_h
 
 enum {
+	BOOT_DEVICE_MMC1,
+	BOOT_DEVICE_MMC2,
+	BOOT_DEVICE_MMC2_2,
 	BOOT_DEVICE_BOARD,
 };
 
diff --git a/include/spl.h b/include/spl.h
index a89830d24fd..e711fb13654 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -228,6 +228,15 @@ static inline const char *spl_phase_prefix(enum u_boot_phase phase)
 # define SPL_TPL_PROMPT	""
 #endif
 
+/**
+ * enum spl_sandbox_flags - flags for sandbox's use of spl_image_info->flags
+ *
+ * @SPL_SANDBOXF_ARG_IS_FNAME: arg is the filename to jump to (default)
+ */
+enum spl_sandbox_flags {
+	SPL_SANDBOXF_ARG_IS_FNAME = 0,
+};
+
 struct spl_image_info {
 	const char *name;
 	u8 os;
-- 
2.38.0.135.g90850a2211-goog



More information about the U-Boot mailing list