It is a common need in U-Boot to have one subsystem notify another when something happens. An example is reading a partition table when a new block device is set up.
It is also common to add weak functions and 'hook' functions to modify how U-Boot works. See for example ft_board_setup() and the like. U-Boot would benefit from a generic mechanism to handle these cases, with the ability to hook into various 'events' in a subsystem-independent and transparent way. This series provides a way to create and dispatch events, with a way of registering a 'spy' which watches for events of different types. This allows 'hook' functions to be created in a generic way. It also includes a script to list the hooks in an image, which is a bit easier to debug than weak functions, as well as an 'event' command to do the same from within U-Boot. These 'static' events can be used to replace hooks like misc_init_f(), for example. Also included is basic support for 'dynamic' events, where a spy can be registered at runtime. The need for this is still being figured out. Changes in v2: - Add a 'used' attribute to avoid LTO dropping the code - Update keymile pg-wcom boards also - Make the sandbox function static - Convert arch/arm/mach-imx/imx8/cpu.c also - Add DM_EVENT to ARCH_IMX8 too - Tidy up galileo defconfig and rename quark_init_dm() - Make a few more of the functions static - Add a weak function for spl - Update for patman snake-case change - Use a regular expression in the test to avoid dependency on build dir Simon Glass (12): Makefile: Allow LTO to be disabled for a build sandbox: start: Sort the header files binman: Expand elf support a little event: Add basic support for events event: Add a simple test event: Set up the event system on start-up event: Add events for device probe/remove event: Convert misc_init_f() to use events event: Convert arch_cpu_init_dm() to use events event: Add a command event: Add a script to decode the event-spy list event: Add documentation Tim Harvey (1): phy: nop-phy: Fix phy reset if no reset-gpio defined MAINTAINERS | 10 + Makefile | 18 +- arch/Kconfig | 3 + arch/arm/Kconfig | 4 + arch/arm/config.mk | 4 +- arch/arm/include/asm/global_data.h | 2 +- arch/arm/mach-imx/imx8/cpu.c | 4 +- arch/arm/mach-imx/imx8m/soc.c | 4 +- arch/arm/mach-imx/imx8ulp/soc.c | 4 +- arch/arm/mach-omap2/am33xx/board.c | 4 +- arch/arm/mach-omap2/hwinit-common.c | 5 +- arch/mips/Kconfig | 1 + arch/mips/mach-pic32/cpu.c | 4 +- arch/nios2/cpu/cpu.c | 4 +- arch/riscv/cpu/cpu.c | 5 +- arch/riscv/include/asm/system.h | 5 + arch/riscv/lib/spl.c | 3 +- arch/sandbox/cpu/start.c | 8 +- arch/x86/cpu/baytrail/cpu.c | 4 +- arch/x86/cpu/broadwell/cpu.c | 4 +- arch/x86/cpu/ivybridge/cpu.c | 4 +- arch/x86/cpu/quark/quark.c | 4 +- arch/x86/include/asm/fsp2/fsp_api.h | 8 + arch/x86/lib/fsp2/fsp_init.c | 4 +- arch/x86/lib/spl.c | 5 +- arch/x86/lib/tpl.c | 10 - board/google/chromebook_coral/coral.c | 7 +- board/keymile/kmcent2/kmcent2.c | 4 +- .../keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c | 5 +- cmd/Kconfig | 8 + cmd/Makefile | 1 + cmd/event.c | 27 +++ common/Kconfig | 37 ++- common/Makefile | 2 + common/board_f.c | 13 +- common/board_r.c | 1 + common/event.c | 196 ++++++++++++++++ common/log.c | 1 + configs/chromebook_coral_defconfig | 1 + configs/kmcent2_defconfig | 2 +- configs/pg_wcom_expu1_defconfig | 1 + configs/pg_wcom_expu1_update_defconfig | 1 + configs/pg_wcom_seli8_defconfig | 1 + configs/pg_wcom_seli8_update_defconfig | 1 + configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - configs/sandbox_flattree_defconfig | 1 - configs/sandbox_spl_defconfig | 1 - configs/tools-only_defconfig | 1 - doc/build/gcc.rst | 17 ++ doc/develop/event.rst | 66 ++++++ doc/develop/index.rst | 1 + doc/usage/event.rst | 49 ++++ doc/usage/index.rst | 1 + drivers/core/Kconfig | 10 + drivers/core/device-remove.c | 8 + drivers/core/device.c | 9 + drivers/core/root.c | 5 + drivers/phy/nop-phy.c | 12 +- include/asm-generic/global_data.h | 13 ++ include/configs/km/pg-wcom-ls102xa.h | 2 - include/dm/device-internal.h | 10 + include/event.h | 210 ++++++++++++++++++ include/event_internal.h | 35 +++ include/init.h | 12 - include/log.h | 2 + scripts/event_dump.py | 115 ++++++++++ test/common/Makefile | 1 + test/common/event.c | 85 +++++++ test/py/tests/test_event_dump.py | 20 ++ test/test-main.c | 4 + tools/binman/elf.py | 58 ++++- 72 files changed, 1108 insertions(+), 86 deletions(-) create mode 100644 cmd/event.c create mode 100644 common/event.c create mode 100644 doc/develop/event.rst create mode 100644 doc/usage/event.rst create mode 100644 include/event.h create mode 100644 include/event_internal.h create mode 100755 scripts/event_dump.py create mode 100644 test/common/event.c create mode 100644 test/py/tests/test_event_dump.py -- 2.35.1.616.g0bdcbb4464-goog