From ba5e3e1ed0afb3daa446d2168e5c8c9fe119cbaf Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:16:48 -0600 Subject: event: Support a simple spy record The current event spy is always passed the event context and the event. The context is always NULL for a static spy. The event is not often used. Introduce a 'simple' spy which takes no arguments. This allows us to drop the adaptation code that many of these spy records use. Update the event script to find these in the image. Signed-off-by: Simon Glass --- include/event.h | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'include/event.h') diff --git a/include/event.h b/include/event.h index daf44bf8a83..0e3222c2e24 100644 --- a/include/event.h +++ b/include/event.h @@ -99,19 +99,48 @@ struct event { union event_data data; }; +/* Flags for event spy */ +enum evspy_flags { + EVSPYF_SIMPLE = 1 << 0, +}; + /** Function type for event handlers */ typedef int (*event_handler_t)(void *ctx, struct event *event); +/** Function type for simple event handlers */ +typedef int (*event_handler_simple_t)(void); + /** * struct evspy_info - information about an event spy * * @func: Function to call when the event is activated (must be first) * @type: Event type + * @flag: Flags for this spy * @id: Event id string */ struct evspy_info { event_handler_t func; - enum event_t type; + u8 type; + u8 flags; +#if CONFIG_IS_ENABLED(EVENT_DEBUG) + const char *id; +#endif +}; + +/** + * struct evspy_info_simple - information about an event spy + * + * THis is the 'simple' record, the only difference being the handler function + * + * @func: Function to call when the event is activated (must be first) + * @type: Event type + * @flag: Flags for this spy + * @id: Event id string + */ +struct evspy_info_simple { + event_handler_simple_t func; + u8 type; + u8 flags; #if CONFIG_IS_ENABLED(EVENT_DEBUG) const char *id; #endif @@ -119,9 +148,11 @@ struct evspy_info { /* Declare a new event spy */ #if CONFIG_IS_ENABLED(EVENT_DEBUG) -#define _ESPY_REC(_type, _func) { _func, _type, #_func, } +#define _ESPY_REC(_type, _func) { _func, _type, 0, #_func, } +#define _ESPY_REC_SIMPLE(_type, _func) { _func, _type, EVSPYF_SIMPLE, #_func, } #else #define _ESPY_REC(_type, _func) { _func, _type, } +#define _ESPY_REC_SIMPLE(_type, _func) { _func, _type, EVSPYF_SIMPLE } #endif static inline const char *event_spy_id(struct evspy_info *spy) @@ -168,6 +199,12 @@ static inline const char *event_spy_id(struct evspy_info *spy) __used ll_entry_declare(struct evspy_info, _type ## _3_ ## _func, \ evspy_info) = _ESPY_REC(_type, _func) +/* Simple spy with no function arguemnts */ +#define EVENT_SPY_SIMPLE(_type, _func) \ + __used ll_entry_declare(struct evspy_info_simple, \ + _type ## _3_ ## _func, \ + evspy_info) = _ESPY_REC_SIMPLE(_type, _func) + /** * event_register - register a new spy * -- cgit v1.2.3 From fb7dfca28ad256f27f89a79f96cb4617dc54731d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:16:53 -0600 Subject: event: Export event_type_name() Export this function so it can be used with initcall debugging. Signed-off-by: Simon Glass --- include/event.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/event.h') diff --git a/include/event.h b/include/event.h index 0e3222c2e24..062b5847897 100644 --- a/include/event.h +++ b/include/event.h @@ -230,6 +230,14 @@ void event_show_spy_list(void); */ int event_manual_reloc(void); +/** + * event_type_name() - Get the name of an event type + * + * @type: Type to check + * Return: Name of event, or "(unknown)" if not known + */ +const char *event_type_name(enum event_t type); + /** * event_notify() - notify spies about an event * -- cgit v1.2.3 From 6c4cad74382aed5d6bd08b4a62b8747c98310dea Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:16:57 -0600 Subject: event: Rename EVENT_SPY to EVENT_SPY_FULL The new name makes it clearer that this is for a full spy, with access to the context and the event data. Signed-off-by: Simon Glass --- include/event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/event.h') diff --git a/include/event.h b/include/event.h index 062b5847897..b2cfd65c9f8 100644 --- a/include/event.h +++ b/include/event.h @@ -195,7 +195,7 @@ static inline const char *event_spy_id(struct evspy_info *spy) * away the linker-list entry sometimes, e.g. with the EVT_FT_FIXUP entry in * vbe_simple.c - so for now, make it global. */ -#define EVENT_SPY(_type, _func) \ +#define EVENT_SPY_FULL(_type, _func) \ __used ll_entry_declare(struct evspy_info, _type ## _3_ ## _func, \ evspy_info) = _ESPY_REC(_type, _func) -- cgit v1.2.3 From 13a7db9ab1791736c69ce49be85db5f4c32dc581 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:16:59 -0600 Subject: x86: Convert arch_fsp_init() to use events Convert this to use events instead of calling a function directly in the init sequence. Rename it to arch_fsp_init_f() to distinguish it from the one that happens after relocation. For FSPv2 nothing needs to be done here, so drop the empty function. Signed-off-by: Simon Glass --- include/event.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/event.h') diff --git a/include/event.h b/include/event.h index b2cfd65c9f8..85269aa317a 100644 --- a/include/event.h +++ b/include/event.h @@ -32,6 +32,15 @@ enum event_t { /* Init hooks */ EVT_MISC_INIT_F, + /* + * Emitted before relocation to set up Firmware Support Package + * + * Where U-Boot relies on binary blobs to handle part of the system + * init, this event can be used to set up the blobs. This is used on + * some Intel platforms + */ + EVT_FSP_INIT_F, + /* Fpga load hook */ EVT_FPGA_LOAD, -- cgit v1.2.3 From 91caa3bb89b112a1421ee2ee3661baf67c64bab9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:17:01 -0600 Subject: event: Use an event to replace last_stage_init() Add a new event which handles this function. Convert existing use of the function to use the new event instead. Make sure that EVENT is enabled by affected boards, by selecting it from the LAST_STAGE_INIT option. For x86, enable it by default since all boards need it. For controlcenterdc, inline the get_tpm() function and make sure the event is not built in SPL. Signed-off-by: Simon Glass --- include/event.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/event.h') diff --git a/include/event.h b/include/event.h index 85269aa317a..747a9f6c654 100644 --- a/include/event.h +++ b/include/event.h @@ -41,6 +41,18 @@ enum event_t { */ EVT_FSP_INIT_F, + /* + * Emitted just before jumping to the main loop + * + * Some boards need to perform initialisation immediately before control + * is passed to the command-line interpreter (e.g. for init that depend + * on later phases in the init sequence). + * + * Some parts can be only initialized if all others (like Interrupts) + * are up and running (e.g. the PC-style ISA keyboard). + */ + EVT_LAST_STAGE_INIT, + /* Fpga load hook */ EVT_FPGA_LOAD, -- cgit v1.2.3 From b53ab97150314674edc25508f4fc528be2baa73f Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 4 Sep 2023 11:19:50 -0400 Subject: event.h: Documented some newly added portions better After the merge of v2023.10-rc4 to next include/event.h needs to be fully documented in order for documentation builds to complete. Rewords two of the event_t descriptions to be docbook style and better match the rest of this enum. Fix two typos (flag->flags) in other comments. Signed-off-by: Tom Rini --- include/event.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'include/event.h') diff --git a/include/event.h b/include/event.h index c37deae9452..311df878c4a 100644 --- a/include/event.h +++ b/include/event.h @@ -94,18 +94,19 @@ enum event_t { */ EVT_MISC_INIT_F, - /* - * Emitted before relocation to set up Firmware Support Package - * + /** + * @EVT_FSP_INIT_F: + * This event is triggered before relocation to set up Firmware Support + * Package. * Where U-Boot relies on binary blobs to handle part of the system * init, this event can be used to set up the blobs. This is used on * some Intel platforms */ EVT_FSP_INIT_F, - /* - * Emitted just before jumping to the main loop - * + /** + * @EVT_LAST_STAGE_INIT: + * This event is triggered just before jumping to the main loop. * Some boards need to perform initialisation immediately before control * is passed to the command-line interpreter (e.g. for init that depend * on later phases in the init sequence). @@ -222,7 +223,7 @@ typedef int (*event_handler_simple_t)(void); * * @func: Function to call when the event is activated (must be first) * @type: Event type - * @flag: Flags for this spy + * @flags: Flags for this spy * @id: Event id string */ struct evspy_info { @@ -241,7 +242,7 @@ struct evspy_info { * * @func: Function to call when the event is activated (must be first) * @type: Event type - * @flag: Flags for this spy + * @flags: Flags for this spy * @id: Event id string */ struct evspy_info_simple { -- cgit v1.2.3 From 1ee16b268d09d2e0427e3bcc2b56b5e27bbadfa3 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 6 Sep 2023 23:29:47 +0200 Subject: common: event: Remove unused NEEDS_MANUAL_RELOC code bits The last user of the NEEDS_MANUAL_RELOC has been removed in commit 26af162ac8f8 ("arch: m68k: Implement relocation") Remove now unused NEEDS_MANUAL_RELOC code. Signed-off-by: Marek Vasut --- include/event.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'include/event.h') diff --git a/include/event.h b/include/event.h index 311df878c4a..be4cefd6ae8 100644 --- a/include/event.h +++ b/include/event.h @@ -328,16 +328,6 @@ int event_register(const char *id, enum event_t type, event_handler_t func, /** event_show_spy_list( - Show a list of event spies */ void event_show_spy_list(void); -/** - * event_manual_reloc() - Relocate event handler pointers - * - * Relocate event handler pointers for all static event spies. It is called - * during the generic board init sequence, after relocation. - * - * Return: 0 if OK - */ -int event_manual_reloc(void); - /** * event_type_name() - Get the name of an event type * -- cgit v1.2.3