[PATCH 4/4] spl: atf: Reduce SPL code size

Massimo Pegorer massimo.pegorer+oss at gmail.com
Sat Sep 16 10:25:07 CEST 2023


Previous fix commit increases code size of a few bytes. This minor
rework finally reduces SPL size of about 64-72 bytes (tested with
buildman on several aarch64 boards).

Signed-off-by: Massimo Pegorer <massimo.pegorer+oss at gmail.com>
---
 common/spl/spl_atf.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/common/spl/spl_atf.c b/common/spl/spl_atf.c
index 0d8db2d14e..fa79f73be2 100644
--- a/common/spl/spl_atf.c
+++ b/common/spl/spl_atf.c
@@ -209,7 +209,19 @@ static void spl_enter_atf(uintptr_t bl31_entry, uintptr_t bl32_entry,
 	atf_entry(bl31_params, (void *)fdt_addr);
 }
 
-static int spl_fit_images_find(void *blob, int os)
+static void spl_fit_images_get_entry(void *blob, int node, uintptr_t *entry_p)
+{
+	ulong val;
+
+	if (fit_image_get_entry(blob, node, &val))
+		if (fit_image_get_load(blob, node, &val))
+			return;
+
+	debug("%s: entry point 0x%lx\n", __func__, val);
+	*entry_p = val;
+}
+
+static int spl_fit_images_get_os_entry(void *blob, int os, uintptr_t *entry_p)
 {
 	int parent, node, ndepth = 0;
 	const void *data;
@@ -231,41 +243,28 @@ static int spl_fit_images_find(void *blob, int os)
 		if (!data)
 			continue;
 
-		if (genimg_get_os_id(data) == os)
-			return node;
+		if (genimg_get_os_id(data) == os) {
+			spl_fit_images_get_entry(blob, node, entry_p);
+			return 0;
+		}
 	};
 
 	return -FDT_ERR_NOTFOUND;
 }
 
-void spl_fit_images_get_entry(void *blob, int node, uintptr_t *entry_p)
-{
-	ulong val;
-
-	if (fit_image_get_entry(blob, node, &val))
-		if (fit_image_get_load(blob, node, &val))
-			return;
-
-	debug("%s: entry point 0x%lx\n", __func__, val);
-	*entry_p = val;
-}
-
 void spl_invoke_atf(struct spl_image_info *spl_image)
 {
 	uintptr_t bl32_entry = 0;
 	uintptr_t bl33_entry = CONFIG_TEXT_BASE;
 	void *blob = spl_image->fdt_addr;
 	uintptr_t platform_param = (uintptr_t)blob;
-	int node;
 
 	/*
 	 * Find (in /fit-images) the TEE binary entry point address
 	 * (or load address if entry point is missing) and pass it as
 	 * the BL3-2 entry point. This is optional.
 	 */
-	node = spl_fit_images_find(blob, IH_OS_TEE);
-	if (node >= 0)
-		spl_fit_images_get_entry(blob, node, &bl32_entry);
+	spl_fit_images_get_os_entry(blob, IH_OS_TEE, &bl32_entry);
 
 	/*
 	 * Find (in /fit-images) the U-Boot binary entry point address
@@ -273,10 +272,7 @@ void spl_invoke_atf(struct spl_image_info *spl_image)
 	 * the BL3-3 entry point.
 	 * This will need to be extended to support Falcon mode.
 	 */
-
-	node = spl_fit_images_find(blob, IH_OS_U_BOOT);
-	if (node >= 0)
-		spl_fit_images_get_entry(blob, node, &bl33_entry);
+	spl_fit_images_get_os_entry(blob, IH_OS_U_BOOT, &bl33_entry);
 
 	/*
 	 * If ATF_NO_PLATFORM_PARAM is set, we override the platform
-- 
2.34.1



More information about the U-Boot mailing list