[PATCH 08/14] initcall: Support manual relocation

Simon Glass sjg at chromium.org
Tue Aug 22 05:16:55 CEST 2023


Move the manual-relocation code to the initcall file. Make sure to avoid
manually relocating event types. Only true function pointers should be
relocated.

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

 common/board_r.c   |  6 ++----
 include/initcall.h |  7 +++++++
 lib/initcall.c     | 10 ++++++++++
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 85860861f0ac..7c1fbc69ed6d 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -813,10 +813,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 #endif
 	gd->flags &= ~GD_FLG_LOG_READY;
 
-	if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
-		for (int i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
-			MANUAL_RELOC(init_sequence_r[i]);
-	}
+	if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC))
+		initcall_manual_reloc(init_sequence_r);
 
 	if (initcall_run_list(init_sequence_r))
 		hang();
diff --git a/include/initcall.h b/include/initcall.h
index 62d3bb67f089..208effd8d13e 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -35,4 +35,11 @@ typedef int (*init_fnc_t)(void);
  */
 int initcall_run_list(const init_fnc_t init_sequence[]);
 
+/**
+ * initcall_manual_reloc() - Do manual relocation on an initcall sequence
+ *
+ * @init_sequence: NULL-terminated init sequence to relocate
+ */
+void initcall_manual_reloc(init_fnc_t init_sequence[]);
+
 #endif
diff --git a/lib/initcall.c b/lib/initcall.c
index 33b7d761dc7e..480490ea239d 100644
--- a/lib/initcall.c
+++ b/lib/initcall.c
@@ -97,3 +97,13 @@ int initcall_run_list(const init_fnc_t init_sequence[])
 
 	return 0;
 }
+
+void initcall_manual_reloc(init_fnc_t init_sequence[])
+{
+	init_fnc_t *ptr;
+
+	for (ptr = init_sequence; *ptr; ptr++) {
+		if (!initcall_is_event(*ptr))
+			MANUAL_RELOC(*ptr);
+	}
+}
-- 
2.42.0.rc1.204.g551eb34607-goog



More information about the U-Boot mailing list