[U-Boot] [PATCH 13/32] sandbox: Allow return from board_init_f()

Simon Glass sjg at chromium.org
Sun Nov 10 18:26:59 CET 2013


The execution flow becomes easier if we can return from board_init_f()
as ARM does. We can control things from start.c instead of having to
call back into that file from other places.

Signed-off-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Simon Glass <sjg at chromium.org>
---
 arch/sandbox/cpu/start.c | 11 ++++++-----
 common/board_f.c         |  8 +++-----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 951ac63..895c4d8 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -10,6 +10,8 @@
 
 #include <os.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int sandbox_early_getopt_check(void)
 {
 	struct sandbox_state *state = state_get_current();
@@ -109,12 +111,11 @@ int main(int argc, char *argv[])
 	if (os_parse_args(state, argc, argv))
 		return 1;
 
-	/*
-	 * Do pre- and post-relocation init, then start up U-Boot. This will
-	 * never return.
-	 */
+	/* Do pre- and post-relocation init */
 	board_init_f(0);
 
-	/* NOTREACHED - board_init_f() does not return */
+	board_init_r(gd->new_gd, 0);
+
+	/* NOTREACHED - board_init_r() does not return */
 	return 0;
 }
diff --git a/common/board_f.c b/common/board_f.c
index f8b8fa2..6e971f8 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -766,7 +766,7 @@ static int setup_reloc(void)
 }
 
 /* ARM calls relocate_code from its crt0.S */
-#if !defined(CONFIG_ARM)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
 
 static int jump_to_copy(void)
 {
@@ -786,8 +786,6 @@ static int jump_to_copy(void)
 	 * (CPU cache)
 	 */
 	board_init_f_r_trampoline(gd->start_addr_sp);
-#elif defined(CONFIG_SANDBOX)
-	board_init_r(gd->new_gd, 0);
 #else
 	relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
 #endif
@@ -989,7 +987,7 @@ static init_fnc_t init_sequence_f[] = {
 	INIT_FUNC_WATCHDOG_RESET
 	reloc_fdt,
 	setup_reloc,
-#ifndef CONFIG_ARM
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
 	jump_to_copy,
 #endif
 	NULL,
@@ -1008,7 +1006,7 @@ void board_init_f(ulong boot_flags)
 	if (initcall_run_list(init_sequence_f))
 		hang();
 
-#ifndef CONFIG_ARM
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
 	/* NOTREACHED - jump_to_copy() does not return */
 	hang();
 #endif
-- 
1.8.4.1



More information about the U-Boot mailing list