Patchwork [U-Boot] nios2: move gd and bd into BSS

login
register
mail settings
Submitter Thomas Chou
Date March 1, 2012, 7:09 a.m.
Message ID <1330585745-19431-1-git-send-email-thomas@wytron.com.tw>
Download mbox | patch
Permalink /patch/143929/
State Superseded
Headers show

Comments

Thomas Chou - March 1, 2012, 7:09 a.m.
As suggested by Graeme Russ, move gd and bd data structrures
to BSS instead of calculating the locations around the stack
and heap.

CC: Graeme Russ <graeme.russ@gmail.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: Alex Hornung <alex@alexhornung.com>
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
For u-boot.

 arch/nios2/lib/board.c          |   13 ++++++-------
 include/configs/nios2-generic.h |    8 ++------
 2 files changed, 8 insertions(+), 13 deletions(-)
Mike Frysinger - March 1, 2012, 5:17 p.m.
On Thursday 01 March 2012 02:09:05 Thomas Chou wrote:
> --- a/arch/nios2/lib/board.c
> +++ b/arch/nios2/lib/board.c
>
> +gd_t gd_data;
> +bd_t bd_data;

mark both static

> --- a/include/configs/nios2-generic.h
> +++ b/include/configs/nios2-generic.h
>
>   * MEMORY ORGANIZATION
>   *	-Monitor at top of sdram.
>   *	-The heap is placed below the monitor
> - *	-Global data is placed below the heap.
> - *	-The stack is placed below global data (&grows down).
> + *	-The stack is placed below the heap (&grows down).

you've got a tab after ther "*" but none of the previous lines do ...
-mike

Patch

diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
index 65de26e..19e688a 100644
--- a/arch/nios2/lib/board.c
+++ b/arch/nios2/lib/board.c
@@ -83,21 +83,20 @@  init_fnc_t *init_sequence[] = {
 
 
 /***********************************************************************/
+gd_t gd_data;
+bd_t bd_data;
+
 void board_init (void)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
 
-	/* Pointer is writable since we allocated a register for it.
-	 * Nios treats CONFIG_SYS_GBL_DATA_OFFSET as an address.
-	 */
-	gd = (gd_t *)CONFIG_SYS_GBL_DATA_OFFSET;
+	/* Pointer is writable since we allocated a register for it. */
+	gd = &gd_data;
 	/* compiler optimization barrier needed for GCC >= 3.4 */
 	__asm__ __volatile__("": : :"memory");
 
-	memset( gd, 0, GENERATED_GBL_DATA_SIZE );
-
-	gd->bd = (bd_t *)(gd+1);	/* At end of global data */
+	gd->bd = &bd_data;
 	gd->baudrate = CONFIG_BAUDRATE;
 	gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
 
diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h
index 17017a5..dccb66c 100644
--- a/include/configs/nios2-generic.h
+++ b/include/configs/nios2-generic.h
@@ -119,8 +119,7 @@ 
  * MEMORY ORGANIZATION
  *	-Monitor at top of sdram.
  *	-The heap is placed below the monitor
- *	-Global data is placed below the heap.
- *	-The stack is placed below global data (&grows down).
+ *	-The stack is placed below the heap (&grows down).
  */
 #define CONFIG_MONITOR_IS_IN_RAM
 #define CONFIG_SYS_MONITOR_LEN		0x40000	/* Reserve 256k */
@@ -130,10 +129,7 @@ 
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 0x20000)
 #define CONFIG_SYS_MALLOC_BASE		(CONFIG_SYS_MONITOR_BASE - \
 					 CONFIG_SYS_MALLOC_LEN)
-#define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_MALLOC_BASE - \
-					 GENERATED_GBL_DATA_SIZE - \
-					 GENERATED_BD_INFO_SIZE)
-#define CONFIG_SYS_INIT_SP		CONFIG_SYS_GBL_DATA_OFFSET
+#define CONFIG_SYS_INIT_SP		CONFIG_SYS_MALLOC_BASE
 
 /*
  * MISC