summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Tyser <ptyser@xes-inc.com>2009-08-21 23:05:21 -0500
committerWolfgang Denk <wd@denx.de>2009-09-04 21:47:07 +0200
commitd4e8ada0f6d51e0e3b80790fb9375ac8910f5352 (patch)
tree172c42027af83102cf77445655b510ebbdb75d89
parenta483a167bc8d808145ca1224a2c238cda90aa60c (diff)
downloadu-boot-imx-d4e8ada0f6d51e0e3b80790fb9375ac8910f5352.zip
u-boot-imx-d4e8ada0f6d51e0e3b80790fb9375ac8910f5352.tar.gz
u-boot-imx-d4e8ada0f6d51e0e3b80790fb9375ac8910f5352.tar.bz2
Consolidate arch-specific mem_malloc_init() implementations
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
-rw-r--r--common/dlmalloc.c15
-rw-r--r--include/malloc.h2
-rw-r--r--lib_arm/board.c10
-rw-r--r--lib_avr32/board.c15
-rw-r--r--lib_blackfin/board.c9
-rw-r--r--lib_m68k/board.c14
-rw-r--r--lib_microblaze/board.c20
-rw-r--r--lib_mips/board.c14
-rw-r--r--lib_nios/board.c14
-rw-r--r--lib_nios2/board.c14
-rw-r--r--lib_ppc/board.c14
-rw-r--r--lib_sh/board.c9
-rw-r--r--lib_sparc/board.c21
13 files changed, 32 insertions, 139 deletions
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index f3bced4..241db8c 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -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)
diff --git a/include/malloc.h b/include/malloc.h
index 0382169..3e145ad 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -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
diff --git a/lib_arm/board.c b/lib_arm/board.c
index 904ea89..a0e56d5 100644
--- a/lib_arm/board.c
+++ b/lib_arm/board.c
@@ -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
diff --git a/lib_avr32/board.c b/lib_avr32/board.c
index ca1bd6f..29999d8 100644
--- a/lib_avr32/board.c
+++ b/lib_avr32/board.c
@@ -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();
diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c
index 17681f6..1053f69 100644
--- a/lib_blackfin/board.c
+++ b/lib_blackfin/board.c
@@ -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);
diff --git a/lib_m68k/board.c b/lib_m68k/board.c
index cbc6b50..3d88530 100644
--- a/lib_m68k/board.c
+++ b/lib_m68k/board.c
@@ -107,18 +107,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
* requirements are just _too_ different. To get rid of the resulting
@@ -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 ();
diff --git a/lib_microblaze/board.c b/lib_microblaze/board.c
index a5d924a..200ea5d 100644
--- a/lib_microblaze/board.c
+++ b/lib_microblaze/board.c
@@ -47,20 +47,6 @@ 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
* requirements are just _too_ different. To get rid of the resulting
@@ -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) {
diff --git a/lib_mips/board.c b/lib_mips/board.c
index b233a6c..f62a46a 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -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();
diff --git a/lib_nios/board.c b/lib_nios/board.c
index 745e0a4..72713a8 100644
--- a/lib_nios/board.c
+++ b/lib_nios/board.c
@@ -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();
diff --git a/lib_nios2/board.c b/lib_nios2/board.c
index 2c470dd..c6b36f4 100644
--- a/lib_nios2/board.c
+++ b/lib_nios2/board.c
@@ -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();
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 6cf7730..d9a12a1 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -142,18 +142,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
* requirements are just _too_ different. To get rid of the resulting
@@ -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 ();
diff --git a/lib_sh/board.c b/lib_sh/board.c
index 2691316..5d61f0d 100644
--- a/lib_sh/board.c
+++ b/lib_sh/board.c
@@ -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;
diff --git a/lib_sparc/board.c b/lib_sparc/board.c
index e69431f..6aadb56 100644
--- a/lib_sparc/board.c
+++ b/lib_sparc/board.c
@@ -75,25 +75,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 *
************************************************************************
* Some of this code should be moved into the core functions,
@@ -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();