From: Simon Glass <[email protected]> There are various functions which announce that booting is imminent and do related preparation. Most of these are arch-specific.
In practice, most archs do a similar thing. It would be better to have a common function, with perhaps some events for things that are really arch- and board-specific. Create a new bootm_final() function with the common pre-boot steps: printing the "Starting kernel" message, recording bootstage data, optionally writing bootstage to the FDT and printing a report, and removing active devices. Be careful to avoid using BIT() macros which are not available with host tools. Signed-off-by: Simon Glass <[email protected]> --- Changes in v3: - Fix "the a" typo - Introduce with all common functionality (not empty) - Put in bootm.c instead of a separate file - Squash in patches 2, 3 and 5 from v2 boot/bootm.c | 20 ++++++++++++++++++++ include/bootm.h | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/boot/bootm.c b/boot/bootm.c index 4bdca22ea8c..3a69cc0deb0 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -7,6 +7,7 @@ #ifndef USE_HOSTCC #include <bootm.h> #include <bootstage.h> +#include <dm/root.h> #include <cli.h> #include <command.h> #include <cpu_func.h> @@ -1194,6 +1195,25 @@ void __weak switch_to_non_secure_mode(void) { } +void bootm_final(enum bootm_final_t flags) +{ + printf("\nStarting kernel ...\n\n"); + + bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel"); + + if (IS_ENABLED(CONFIG_BOOTSTAGE_FDT) && IS_ENABLED(CONFIG_CMD_FDT)) + bootstage_fdt_add_report(); + if (IS_ENABLED(CONFIG_BOOTSTAGE_REPORT)) + bootstage_report(); + + /* + * Call remove function of all devices with a removal flag set. + * This may be useful for last-stage operations, like cancelling + * of DMA operation or releasing device internal buffers. + */ + dm_remove_devices_active(); +} + #else /* USE_HOSTCC */ #if defined(CONFIG_FIT_SIGNATURE) diff --git a/include/bootm.h b/include/bootm.h index 4060cec7fc0..8890c37893f 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -16,6 +16,16 @@ struct cmd_tbl; #define BOOTM_ERR_OVERLAP (-2) #define BOOTM_ERR_UNIMPLEMENTED (-3) +/** + * enum bootm_final_t - flags to control bootm_final() + * + * @BOOTM_FINAL_FAKE: true to do everything except actually boot; it then + * returns to the caller + */ +enum bootm_final_t { + BOOTM_FINAL_FAKE = 1 << 0, +}; + /** * struct bootm_info() - information used when processing images to boot * @@ -321,4 +331,14 @@ void zimage_dump(struct boot_params *base_ptr, bool show_cmdline); */ int bootm_boot_start(ulong addr, const char *cmdline); +/** + * bootm_final() - Announce and do cleanup before boot + * + * This performs the common pre-boot steps: printing the "Starting kernel" + * message, recording bootstage data, and removing active devices. + * + * @flags: Flags to control what this function does + */ +void bootm_final(enum bootm_final_t flags); + #endif -- 2.43.0

