[U-Boot] [PATCH 3/9] SPL: read and store arch property from U-Boot image

Andre Przywara andre.przywara at arm.com
Thu Feb 21 01:30:28 UTC 2019


Read the specified "arch" value from a legacy or FIT U-Boot image and
store it in our SPL data structure.
This allows loaders to take the target architecture in account for
custom loading procedures.
Having the complete string -> arch mapping for FIT based images in the
SPL would be too big, so we leave it up to architectures (or boards) to
overwrite the weak function that does the actual translation, possibly
covering only the required subset there.

Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
 common/spl/spl.c     | 1 +
 common/spl/spl_fit.c | 8 ++++++++
 include/spl.h        | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 2e2af1b28e..7d25e72bbb 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -272,6 +272,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 #endif
 
 		spl_image->os = image_get_os(header);
+		spl_image->arch = image_get_arch(header);
 		spl_image->name = image_get_name(header);
 		debug(SPL_TPL_PROMPT
 		      "payload image: %32s load addr: 0x%lx size: %d\n",
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index db436268cb..d583946571 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -340,6 +340,11 @@ static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
 #endif
 }
 
+__weak u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+	return IH_ARCH_DEFAULT;
+}
+
 int spl_load_simple_fit(struct spl_image_info *spl_image,
 			struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -351,6 +356,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	int images, ret;
 	int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1;
 	int index = 0;
+	const char *arch_str;
 
 	/*
 	 * For FIT with external data, figure out where the external images
@@ -467,6 +473,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	else
 		spl_image->os = IH_OS_U_BOOT;
 #endif
+	arch_str = fdt_getprop(fit, node, "arch", NULL);
+	spl_image->arch = spl_genimg_get_arch_id(arch_str);
 
 	/*
 	 * Booting a next-stage U-Boot may require us to append the FDT.
diff --git a/include/spl.h b/include/spl.h
index f09909e189..aac85150a7 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -64,7 +64,6 @@ static inline bool u_boot_first_phase(void)
 
 struct spl_image_info {
 	const char *name;
-	u8 os;
 	uintptr_t load_addr;
 	uintptr_t entry_point;
 #if CONFIG_IS_ENABLED(LOAD_FIT)
@@ -79,6 +78,8 @@ struct spl_image_info {
 	ulong dcrc_length;
 	ulong dcrc;
 #endif
+	u8 os;
+	u8 arch;
 };
 
 /*
-- 
2.14.5



More information about the U-Boot mailing list