[Concept,05/15] ulib: Disable the main loop

Message ID 20250905170132.182249-6-sjg@u-boot.org
State New
Headers
Series ulib: Provide test programs and documentation |

Commit Message

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

The application wants control once the U-Boot library is ready, so skip
the main loop and just return.

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

 common/board_r.c | 8 ++++++++
 include/init.h   | 4 ++++
 2 files changed, 12 insertions(+)
  

Patch

diff --git a/common/board_r.c b/common/board_r.c
index a19c3138962..d38c2304e87 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -539,6 +539,9 @@  static int dm_announce(void)
 
 static int run_main_loop(void)
 {
+	if (gd_ulib())
+		return 0;
+
 #ifdef CONFIG_SANDBOX
 	sandbox_main_loop_init();
 #endif
@@ -768,6 +771,11 @@  void board_init_r(gd_t *new_gd, ulong dest_addr)
 
 	initcall_run_r();
 
+#ifdef CONFIG_ULIB
+	if (gd_ulib())
+		return;
+#endif
+
 	/* NOTREACHED - run_main_loop() does not return */
 	hang();
 }
diff --git a/include/init.h b/include/init.h
index 2c37cef5fc0..e4b07ea48a0 100644
--- a/include/init.h
+++ b/include/init.h
@@ -277,8 +277,12 @@  struct global_data;
 void arch_setup_gd(struct global_data *gd_ptr);
 
 /* common/board_r.c */
+#ifdef CONFIG_ULIB
+void board_init_r(struct global_data *id, ulong dest_addr);
+#else
 void board_init_r(struct global_data *id, ulong dest_addr)
 	__attribute__ ((noreturn));
+#endif
 
 int cpu_init_r(void);
 int mac_read_from_eeprom(void);