Restore ability to print before relocation.
The problem with printing appears to be due to the corrupted
contents of the global data structure (allocated at a fixed
address for the before relocation use). There is no need to place
the global data structure at a fixed address, it is enough to
have it on the stack before relocation, as it is used only by the
functions in init_sequence_f table, and then passed to
board_init_r() which copies its contents immediately.
The CONFIG_SYS_INIT_GD_ADDR definition is not needed anymore and
is being removed.
BUG=chromium-os:20142
TEST=manual
. program the new image on Alex
. restart the machine
Observe the relocation address and u-boot banner printed on the
console.
Change-Id: Ifcdcd0c9da1e0ba901f319ff9b7145909300b8a1
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/7373
Reviewed-by: Stefan Reinauer <reinauer@google.com>
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index 922e137..6fd086a 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -57,7 +57,7 @@
*/
#undef XTRN_DECLARE_GLOBAL_DATA_PTR
#define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
-DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_GD_ADDR);
+DECLARE_GLOBAL_DATA_PTR;
/* Exports from the Linker Script */
extern ulong __text_start;
@@ -262,15 +262,25 @@
{
init_fnc_t **init_fnc_ptr;
+/*
+ * It's ok to have it on the stack as the stack is not going to be changed
+ * until board_init_r() is invoked, and the first thing it does - is copying
+ * *gd to the new location.
+ */
+
+ gd_t gd_data_f;
+ gd = &gd_data_f;
+ memset(gd, 0, sizeof(*gd));
+
for (init_fnc_ptr = init_sequence_f; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0)
hang();
}
- gd->flags |= GD_FLG_RELOC;
-
printf("Relocating to %p\n", (void *)gd->relocaddr);
+ gd->flags |= GD_FLG_RELOC;
+
/* Enter the relocated U-Boot! */
relocate_code(gd->start_addr_sp, gd, gd->relocaddr);
diff --git a/include/configs/coreboot.h b/include/configs/coreboot.h
index 1de3010..6cd752c 100644
--- a/include/configs/coreboot.h
+++ b/include/configs/coreboot.h
@@ -276,9 +276,6 @@
#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
#define CONFIG_SYS_MONITOR_LEN (256 * 1024)
#define CONFIG_SYS_MALLOC_LEN (0x20000 + 4 * 1024 * 1024)
-/* Address of temporary Global Data */
-#define CONFIG_SYS_INIT_GD_ADDR (256 * 1024)
-
/* allow to overwrite serial and ethaddr */
#define CONFIG_ENV_OVERWRITE