]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Consolidate arch-specific mem_malloc_init() implementations
authorPeter Tyser <ptyser@xes-inc.com>
Sat, 22 Aug 2009 04:05:21 +0000 (23:05 -0500)
committerWolfgang Denk <wd@denx.de>
Fri, 4 Sep 2009 19:47:07 +0000 (21:47 +0200)
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
13 files changed:
common/dlmalloc.c
include/malloc.h
lib_arm/board.c
lib_avr32/board.c
lib_blackfin/board.c
lib_m68k/board.c
lib_microblaze/board.c
lib_mips/board.c
lib_nios/board.c
lib_nios2/board.c
lib_ppc/board.c
lib_sh/board.c
lib_sparc/board.c

index f3bced463fd10773069ba14f5c23c6b781d84c69..241db8cd3e061f1c18788763dfa0b522ca7c5af8 100644 (file)
@@ -1520,6 +1520,21 @@ void *sbrk(ptrdiff_t increment)
        return (void *)old;
 }
 
+#ifndef CONFIG_X86
+/*
+ * x86 boards use a slightly different init sequence thus they implement
+ * their own version of mem_malloc_init()
+ */
+void mem_malloc_init(ulong start, ulong size)
+{
+       mem_malloc_start = start;
+       mem_malloc_end = start + size;
+       mem_malloc_brk = start;
+
+       memset((void *)mem_malloc_start, 0, size);
+}
+#endif
+
 /* field-extraction macros */
 
 #define first(b) ((b)->fd)
index 0382169b6a013b241340b926dbacaedd3b9a7246..3e145ad11c32bf0c9fcfb88c6d06f4895e8316d1 100644 (file)
@@ -944,6 +944,8 @@ extern ulong mem_malloc_start;
 extern ulong mem_malloc_end;
 extern ulong mem_malloc_brk;
 
+void mem_malloc_init(ulong start, ulong size);
+
 #ifdef __cplusplus
 };  /* end of extern "C" */
 #endif
index 904ea89c2d294772d39c2390ef8b37b8dc21f0b4..a0e56d5ae8f9fbd71c8f4863a37045602fa81039 100644 (file)
@@ -82,16 +82,6 @@ extern void rtl8019_get_enetaddr (uchar * addr);
 #include <i2c.h>
 #endif
 
-static
-void mem_malloc_init (ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset ((void *)mem_malloc_start, 0, size);
-}
-
 
 /************************************************************************
  * Coloured LED functionality
index ca1bd6fd3290c28e15098d41fce2843ce9b9e12b..29999d86359e7e00f318625580418c7040e61c4b 100644 (file)
@@ -49,19 +49,6 @@ static int __do_nothing(void)
 int board_postclk_init(void) __attribute__((weak, alias("__do_nothing")));
 int board_early_init_r(void) __attribute__((weak, alias("__do_nothing")));
 
-/* The malloc area is right below the monitor image in RAM */
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       printf("malloc: Using memory from 0x%08lx to 0x%08lx\n",
-              mem_malloc_start, mem_malloc_end);
-
-       memset((void *)mem_malloc_start, 0, size);
-}
-
 #ifdef CONFIG_SYS_DMA_ALLOC_LEN
 #include <asm/arch/cacheflush.h>
 #include <asm/io.h>
@@ -308,6 +295,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 #endif
 
        timer_init();
+
+       /* The malloc area is right below the monitor image in RAM */
        mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
                        CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
        malloc_bin_reloc();
index 17681f6f8ead52e9263082f40b2617de616b215d..1053f694cb47867092f24d53dac58381e3b5fb05 100644 (file)
@@ -44,15 +44,6 @@ static inline void serial_early_puts(const char *s)
 #endif
 }
 
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset((void*)mem_malloc_start, 0, size);
-}
-
 static int display_banner(void)
 {
        printf("\n\n%s\n\n", version_string);
index cbc6b50258a3cf088342b9e0bb384fee65e32acf..3d885306e216178b0e2252e0900e82aefc522204 100644 (file)
@@ -106,18 +106,6 @@ ulong monitor_flash_len;
  ************************************************************************
  */
 
-/*
- * The Malloc area is immediately below the monitor copy in DRAM
- */
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset ((void *)mem_malloc_start, 0, size);
-}
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -494,7 +482,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
         */
        trap_init (CONFIG_SYS_SDRAM_BASE);
 
-       /* initialize malloc() area */
+       /* The Malloc area is immediately below the monitor copy in DRAM */
        mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
                        TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
        malloc_bin_reloc ();
index a5d924a1f333aaa204b5981aef2b71d921d863b8..200ea5dd7015c77d6b82dc8f02e68f39a1ca5b5e 100644 (file)
@@ -46,20 +46,6 @@ extern int eth_init (bd_t * bis);
 extern int getenv_IPaddr (char *);
 #endif
 
-/*
- * The Malloc area is immediately below the monitor copy in DRAM
- * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
- * as our monitory code is run from SDRAM
- */
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset ((void *)mem_malloc_start, 0, size);
-}
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -104,7 +90,11 @@ void board_init (void)
        bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
 
-       /* Initialise malloc() area */
+       /*
+        * The Malloc area is immediately below the monitor copy in DRAM
+        * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
+        * as our monitory code is run from SDRAM
+        */
        mem_malloc_init (CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
 
        for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
index b233a6c8a95e91caadf82466690012af8cdd97f7..f62a46a1726f27c6d6c9e6ca4a9014dd749e62ad 100644 (file)
@@ -74,18 +74,6 @@ int __board_early_init_f(void)
 }
 int board_early_init_f(void) __attribute__((weak, alias("__board_early_init_f")));
 
-/*
- * The Malloc area is immediately below the monitor copy in DRAM
- */
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset ((void *)mem_malloc_start, 0, size);
-}
-
 
 static int init_func_ram (void)
 {
@@ -347,7 +335,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        bd = gd->bd;
 
-       /* initialize malloc() area */
+       /* The Malloc area is immediately below the monitor copy in DRAM */
        mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
                        TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
        malloc_bin_reloc();
index 745e0a4d9831066a108e35b7d620aa56f11fc057..72713a8fec7aebd8db2e15a300efee93343dc6b3 100644 (file)
@@ -52,18 +52,6 @@ DECLARE_GLOBAL_DATA_PTR;
 extern void malloc_bin_reloc (void);
 typedef int (init_fnc_t) (void);
 
-/*
- * The Malloc area is immediately below the monitor copy in RAM
- */
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset ((void *)mem_malloc_start, 0, size);
-}
-
 
 /************************************************************************
  * Initialization sequence                                             *
@@ -124,6 +112,8 @@ void board_init (void)
        }
 
        WATCHDOG_RESET ();
+
+       /* The Malloc area is immediately below the monitor copy in RAM */
        mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
        malloc_bin_reloc();
 
index 2c470dd9f41d3d4c3467781f1cc11287ec7cef9e..c6b36f4a2ef1e35903c535abfab261d743627d1c 100644 (file)
@@ -55,18 +55,6 @@ DECLARE_GLOBAL_DATA_PTR;
 extern void malloc_bin_reloc (void);
 typedef int (init_fnc_t) (void);
 
-/*
- * The Malloc area is immediately below the monitor copy in RAM
- */
-static void mem_malloc_init (void)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start
-
-       memset((void *)mem_malloc_start, 0, size);
-}
-
 
 /************************************************************************
  * Initialization sequence                                             *
@@ -130,6 +118,8 @@ void board_init (void)
        }
 
        WATCHDOG_RESET ();
+
+       /* The Malloc area is immediately below the monitor copy in RAM */
        mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
        malloc_bin_reloc();
 
index 6cf773009510095b97d4bf8069974b58f9ea993f..d9a12a1241329cbd14808a2e59a957c11a9e0cf7 100644 (file)
@@ -141,18 +141,6 @@ ulong monitor_flash_len;
  ************************************************************************
  */
 
-/*
- * The Malloc area is immediately below the monitor copy in DRAM
- */
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset ((void *)mem_malloc_start, 0, size);
-}
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -657,6 +645,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
 
+       /* The Malloc area is immediately below the monitor copy in DRAM */
 #if defined(CONFIG_RELOC_FIXUP_WORKS)
        gd->reloc_off = 0;
        malloc_start = dest_addr - TOTAL_MALLOC_LEN;
@@ -758,7 +747,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        asm ("sync ; isync");
 
-       /* initialize malloc() area */
        mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
        malloc_bin_reloc ();
 
index 26913160463387e4c9891469ff0997f53996dc46..5d61f0d74fe1b7f1f425468d6158c7bc97a16448 100644 (file)
@@ -38,15 +38,6 @@ const char version_string[] = U_BOOT_VERSION" ("U_BOOT_DATE" - "U_BOOT_TIME")";
 
 unsigned long monitor_flash_len = CONFIG_SYS_MONITOR_LEN;
 
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start;
-
-       memset((void *)mem_malloc_start, 0, size);
-}
-
 static int sh_flash_init(void)
 {
        DECLARE_GLOBAL_DATA_PTR;
index e69431f8b896e5de9c1d6ea8f0c554ff192250fc..6aadb56f63c1fa1bbd39e7a54957528d9e7ba511 100644 (file)
@@ -74,25 +74,6 @@ static char *failed = "*** failed ***\n";
 
 ulong monitor_flash_len;
 
-/************************************************************************
- * Utilities                                                           *
- ************************************************************************
- */
-
-/*
- * The Malloc area is immediately below the monitor copy in RAM
- */
-static void mem_malloc_init(ulong start, ulong size)
-{
-       mem_malloc_start = start;
-       mem_malloc_end = start + size;
-       mem_malloc_brk = start
-
-       memset((void *)mem_malloc_start, 0, size);
-}
-
-/***********************************************************************/
-
 /************************************************************************
  * Init Utilities                                                      *
  ************************************************************************
@@ -313,7 +294,7 @@ void board_init_f(ulong bootflag)
         */
        interrupt_init();
 
-       /* initialize malloc() area */
+       /* The Malloc area is immediately below the monitor copy in RAM */
        mem_malloc_init(CONFIG_SYS_MALLOC_BASE,
                        CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE);
        malloc_bin_reloc();