From: Stefan Roese Date: Mon, 11 May 2009 13:50:12 +0000 (+0200) Subject: lib_arch/board.c: Move malloc initialization before flash_init() X-Git-Tag: v2009.08-rc1~153^2~127 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c790b04d230363d03939dc008bcc80f3ba4de1ae;p=oweals%2Fu-boot.git lib_arch/board.c: Move malloc initialization before flash_init() This patch moves the malloc initialization before calling flash_init(). Upcoming changes to the NOR FLASH common CFI driver with optional MTD infrastructure and MTD concatenation support will call malloc(). And nothing really speaks against enabling malloc just a little earlier in the boot stage. Some architectures already enable malloc before calling flash_init() so they don't need any changes here. Signed-off-by: Stefan Roese Cc: Wolfgang Denk Cc: Mike Frysinger Cc: Scott McNutt Cc: Shinya Kuribayashi Cc: Nobuhiro Iwamatsu Cc: Daniel Hellstrom Cc: Jean-Christophe PLAGNIOL-VILLARD Cc: John Rigby --- diff --git a/lib_arm/board.c b/lib_arm/board.c index 5d05d9b927..e3040acdc6 100644 --- a/lib_arm/board.c +++ b/lib_arm/board.c @@ -316,6 +316,9 @@ void start_armboot (void) } } + /* armboot_start is defined in the board-specific linker script */ + mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN); + #ifndef CONFIG_SYS_NO_FLASH /* configure available FLASH banks */ display_flash_config (flash_init ()); @@ -350,9 +353,6 @@ void start_armboot (void) } #endif /* CONFIG_LCD */ - /* armboot_start is defined in the board-specific linker script */ - mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN); - #if defined(CONFIG_CMD_NAND) puts ("NAND: "); nand_init(); /* go init the NAND */ diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c index 49465d2a05..047f16418f 100644 --- a/lib_blackfin/board.c +++ b/lib_blackfin/board.c @@ -324,6 +324,10 @@ void board_init_r(gd_t * id, ulong dest_addr) post_reloc(); #endif + /* initialize malloc() area */ + mem_malloc_init(); + malloc_bin_reloc(); + #if !defined(CONFIG_SYS_NO_FLASH) /* Initialize the flash and protect u-boot by default */ extern flash_info_t flash_info[]; @@ -341,9 +345,6 @@ void board_init_r(gd_t * id, ulong dest_addr) bd->bi_flashsize = 0; bd->bi_flashoffset = 0; #endif - /* initialize malloc() area */ - mem_malloc_init(); - malloc_bin_reloc(); #ifdef CONFIG_CMD_NAND puts("NAND: "); diff --git a/lib_m68k/board.c b/lib_m68k/board.c index db45b00b1e..584d1fff32 100644 --- a/lib_m68k/board.c +++ b/lib_m68k/board.c @@ -519,6 +519,10 @@ void board_init_r (gd_t *id, ulong dest_addr) */ trap_init (CONFIG_SYS_SDRAM_BASE); + /* initialize malloc() area */ + mem_malloc_init (); + malloc_bin_reloc (); + #if !defined(CONFIG_SYS_NO_FLASH) puts ("FLASH: "); @@ -563,10 +567,6 @@ void board_init_r (gd_t *id, ulong dest_addr) WATCHDOG_RESET (); - /* initialize malloc() area */ - mem_malloc_init (); - malloc_bin_reloc (); - #ifdef CONFIG_SPI # if !defined(CONFIG_ENV_IS_IN_EEPROM) spi_init_f (); diff --git a/lib_mips/board.c b/lib_mips/board.c index 061901e972..f8ac234d10 100644 --- a/lib_mips/board.c +++ b/lib_mips/board.c @@ -370,6 +370,10 @@ void board_init_r (gd_t *id, ulong dest_addr) bd = gd->bd; + /* initialize malloc() area */ + mem_malloc_init(); + malloc_bin_reloc(); + #ifndef CONFIG_SYS_NO_FLASH /* configure available FLASH banks */ size = flash_init(); @@ -384,10 +388,6 @@ void board_init_r (gd_t *id, ulong dest_addr) bd->bi_flashoffset = 0; #endif - /* initialize malloc() area */ - mem_malloc_init(); - malloc_bin_reloc(); - #ifdef CONFIG_CMD_NAND puts ("NAND: "); nand_init (); /* go init the NAND */ diff --git a/lib_nios/board.c b/lib_nios/board.c index 63e79aec28..9d8eea7962 100644 --- a/lib_nios/board.c +++ b/lib_nios/board.c @@ -142,12 +142,14 @@ void board_init (void) } } + WATCHDOG_RESET (); + mem_malloc_init(); + malloc_bin_reloc(); + WATCHDOG_RESET (); bd->bi_flashsize = flash_init(); WATCHDOG_RESET (); - mem_malloc_init(); - malloc_bin_reloc(); env_relocate(); bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); diff --git a/lib_nios2/board.c b/lib_nios2/board.c index 70fad1b870..0677e99995 100644 --- a/lib_nios2/board.c +++ b/lib_nios2/board.c @@ -148,12 +148,14 @@ void board_init (void) } } + WATCHDOG_RESET (); + mem_malloc_init(); + malloc_bin_reloc(); + WATCHDOG_RESET (); bd->bi_flashsize = flash_init(); WATCHDOG_RESET (); - mem_malloc_init(); - malloc_bin_reloc(); env_relocate(); bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); diff --git a/lib_ppc/board.c b/lib_ppc/board.c index 9e944fa38a..a0e6b208a7 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -775,6 +775,10 @@ void board_init_r (gd_t *id, ulong dest_addr) asm ("sync ; isync"); + /* initialize malloc() area */ + mem_malloc_init (); + malloc_bin_reloc (); + #if !defined(CONFIG_SYS_NO_FLASH) puts ("FLASH: "); @@ -832,10 +836,6 @@ void board_init_r (gd_t *id, ulong dest_addr) WATCHDOG_RESET (); - /* initialize malloc() area */ - mem_malloc_init (); - malloc_bin_reloc (); - #ifdef CONFIG_SPI # if !defined(CONFIG_ENV_IS_IN_EEPROM) spi_init_f (); diff --git a/lib_sh/board.c b/lib_sh/board.c index 2fd213ba3d..183110fe30 100644 --- a/lib_sh/board.c +++ b/lib_sh/board.c @@ -146,8 +146,8 @@ init_fnc_t *init_sequence[] = checkboard, /* Check support board */ dram_init, /* SDRAM init */ timer_init, /* SuperH Timer (TCNT0 only) init */ - sh_flash_init, /* Flash memory(NOR) init*/ sh_mem_env_init, + sh_flash_init, /* Flash memory(NOR) init*/ INIT_FUNC_NAND_INIT/* Flash memory (NAND) init */ INIT_FUNC_PCI_INIT /* PCI init */ devices_init, diff --git a/lib_sparc/board.c b/lib_sparc/board.c index 2f3e6733b6..628d46d308 100644 --- a/lib_sparc/board.c +++ b/lib_sparc/board.c @@ -331,6 +331,10 @@ void board_init_f(ulong bootflag) */ interrupt_init(); + /* initialize malloc() area */ + mem_malloc_init(); + malloc_bin_reloc(); + #if !defined(CONFIG_SYS_NO_FLASH) puts("FLASH: "); @@ -371,11 +375,6 @@ void board_init_f(ulong bootflag) bd->bi_flashoffset = 0; #endif /* !CONFIG_SYS_NO_FLASH */ - /* initialize malloc() area */ - mem_malloc_init(); - - malloc_bin_reloc(); - #ifdef CONFIG_SPI # if !defined(CONFIG_ENV_IS_IN_EEPROM) spi_init_f();