[Concept,07/24] boot: Provide a Kconfig to enable faking the boot

Message ID 20250922180116.3088502-8-sjg@u-boot.org
State New
Headers
Series boot: efi: Various improvements to booting with the EFI app |

Commit Message

Simon Glass Sept. 22, 2025, 6 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

This feature was designed for tracing but can be useful for debugging
too, since it is possible to examine the state of the system just before
handing off to the OS.

Provide a separate CONFIG_BOOTM_FAKE_GO option to allow this feature to
be used separate from tracing. Enable it for the EFI app.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/Kconfig | 8 ++++++++
 boot/bootm.c | 5 ++---
 2 files changed, 10 insertions(+), 3 deletions(-)
  

Patch

diff --git a/boot/Kconfig b/boot/Kconfig
index 13036fd3a09..8f0cecfb1f6 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -453,6 +453,14 @@  config BOOTM_VXWORKS
 	help
 	  Support booting VxWorks images via the bootm command.
 
+config BOOTM_FAKE_GO
+	bool "Support faking a boot, for debugging purposes"
+	default y if TRACE || EFI_APP
+	help
+	  Provides a way to fake the boot, so that almost everything is done
+	  to prepare for the boot, but the jump to the OS does not actually
+	  happen. This can be useful for debugging.
+
 endif  # BOOT
 
 config PXE_UTILS
diff --git a/boot/bootm.c b/boot/bootm.c
index a536737db09..0981494a2b8 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1260,9 +1260,9 @@  int bootm_run_states(struct bootm_info *bmi, int states)
 		ret = boot_fn(BOOTM_STATE_OS_PREP, bmi);
 	}
 
-#ifdef CONFIG_TRACE
 	/* Pretend to run the OS, then run a user command */
-	if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
+	if (IS_ENABLED(CONFIG_BOOTM_FAKE_GO) && !ret &&
+	    (states & BOOTM_STATE_OS_FAKE_GO)) {
 		char *cmd_list = env_get("fakegocmd");
 
 		log_debug("fake_go\n");
@@ -1270,7 +1270,6 @@  int bootm_run_states(struct bootm_info *bmi, int states)
 		if (!ret && cmd_list)
 			ret = run_command_list(cmd_list, -1, 0);
 	}
-#endif
 
 	/* Check for unsupported subcommand. */
 	if (ret) {