diff mbox

[U-Boot,2/2] microblaze: Fix bdiinfo pointer

Message ID 1292933384-3032-3-git-send-email-monstr@monstr.eu
State Changes Requested
Headers show

Commit Message

Michal Simek Dec. 21, 2010, 12:09 p.m. UTC
Patch "Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value"
(sha1: 25ddd1fb0a2281b182529afbc8fda5de2dc16d96)
introduce GENERATED_GBL_DATA_SIZE which is sizeof aligned gd_t
(currently 0x40).
Microblaze configs used 0x40(128) because this place also contained
board info structure which lies on the top of ram.

This patch is fixing this scheme by extending CONFIG_SYS_GBL_DATA_OFFSET
value. Doubled GENERATED_GBL_DATA_SIZE size is enough to store
gd_t and bd_t structures.

U-Boot is placed to the top of the ram (for example 0xd7ffffff)
and bd structure was moved out of ram.

For example:
Current: gd 0xd7ffffc0, bd 0xd8000000
Fixed:   gd 0xd7ffff80, bd 0xd7ffffc0

Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/lib/board.c          |    2 +-
 include/configs/microblaze-generic.h |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Wolfgang Denk Dec. 21, 2010, 12:26 p.m. UTC | #1
Dear Michal Simek,

In message <1292933384-3032-3-git-send-email-monstr@monstr.eu> you wrote:
> Patch "Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value"
> (sha1: 25ddd1fb0a2281b182529afbc8fda5de2dc16d96)
> introduce GENERATED_GBL_DATA_SIZE which is sizeof aligned gd_t
> (currently 0x40).
> Microblaze configs used 0x40(128) because this place also contained
> board info structure which lies on the top of ram.
> 
> This patch is fixing this scheme by extending CONFIG_SYS_GBL_DATA_OFFSET
> value. Doubled GENERATED_GBL_DATA_SIZE size is enough to store
> gd_t and bd_t structures.

No, I will not accept this.

Please do not make assumptions abouth the size of bd_t compared to
GENERATED_GBL_DATA_SIZE.  Use the correct size instead, as you can
easily get using the sizeof() operator (plus some padding eventually
to guarantee alignment, if needed).

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index eeef579..e215684 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -96,7 +96,7 @@  void board_init (void)
 	ulong flash_size = 0;
 #endif
 	asm ("nop");	/* FIXME gd is not initialize - wait */
-	memset ((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
+	memset ((void *)gd, 0, 2 * GENERATED_GBL_DATA_SIZE); /* gd/bd space */
 	gd->bd = (bd_t *) (gd + 1);	/* At end of global data */
 	gd->baudrate = CONFIG_BAUDRATE;
 	bd = gd->bd;
diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index 75e4e07..ec152bf 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -135,14 +135,17 @@ 
 #define	CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_SDRAM_BASE + 0x1000)
 
 /* global pointer */
+/* Allocate 2 * GENERATED_GBL_DATA_SIZE (0x40) size for global data and
+ * board info structure(size 0x24). Would be better to use sizeof but
+ * this requires more changes to asm code */
 /* start of global data */
 #define	CONFIG_SYS_GBL_DATA_OFFSET \
 	(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_SDRAM_SIZE \
-				- GENERATED_GBL_DATA_SIZE)
+				- 2 * GENERATED_GBL_DATA_SIZE)
 
 /* monitor code */
 #define	SIZE				0x40000
-#define	CONFIG_SYS_MONITOR_LEN		(SIZE - GENERATED_GBL_DATA_SIZE)
+#define	CONFIG_SYS_MONITOR_LEN		SIZE
 #define	CONFIG_SYS_MONITOR_BASE	\
 			(CONFIG_SYS_GBL_DATA_OFFSET - CONFIG_SYS_MONITOR_LEN)
 #define	CONFIG_SYS_MONITOR_END \