]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
initcall: Support manual relocation
authorSimon Glass <sjg@chromium.org>
Tue, 22 Aug 2023 03:16:55 +0000 (21:16 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 31 Aug 2023 17:16:54 +0000 (13:16 -0400)
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@chromium.org>
common/board_r.c
include/initcall.h
lib/initcall.c

index 85860861f0ac4f06d01feaec73367fb23ba8daac..7c1fbc69ed6d696838cff3afde8d13cfe608322a 100644 (file)
@@ -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();
index 62d3bb67f089318e22f7a847cb887c2cfa0458d0..208effd8d13e44258a5139a544cbc7d1ffead740 100644 (file)
@@ -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
index 33b7d761dc7e1e3011ff7ee445a2aa2f434d0a03..480490ea239d050ea66d479184cc19aed3de5e04 100644 (file)
@@ -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);
+       }
+}