public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] MIPS: board.c: fix monitor length calculations
@ 2013-01-16 14:39 Gabor Juhos
  2013-01-16 17:43 ` Gabor Juhos
  0 siblings, 1 reply; 2+ messages in thread
From: Gabor Juhos @ 2013-01-16 14:39 UTC (permalink / raw)
  To: u-boot

The current code uses the CONFIG_SYS_MONITOR_BASE
constant to calculate the size of the reserved
memory for U-Boot. The constant is also used
explicitly to calcualte the value of the
monitor_flash_len variable.

However this leads to miscalculated values if
CONFIG_SYS_TEXT_BASE != CONFIG_SYS_MONITOR_BASE.

Use the linked address of the _start symbol in
the calculations to fix the miscalculated values.

Also print the calculated monitor length if
debug is enabled.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
 arch/mips/include/asm/u-boot-mips.h |    1 +
 arch/mips/lib/board.c               |    5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/u-boot-mips.h b/arch/mips/include/asm/u-boot-mips.h
index 6f26dfa..4421696 100644
--- a/arch/mips/include/asm/u-boot-mips.h
+++ b/arch/mips/include/asm/u-boot-mips.h
@@ -5,6 +5,7 @@
  * Copyright (C) 2003 Wolfgang Denk, DENX Software Engineering, wd at denx.de
  */
 
+extern ulong _start;
 extern ulong uboot_end_data;
 extern ulong uboot_end;
 
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index d79e183..5c4d0eb 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -143,7 +143,7 @@ void board_init_f(ulong bootflag)
 	gd_t gd_data, *id;
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
-	ulong addr, addr_sp, len = (ulong)&uboot_end - CONFIG_SYS_MONITOR_BASE;
+	ulong addr, addr_sp, len = (ulong)&uboot_end - (ulong)&_start;
 	ulong *s;
 
 	/* Pointer is writable since we allocated a register for it.
@@ -261,7 +261,8 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
 
-	monitor_flash_len = (ulong)&uboot_end_data - dest_addr;
+	monitor_flash_len = (ulong)&uboot_end_data - (ulong)&_start;
+	debug("Monitor flash len: %08lX\n", monitor_flash_len);
 
 	serial_initialize();
 
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-16 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-16 14:39 [U-Boot] [PATCH] MIPS: board.c: fix monitor length calculations Gabor Juhos
2013-01-16 17:43 ` Gabor Juhos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox