[U-Boot] [RFC] board_f: generalize code for case of no relocation

Alexey Brodkin Alexey.Brodkin at synopsys.com
Tue Dec 15 11:06:31 CET 2015


Current implementation of disabled relocation only works for EFI.

In case of GD_FLG_SKIP_RELOC jump_to_copy() will return instead of
jumping further in board_init_r() etc. And jump_to_copy() being the last
call in init_sequence_f when returning simply triggers hang() in
board_init_f(). Well for everything except ARM, SANDBOX and EFI_APP.

Not sure why ARM and SANBOX are here - I would assume it's all on
purpose but as for EFI_APP this is an essential need for getting out of
board_init_f() and jumping in board_init_r() immediately afterwards, see
efi_main().

But what if in case of no relocation we jump in board_init_r() right
from jump_to_copy()? In that case we remove one ifdef from
board_init_f() and leave a chance to seamlessly re-use disabled
relocation for other (non-EFI) cases.

Signed-off-by: Alexey Brodkin <abrodkin at synopsys.com>
---

Note I didn't test it for EFI because I don't know how to do that in
simulation, please let me know if there's a simple way to do it.

But I did test it for ARC boards (with additional patches) that enable
disabled relocation - these patches to follow once something similar to
my proposal here is implemented.

 common/board_f.c  | 11 ++++++++---
 lib/efi/efi_app.c |  2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index eac7c5e..2d60ed9 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -720,8 +720,14 @@ static int setup_reloc(void)
 
 static int jump_to_copy(void)
 {
+	/*
+	 * In case of no relocation nothing to do between "running from flash"
+	 * (init_f) and "running from ram" (init_r), so just jumping in
+	 * board_init_r().
+	 */
 	if (gd->flags & GD_FLG_SKIP_RELOC)
-		return 0;
+		board_init_r((gd_t *)gd, gd->relocaddr);
+
 	/*
 	 * x86 is special, but in a nice way. It uses a trampoline which
 	 * enables the dcache if possible.
@@ -1017,8 +1023,7 @@ void board_init_f(ulong boot_flags)
 	if (initcall_run_list(init_sequence_f))
 		hang();
 
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
-		!defined(CONFIG_EFI_APP)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
 	/* NOTREACHED - jump_to_copy() does not return */
 	hang();
 #endif
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 452ab5d..5e41b7f 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -123,7 +123,7 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
 	printf("starting\n");
 
 	board_init_f(GD_FLG_SKIP_RELOC);
-	board_init_r(NULL, 0);
+	/* board_init_r() is called in the end of board_init_f() */
 	free_memory(priv);
 
 	return EFI_SUCCESS;
-- 
2.4.3



More information about the U-Boot mailing list