Skip to contentSkip to conversation

common/board_f: Initialized global data for generic board

PATCH New York Sun 3 participants 6 messages May 3, 2014 – May 13, 2014

Subsystems (3)
lore
Share & tools
lore

York Sun

author
#0 lore raw

PATCH v5 1/2 common/board_f: Initialized global data for generic board

Some platforms (tested on mpc85xx, mpc86xx) use global data before calling function baord_inti_f(). The data should not be cleared later. Any arch which uses global data in generic board board_init_f() should define CONFIG_SYS_GENERIC_GLOBAL_DATA.

CC Scott Wood <[email protected]>
CC Simon Glass <[email protected]>
CC Albert ARIBAUD <[email protected]>

---
Change log

v5: Add sandbox to the list
v4: Replace with CONFIG_SYS_GENERIC_GLOBAL_DATA, a positive logic
v3: Introduce CONFIG_SYS_EARLY_GD instead of using a list
v2: Instead of adding back gd init for all PPC, preserve gd for mpc85xx and mpc86xx.

 README                            |    6 ++++++
 arch/arc/include/asm/config.h     |    2 ++
 arch/arm/include/asm/config.h     |    2 ++
 arch/mips/include/asm/config.h    |    2 ++
 arch/sandbox/include/asm/config.h |    1 +
 common/board_f.c                  |   12 +++++++-----
 6 files changed, 20 insertions(+), 5 deletions(-)
README +6 -0
index 12758dc..c66f988 100644
@@ -440,6 +440,12 @@ The following options need to be configured:
 		supported, core will start to execute uboot when wakes up.
 
 - Generic CPU options:
+		CONFIG_SYS_GENERIC_GLOBAL_DATA
+		Defines global data is initialized in generic board board_init_f().
+		If this macro is defined, global data is created and cleared in
+		generic board board_init_f(). Without this macro, architecture/board
+		should initialize global data before calling board_init_f().
+
 		CONFIG_SYS_BIG_ENDIAN, CONFIG_SYS_LITTLE_ENDIAN
 
 		Defines the endianess of the CPU. Implementation of those
arch/arc/include/asm/config.h +2 -0
index 5761def..3d331cc 100644
@@ -7,6 +7,8 @@
 #ifndef __ASM_ARC_CONFIG_H_
 #define __ASM_ARC_CONFIG_H_
 
+#define CONFIG_SYS_GENERIC_GLOBAL_DATA
+
 #define CONFIG_LMB
 
 #endif /*__ASM_ARC_CONFIG_H_ */
arch/arm/include/asm/config.h +2 -0
index abf79e5..2a20a77 100644
@@ -7,6 +7,8 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#define CONFIG_SYS_GENERIC_GLOBAL_DATA
+
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
 
arch/mips/include/asm/config.h +2 -0
index 3a891ba..1c8a42b 100644
@@ -7,6 +7,8 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#define CONFIG_SYS_GENERIC_GLOBAL_DATA
+
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
 
arch/sandbox/include/asm/config.h +1 -0
index ec7729e..6c1bff9 100644
@@ -7,6 +7,7 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#define CONFIG_SYS_GENERIC_GLOBAL_DATA
 #define CONFIG_SANDBOX_ARCH
 
 /* Used by drivers/spi/sandbox_spi.c and arch/sandbox/include/asm/state.h */
common/board_f.c +7 -5
index cbdf06f..7601a98 100644
@@ -970,20 +970,22 @@ static init_fnc_t init_sequence_f[] = {
 
 void board_init_f(ulong boot_flags)
 {
-#ifndef CONFIG_X86
+#ifdef CONFIG_SYS_GENERIC_GLOBAL_DATA
+	/*
+	 * For some archtectures, global data is initialized and used before
+	 * calling this function. The data should be preserved. For others,
+	 * CONFIG_SYS_GENERIC_GLOBAL_DATA should be defined and use the stack
+	 * here to host global data until relocation.
+	 */
 	gd_t data;
 
 	gd = &data;
-#endif
 
 	/*
 	 * Clear global data before it is accessed at debug print
 	 * in initcall_run_list. Otherwise the debug print probably
 	 * get the wrong vaule of gd->have_console.
 	 */
-#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC512X) && \
-		!defined(CONFIG_MPC83xx) && !defined(CONFIG_MPC85xx) && \
-		!defined(CONFIG_MPC86xx) && !defined(CONFIG_X86)
 	zero_global_data();
 #endif
 
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v5 2/2 common/board_f: Fix size variable

DRAM size should use 64-bit variable when the size could be more than 4GB. Caught and verified on P4080DS with 4GB DDR.

---
Change log
v5: no change since v1

 common/board_f.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/board_f.c +1 -1
index 7601a98..c268cf9 100644
@@ -194,7 +194,7 @@ static int init_func_ram(void)
 
 static int show_dram_config(void)
 {
-	ulong size;
+	unsigned long long size;
 
 #ifdef CONFIG_NR_DRAM_BANKS
 	int i;
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v5 2/2 common/board_f: Fix size variable

In reply to York Sun
Quoted 5 lines · York Sun

DRAM size should use 64-bit variable when the size could be more than 4GB. Caught and verified on P4080DS with 4GB DDR.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140512/b16528b5/attachment.pgp>
#4 lore raw

PATCH v5 1/2 common/board_f: Initialized global data for generic board

In reply to York Sun
Quoted 2 lines · York Sun

Some platforms (tested on mpc85xx, mpc86xx) use global data before calling function baord_inti_f(). The data should not be cleared later. Any arch

nit: board_init_f

Quoted 7 lines

which uses global data in generic board board_init_f() should define CONFIG_SYS_GENERIC_GLOBAL_DATA.

CC Scott Wood <[email protected]>
CC Simon Glass <[email protected]>
CC Albert ARIBAUD <[email protected]>
#5 lore raw

PATCH v5 1/2 common/board_f: Initialized global data for generic board

In reply to York Sun
Quoted 10 lines · York Sun

Some platforms (tested on mpc85xx, mpc86xx) use global data before calling function baord_inti_f(). The data should not be cleared later. Any arch which uses global data in generic board board_init_f() should define CONFIG_SYS_GENERIC_GLOBAL_DATA.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140512/842a7220/attachment.pgp>