[PATCH 01/10] boot: Create a function for final pre-boot steps

Simon Glass sjg at chromium.org
Wed Jan 7 01:31:18 CET 2026


From: Simon Glass <sjg at chromium.org>

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 the 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 function for this. For now, nothing uses it. Be careful to
avoid using BIT() macros which are not available with host tools.

Signed-off-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Simon Glass <simon.glass at canonical.com>
---

 MAINTAINERS        |  1 +
 boot/Makefile      |  2 +-
 boot/bootm_final.c | 12 ++++++++++++
 include/bootm.h    | 17 +++++++++++++++++
 4 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 boot/bootm_final.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 27ce73d83f4..f0bd2562f77 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -981,6 +981,7 @@ M:	Simon Glass <sjg at chromium.org>
 S:	Maintained
 F:	boot/bootdev*.c
 F:	boot/bootflow.c
+F:	boot/bootm_final.c
 F:	boot/bootmeth*.c
 F:	boot/bootstd.c
 F:	cmd/bootdev.c
diff --git a/boot/Makefile b/boot/Makefile
index 7fb56e7ef37..12477fabe28 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
 
 endif
 
-obj-y += image.o image-board.o
+obj-y += image.o image-board.o bootm_final.o
 
 obj-$(CONFIG_ANDROID_AB) += android_ab.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o
diff --git a/boot/bootm_final.c b/boot/bootm_final.c
new file mode 100644
index 00000000000..15ddbbe5e74
--- /dev/null
+++ b/boot/bootm_final.c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Cleanup before handing off to the OS
+ *
+ * Copyright 2025 Simon Glass <sjg at chromium.org>
+ */
+
+#include <bootm.h>
+
+void bootm_final(enum bootm_final_t flags)
+{
+}
diff --git a/include/bootm.h b/include/bootm.h
index 4060cec7fc0..32711eabb2e 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,11 @@ 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
+ *
+ * @flags: Flags to control what this function does
+ */
+void bootm_final(enum bootm_final_t flags);
+
 #endif
-- 
2.43.0



More information about the U-Boot mailing list