Each arch does something slightly different before booting the OS. Some archs even do different things depending on the CPU type.
It is quite hard to know what actually happens in the final milliseconds before the OS boot. This series attempts to start cleaning up U-Boot in this area. The basic intent is to create a new bootm_final() function which can be called by all archs. It provides some flags for a couple of necessary variations but otherwise it is generic. RISC-V, x86 and ARM are converted over to use this new function. For consistency, EFI loader is converted as well. A noteable change is that EFI_LOADER now does bootstage processing before boot, if enabled, thus producing a report. There is also a patch to drop EFI_GRUB_ARM32_WORKAROUND, as discussed recently on the mailing list. Future work could take this a little further: - Drop board_quiesce_devices() and rely on driver model for that - Similarly with udc_disconnect() - Look at converting EFI to use the same function Also, the comment for cleanup_before_linux() could use more details as to what it is supposed to do, to reduce the number of arch-specific variations. It currently does different things on differents archs and is mostly uncommented (apart from an ARM-specific note in a README). Ideally it would be commented with exactly what it should do, ideally at a high level so it is not just arch-specific. While some of these arch-specific differences are necessary, some are just due to the changes to code over time. Changes in v2: - Replace 'efi: Make use of bootm_final()' with a non-EFI patch - Drop comment about EFI - Drop the EFI change - Drop the call to udc_disconnect() - Drop the EFI_LOADER change - Drop patch 'efi: Drop EFI_GRUB_ARM32_WORKAROUND' - Update cover message to reflect dropping the EFI patches, etc. Simon Glass (9): boot: Create a function for final pre-boot steps bootm: Remove active devices in bootm_final() bootm: Add a message when booting bootstage: Add some missing dummy functions bootm: Do bootstage processing in bootm_final() x86: Call bootm_final() riscv: Drop board_quiesce_devices() riscv: Call bootm_final() x86: Add cleanup_before_linux() MAINTAINERS | 1 + arch/riscv/include/asm/u-boot-riscv.h | 1 - arch/riscv/lib/bootm.c | 24 +------------------ arch/x86/cpu/cpu.c | 5 ++++ arch/x86/lib/bootm.c | 14 +---------- boot/Makefile | 2 +- boot/bootm_final.c | 34 +++++++++++++++++++++++++++ include/bootm.h | 17 ++++++++++++++ include/bootstage.h | 8 +++++++ 9 files changed, 68 insertions(+), 38 deletions(-) create mode 100644 boot/bootm_final.c -- 2.43.0 base-commit: 8fd76675efbe7af785ccc1ba1ac8b9f7e10f6715 branch: bootma-us2

