aboutsummaryrefslogtreecommitdiff
path: root/common/board_r.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-08-31 15:10:42 -0400
committerTom Rini <trini@konsulko.com>2023-08-31 15:10:42 -0400
commitb8b512a45358d50bce2e17b5941c5e39b52a0594 (patch)
treef70b4d2452f8ca45025916cd85f0d1af684902bb /common/board_r.c
parentb81a024e4a37097d3dcffccb225850f8f6dc8277 (diff)
parent91caa3bb89b112a1421ee2ee3661baf67c64bab9 (diff)
Merge branch '2023-08-31-replace-more-init-hooks-with-events' into next
To quote the author: This series replaces some more of the init hooks in board_f.c and board_r.c with events. Notably it converts last_state_init() over. It also provides a 'simple' event spy, which takes no arguments. It turns out that this is quite a common case, so it is worth optimising for this, to reduce code size, before events become too commonly used. Finally, it introduces a way of emitting an event in an initcall, instead of calling a function. This is likely to be used at least as often as the functions, as we convert more of these initcalls. As part of this, the initcall code is brought back into a C file. Somehow the compiler has changed or something else, so that this does not confer any benefits now. For boards with EVENT enabled, this unfortunately results in small growth, e.g. for firefly: aarch64: (for 1/1 boards) all +114.0 data +16.0 rodata +22.0 text +76.0 arm: (for 1/1 boards) all +82.0 rodata +18.0 text +64.0 For boards without EVENT enabled the growth is smaller, e.g. nokia_rx51: arm: (for 1/1 boards) all +32.0 data +8.0 rodata -8.0 text +32.0 I cannot find a good way to avoid the latter, other than macro magic with an embedded comma (to completely remove an event entry), which seems nasty.
Diffstat (limited to 'common/board_r.c')
-rw-r--r--common/board_r.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/common/board_r.c b/common/board_r.c
index 598155c775..ad9a3cf633 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -583,7 +583,10 @@ static int run_main_loop(void)
}
/*
- * We hope to remove most of the driver-related init and do it if/when
+ * Over time we hope to remove these functions with code fragments and
+ * stub functions, and instead call the relevant function directly.
+ *
+ * We also hope to remove most of the driver-related init and do it if/when
* the driver is later used.
*
* TODO: perhaps reset the watchdog in the initcall function after each call?
@@ -770,15 +773,8 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_POST
initr_post,
#endif
-#ifdef CONFIG_LAST_STAGE_INIT
INIT_FUNC_WATCHDOG_RESET
- /*
- * Some parts can be only initialized if all others (like
- * Interrupts) are up and running (i.e. the PC-style ISA
- * keyboard).
- */
- last_stage_init,
-#endif
+ INITCALL_EVENT(EVT_LAST_STAGE_INIT),
#if defined(CFG_PRAM)
initr_mem,
#endif
@@ -810,10 +806,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();