[U-Boot] [PATCH v5 3/4] generic board patch of manual reloc and zero gd_t

fenghua at phytium.com.cn fenghua at phytium.com.cn
Sat Aug 24 03:06:27 CEST 2013


From: David Feng <fenghua at phytium.com.cn>

1. function board_init_f in board_f.c should firstly zero gd_t structure
   before it call initcall_run_list, otherwise the debug print will go run
   if DEBUG is defined. Because the printf function will use global data
   to determine whether serial port is initialized and could be written.
2. function board_init_r in board_r.c should firstly relocate init_sequence_r
   table before it call initcall_run_list. Command table also should be relocated.

Signed-off-by: David Feng <fenghua at phytium.com.cn>
---
Changes for v4:
  - fix the generic board_f.c, remove zero_global_data from init_sequence_f array
    and move it to board_init_f() function with CONFIG_X86 switch. The previous
    fixup is inaccurate.

 common/board_f.c |   19 +++++++++++++------
 common/board_r.c |   17 +++++++++++++++++
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 0ada1af..98e24c3 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -458,7 +458,11 @@ static int reserve_round_4k(void)
 static int reserve_mmu(void)
 {
 	/* reserve TLB table */
+#ifndef CONFIG_ARMV8
 	gd->arch.tlb_size = 4096 * 4;
+#else
+	gd->arch.tlb_size = 0x10000;
+#endif
 	gd->relocaddr -= gd->arch.tlb_size;
 
 	/* round down to next 64 kB limit */
@@ -610,7 +614,7 @@ static int reserve_stacks(void)
 	 * TODO(sjg at chromium.org): Perhaps create arch_reserve_stack()
 	 * to handle this and put in arch/xxx/lib/stack.c
 	 */
-# ifdef CONFIG_ARM
+# if defined(CONFIG_ARM) && !defined(CONFIG_ARMV8)
 #  ifdef CONFIG_USE_IRQ
 	gd->start_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
 	debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
@@ -807,11 +811,6 @@ static int mark_bootstage(void)
 }
 
 static init_fnc_t init_sequence_f[] = {
-#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC512X) && \
-		!defined(CONFIG_MPC83xx) && !defined(CONFIG_MPC85xx) && \
-		!defined(CONFIG_MPC86xx) && !defined(CONFIG_X86)
-	zero_global_data,
-#endif
 #ifdef CONFIG_SANDBOX
 	setup_ram_buf,
 #endif
@@ -1005,6 +1004,14 @@ void board_init_f(ulong boot_flags)
 	gd = &data;
 #endif
 
+	/*
+	 * Zero gd_t first, otherwise the debug print in initcall_run_list
+	 * function before zero_global_data is called will go wrong.
+	 */
+#ifndef CONFIG_X86
+	zero_global_data();
+#endif
+
 	gd->flags = boot_flags;
 
 	if (initcall_run_list(init_sequence_f))
diff --git a/common/board_r.c b/common/board_r.c
index 86ca1cb..1b4bdd2 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -157,6 +157,13 @@ static int initr_reloc_global_data(void)
 	 */
 	gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
 #endif
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+	/*
+	 * We have to relocate the command table manually
+	 */
+	fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+			ll_entry_count(cmd_tbl_t, cmd));
+#endif /* CONFIG_NEEDS_MANUAL_RELOC */
 	return 0;
 }
 
@@ -899,6 +906,7 @@ init_fnc_t init_sequence_r[] = {
 	initr_modem,
 #endif
 	run_main_loop,
+	NULL,
 };
 
 void board_init_r(gd_t *new_gd, ulong dest_addr)
@@ -906,6 +914,15 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 #ifndef CONFIG_X86
 	gd = new_gd;
 #endif
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+	/*
+	 * We have to relocate the init_sequence_r table manually
+	 */
+	init_fnc_t	*init_fnc_ptr;
+	for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr)
+		*init_fnc_ptr = (init_fnc_t *)((unsigned long)(*init_fnc_ptr) + gd->reloc_off);
+#endif /* CONFIG_NEEDS_MANUAL_RELOC */
+
 	if (initcall_run_list(init_sequence_r))
 		hang();
 
-- 
1.7.9.5




More information about the U-Boot mailing list