Skip to contentSkip to conversation

microblaze: Fix bd_info pointer

PATCH New Michal Simek 1 participant 1 message Dec 21, 2010 Microblaze architecture

lore
Share & tools
lore

Michal Simek

author maintainer
#0 lore raw

PATCH v2 1/1 microblaze: Fix bd_info pointer

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.

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

This patch is fixing this scheme with GENERATED_BD_INFO_SIZE which swap global data and board info structures.

For example:

Current: gd 0xd7ffffc0, bd 0xd8000000
Fixed:   gd 0xd7ffffc0, bd 0xd7ffff90
---
 arch/microblaze/lib/board.c          |    8 +++++---
 include/configs/microblaze-generic.h |    8 ++++----
 2 files changed, 9 insertions(+), 7 deletions(-)
arch/microblaze/lib/board.c +5 -3
index eeef579..b06212e 100644
@@ -90,16 +90,18 @@ void board_init (void)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
-	gd = (gd_t *) CONFIG_SYS_GBL_DATA_OFFSET;
+	gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
+	bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
+						- GENERATED_BD_INFO_SIZE);
 	char *s;
 #if defined(CONFIG_CMD_FLASH)
 	ulong flash_size = 0;
 #endif
 	asm ("nop");	/* FIXME gd is not initialize - wait */
 	memset ((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
-	gd->bd = (bd_t *) (gd + 1);	/* At end of global data */
+	memset ((void *)bd, 0, GENERATED_BD_INFO_SIZE);
+	gd->bd = bd;
 	gd->baudrate = CONFIG_BAUDRATE;
-	bd = gd->bd;
 	bd->bi_baudrate = CONFIG_BAUDRATE;
 	bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
 	bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
include/configs/microblaze-generic.h +4 -4
index 75e4e07..090ab3b 100644
@@ -137,14 +137,14 @@
 /* global pointer */
 /* start of global data */
 #define	CONFIG_SYS_GBL_DATA_OFFSET \
-	(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_SDRAM_SIZE \
-				- GENERATED_GBL_DATA_SIZE)
+		(CONFIG_SYS_SDRAM_SIZE - 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)
+		(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
+			- CONFIG_SYS_MONITOR_LEN - GENERATED_BD_INFO_SIZE)
 #define	CONFIG_SYS_MONITOR_END \
 			(CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
 #define	CONFIG_SYS_MALLOC_LEN		SIZE
Signature · 1 line
1.5.5.6