aboutsummaryrefslogtreecommitdiff
path: root/common/event.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/event.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/event.c')
-rw-r--r--common/event.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/common/event.c b/common/event.c
index 3224e28122..4845104b17 100644
--- a/common/event.c
+++ b/common/event.c
@@ -35,6 +35,8 @@ const char *const type_name[] = {
/* init hooks */
"misc_init_f",
+ "fsp_init_r",
+ "last_stage_init",
/* Fpga load hook */
"fpga_load",
@@ -49,7 +51,7 @@ const char *const type_name[] = {
_Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
#endif
-static const char *event_type_name(enum event_t type)
+const char *event_type_name(enum event_t type)
{
#if CONFIG_IS_ENABLED(EVENT_DEBUG)
return type_name[type];
@@ -71,7 +73,14 @@ static int notify_static(struct event *ev)
log_debug("Sending event %x/%s to spy '%s'\n", ev->type,
event_type_name(ev->type), event_spy_id(spy));
- ret = spy->func(NULL, ev);
+ if (spy->flags & EVSPYF_SIMPLE) {
+ const struct evspy_info_simple *simple;
+
+ simple = (struct evspy_info_simple *)spy;
+ ret = simple->func();
+ } else {
+ ret = spy->func(NULL, ev);
+ }
/*
* TODO: Handle various return codes to