[PATCH 20/31] passage: spl: Support passing the passage to U-Boot

Simon Glass sjg at chromium.org
Mon Nov 1 02:17:22 CET 2021


Update the jump routine to support passing three parameters instead of
one. The two new parameters are the bloblist address and the offset from
there to the devicetree.

Add an accessor for gd->bloblist to avoid needing #ifdefs in the C code.

Note that this renames jump_to_image_no_args() to jump_to_image(), so will
not work on boards which have overridden that weak function. This can be
tided up by maintainers as they enable the standard passage. Fix up a
few that definitely need a tweak.

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

 arch/sandbox/cpu/spl.c            |  2 +-
 arch/x86/lib/spl.c                |  2 +-
 arch/x86/lib/tpl.c                |  2 +-
 common/spl/spl.c                  | 30 +++++++++++++++++++++++++-----
 include/asm-generic/global_data.h |  6 ++++++
 include/spl.h                     | 13 +++++++++++++
 6 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 650bdb0a701..7047613517b 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -87,7 +87,7 @@ void spl_board_init(void)
 	}
 }
 
-void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+void __noreturn jump_to_image(struct spl_image_info *spl_image)
 {
 	const char *fname = spl_image->arg;
 
diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
index b18c1cd6092..c51514bfeb8 100644
--- a/arch/x86/lib/spl.c
+++ b/arch/x86/lib/spl.c
@@ -238,7 +238,7 @@ int spl_spi_load_image(void)
 }
 
 #ifdef CONFIG_X86_RUN_64BIT
-void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+void __noreturn jump_to_image(struct spl_image_info *spl_image)
 {
 	int ret;
 
diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 5b57e53c2dd..b334f70e83e 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -110,7 +110,7 @@ int spl_spi_load_image(void)
 	return -EPERM;
 }
 
-void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+void __noreturn jump_to_image(struct spl_image_info *spl_image)
 {
 	debug("Jumping to %s at %lx\n", spl_phase_name(spl_next_phase()),
 	      (ulong)spl_image->entry_point);
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 7a9df9aaece..a226c2a2488 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -394,13 +394,33 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 
 __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
-	typedef void __noreturn (*image_entry_noargs_t)(void);
+	jump_to_image(spl_image);
+}
+
+__weak void __noreturn jump_to_image(struct spl_image_info *spl_image)
+{
+	typedef void __noreturn (*image_entry_t)(ulong bloblist,
+						 ulong dtb_offset);
+	ulong bloblist = 0;
+	ulong dtb_offset = 0;
 
-	image_entry_noargs_t image_entry =
-		(image_entry_noargs_t)spl_image->entry_point;
+	image_entry_t image_entry = (image_entry_t)spl_image->entry_point;
 
 	debug("image entry point: 0x%lx\n", spl_image->entry_point);
-	image_entry();
+
+	if (CONFIG_IS_ENABLED(PASSAGE_OUT)) {
+		const void *fdt;
+
+		bloblist = bloblist_get_base();
+		fdt = bloblist_find(BLOBLISTT_CONTROL_DTB, 0);
+		if (fdt)
+			dtb_offset = (ulong)fdt - (ulong)gd_bloblist();
+
+		log_debug("passage: sending bloblist at %lx, dtb offset %lx\n",
+			  bloblist, dtb_offset);
+	}
+
+	image_entry(bloblist, dtb_offset);
 }
 
 #if CONFIG_IS_ENABLED(HANDOFF)
@@ -862,7 +882,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 #endif
 
 	spl_board_prepare_for_boot();
-	jump_to_image_no_args(&spl_image);
+	jump_to_image(&spl_image);
 }
 
 /*
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 717fe2edb46..6aba74dac10 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -541,6 +541,12 @@ static_assert(sizeof(struct global_data) == GD_SIZE);
 #define gd_set_multi_dtb_fit(_dtb)
 #endif
 
+#if CONFIG_IS_ENABLED(BLOBLIST)
+#define gd_bloblist()		gd->bloblist
+#else
+#define gd_bloblist()		NULL
+#endif
+
 /**
  * enum gd_flags - global data flags
  *
diff --git a/include/spl.h b/include/spl.h
index 7da8f7f92ab..3292ddeb512 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -581,6 +581,19 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
 int spl_load_image_fat_os(struct spl_image_info *spl_image,
 			  struct blk_desc *block_dev, int partition);
 
+/**
+ * jump_to_image() - Jump to image, using standard passage if enabled
+ *
+ * This sets the machine registers correctly if standard passage is enabled for
+ * output. This allows the target image to read the info using the standard
+ * passage protocol
+ *
+ * This is a weak function, so may be overriddden
+ *
+ * @spl_image: Image to jump to
+ */
+void __noreturn jump_to_image(struct spl_image_info *spl_image);
+
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
 
 /* SPL EXT image functions */
-- 
2.33.1.1089.g2158813163f-goog



More information about the U-Boot mailing list