* [U-Boot] [PATCH 0/3] Clean up up malloc pool init
@ 2009-08-22 4:05 Peter Tyser
2009-08-22 4:05 ` [U-Boot] [PATCH 1/3] Consolidate arch-specific sbrk() implementations Peter Tyser
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Peter Tyser @ 2009-08-22 4:05 UTC (permalink / raw)
To: u-boot
Most architectures share nearly identical malloc initialization code.
This series factors out the common code into dlmalloc.c.
I tested on the XPedite5200, an mpc8548-based board. Let me know if anyone
runs into any issues on other architectures.
Peter Tyser (3):
Consolidate arch-specific sbrk() implementations
Standardize mem_malloc_init() implementation
Consolidate arch-specific mem_malloc_init() implementations
common/dlmalloc.c | 33 ++++++++++++++++++++++++++++++++-
include/malloc.h | 8 ++++++++
lib_arm/board.c | 34 ++--------------------------------
lib_avr32/board.c | 41 ++++-------------------------------------
lib_blackfin/board.c | 25 +------------------------
lib_i386/board.c | 21 ---------------------
lib_m68k/board.c | 41 +++--------------------------------------
lib_microblaze/board.c | 40 ++++++----------------------------------
lib_mips/board.c | 40 +++-------------------------------------
lib_nios/board.c | 37 ++++---------------------------------
lib_nios2/board.c | 37 ++++---------------------------------
lib_ppc/board.c | 44 ++++++--------------------------------------
lib_sh/board.c | 31 ++-----------------------------
lib_sparc/board.c | 42 +++---------------------------------------
14 files changed, 78 insertions(+), 396 deletions(-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 1/3] Consolidate arch-specific sbrk() implementations
2009-08-22 4:05 [U-Boot] [PATCH 0/3] Clean up up malloc pool init Peter Tyser
@ 2009-08-22 4:05 ` Peter Tyser
2009-09-04 19:45 ` Wolfgang Denk
2009-08-22 4:05 ` [U-Boot] [PATCH 2/3] Standardize mem_malloc_init() implementation Peter Tyser
2009-08-22 4:05 ` [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations Peter Tyser
2 siblings, 1 reply; 13+ messages in thread
From: Peter Tyser @ 2009-08-22 4:05 UTC (permalink / raw)
To: u-boot
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
common/dlmalloc.c | 18 +++++++++++++++++-
include/malloc.h | 6 ++++++
lib_arm/board.c | 20 --------------------
lib_avr32/board.c | 19 -------------------
lib_blackfin/board.c | 20 +++-----------------
lib_i386/board.c | 21 ---------------------
lib_m68k/board.c | 20 --------------------
lib_microblaze/board.c | 19 -------------------
lib_mips/board.c | 19 -------------------
lib_nios/board.c | 20 +-------------------
lib_nios2/board.c | 20 +-------------------
lib_ppc/board.c | 19 -------------------
lib_sh/board.c | 18 ------------------
lib_sparc/board.c | 19 -------------------
14 files changed, 28 insertions(+), 230 deletions(-)
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 4a18562..f3bced4 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1502,7 +1502,23 @@ void malloc_bin_reloc (void)
*p++ += gd->reloc_off;
}
}
-\f
+
+ulong mem_malloc_start = 0;
+ulong mem_malloc_end = 0;
+ulong mem_malloc_brk = 0;
+
+void *sbrk(ptrdiff_t increment)
+{
+ ulong old = mem_malloc_brk;
+ ulong new = old + increment;
+
+ if ((new < mem_malloc_start) || (new > mem_malloc_end))
+ return NULL;
+
+ mem_malloc_brk = new;
+
+ return (void *)old;
+}
/* field-extraction macros */
diff --git a/include/malloc.h b/include/malloc.h
index a38464e..0382169 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -937,6 +937,12 @@ int mALLOPt();
struct mallinfo mALLINFo();
#endif
+/*
+ * Begin and End of memory area for malloc(), and current "brk"
+ */
+extern ulong mem_malloc_start;
+extern ulong mem_malloc_end;
+extern ulong mem_malloc_brk;
#ifdef __cplusplus
}; /* end of extern "C" */
diff --git a/lib_arm/board.c b/lib_arm/board.c
index a44d308..9bd5eca 100644
--- a/lib_arm/board.c
+++ b/lib_arm/board.c
@@ -86,13 +86,6 @@ extern void rtl8019_get_enetaddr (uchar * addr);
#include <i2c.h>
#endif
-/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start = 0;
-static ulong mem_malloc_end = 0;
-static ulong mem_malloc_brk = 0;
-
static
void mem_malloc_init (ulong dest_addr)
{
@@ -104,19 +97,6 @@ void mem_malloc_init (ulong dest_addr)
mem_malloc_end - mem_malloc_start);
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
-
- return ((void *) old);
-}
-
/************************************************************************
* Coloured LED functionality
diff --git a/lib_avr32/board.c b/lib_avr32/board.c
index e2b0a2e..03a520c 100644
--- a/lib_avr32/board.c
+++ b/lib_avr32/board.c
@@ -41,13 +41,6 @@ const char version_string[] =
unsigned long monitor_flash_len;
-/*
- * Begin and end of memory area for malloc(), and current "brk"
- */
-static unsigned long mem_malloc_start = 0;
-static unsigned long mem_malloc_end = 0;
-static unsigned long mem_malloc_brk = 0;
-
/* Weak aliases for optional board functions */
static int __do_nothing(void)
{
@@ -73,18 +66,6 @@ static void mem_malloc_init(void)
mem_malloc_end - mem_malloc_start);
}
-void *sbrk(ptrdiff_t increment)
-{
- unsigned long old = mem_malloc_brk;
- unsigned long new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end))
- return NULL;
-
- mem_malloc_brk = new;
- return ((void *)old);
-}
-
#ifdef CONFIG_SYS_DMA_ALLOC_LEN
#include <asm/arch/cacheflush.h>
#include <asm/io.h>
diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c
index b957a9d..b293c1b 100644
--- a/lib_blackfin/board.c
+++ b/lib_blackfin/board.c
@@ -44,27 +44,13 @@ static inline void serial_early_puts(const char *s)
#endif
}
-static void *mem_malloc_start, *mem_malloc_end, *mem_malloc_brk;
-
static void mem_malloc_init(void)
{
- mem_malloc_start = (void *)CONFIG_SYS_MALLOC_BASE;
- mem_malloc_end = (void *)(CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN);
+ mem_malloc_start = (ulong)CONFIG_SYS_MALLOC_BASE;
+ mem_malloc_end = (ulong)(CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN);
mem_malloc_brk = mem_malloc_start;
- memset(mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
-}
-
-void *sbrk(ptrdiff_t increment)
-{
- void *old = mem_malloc_brk;
- void *new = old + increment;
-
- if (new < mem_malloc_start || new > mem_malloc_end)
- return NULL;
-
- mem_malloc_brk = new;
- return old;
+ memset((void*)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
}
static int display_banner(void)
diff --git a/lib_i386/board.c b/lib_i386/board.c
index 54ef6e7..0262b5e 100644
--- a/lib_i386/board.c
+++ b/lib_i386/board.c
@@ -73,14 +73,6 @@ ulong i386boot_bios_size = (ulong)&_i386boot_bios_size; /* size of BIOS
const char version_string[] =
U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")";
-
-/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start = 0;
-static ulong mem_malloc_end = 0;
-static ulong mem_malloc_brk = 0;
-
static int mem_malloc_init(void)
{
/* start malloc area right after the stack */
@@ -96,19 +88,6 @@ static int mem_malloc_init(void)
return 0;
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
-
- return ((void *) old);
-}
-
/************************************************************************
* Init Utilities *
************************************************************************
diff --git a/lib_m68k/board.c b/lib_m68k/board.c
index 483c9b6..4392bcc 100644
--- a/lib_m68k/board.c
+++ b/lib_m68k/board.c
@@ -101,13 +101,6 @@ extern int watchdog_disable(void);
ulong monitor_flash_len;
-/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start = 0;
-static ulong mem_malloc_end = 0;
-static ulong mem_malloc_brk = 0;
-
/************************************************************************
* Utilities *
************************************************************************
@@ -129,19 +122,6 @@ static void mem_malloc_init (void)
mem_malloc_end - mem_malloc_start);
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) ||
- (new > mem_malloc_end) ) {
- return (NULL);
- }
- mem_malloc_brk = new;
- return ((void *)old);
-}
-
/*
* All attempts to come up with a "common" initialization sequence
* that works for all boards and architectures failed: some of the
diff --git a/lib_microblaze/board.c b/lib_microblaze/board.c
index cfed5fe..fc25a75 100644
--- a/lib_microblaze/board.c
+++ b/lib_microblaze/board.c
@@ -47,13 +47,6 @@ extern int getenv_IPaddr (char *);
#endif
/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start;
-static ulong mem_malloc_end;
-static ulong mem_malloc_brk;
-
-/*
* 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
@@ -66,18 +59,6 @@ static void mem_malloc_init (void)
memset ((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
- return ((void *)old);
-}
-
/*
* All attempts to come up with a "common" initialization sequence
* that works for all boards and architectures failed: some of the
diff --git a/lib_mips/board.c b/lib_mips/board.c
index aa5b129..68a3697 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -60,13 +60,6 @@ const char version_string[] =
static char *failed = "*** failed ***\n";
/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start;
-static ulong mem_malloc_end;
-static ulong mem_malloc_brk;
-
-/*
* mips_io_port_base is the begin of the address space to which x86 style
* I/O ports are mapped.
*/
@@ -97,18 +90,6 @@ static void mem_malloc_init (void)
mem_malloc_end - mem_malloc_start);
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
- return ((void *) old);
-}
-
static int init_func_ram (void)
{
diff --git a/lib_nios/board.c b/lib_nios/board.c
index cd23457..30cdb47 100644
--- a/lib_nios/board.c
+++ b/lib_nios/board.c
@@ -27,6 +27,7 @@
#include <common.h>
#include <stdio_dev.h>
#include <watchdog.h>
+#include <malloc.h>
#include <net.h>
#ifdef CONFIG_STATUS_LED
#include <status_led.h>
@@ -52,13 +53,6 @@ extern void malloc_bin_reloc (void);
typedef int (init_fnc_t) (void);
/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start = 0;
-static ulong mem_malloc_end = 0;
-static ulong mem_malloc_brk = 0;
-
-/*
* The Malloc area is immediately below the monitor copy in RAM
*/
static void mem_malloc_init (void)
@@ -71,18 +65,6 @@ static void mem_malloc_init (void)
mem_malloc_end - mem_malloc_start);
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
- return ((void *) old);
-}
-
/************************************************************************
* Initialization sequence *
diff --git a/lib_nios2/board.c b/lib_nios2/board.c
index b142c59..e5a8d54 100644
--- a/lib_nios2/board.c
+++ b/lib_nios2/board.c
@@ -27,6 +27,7 @@
#include <common.h>
#include <stdio_dev.h>
#include <watchdog.h>
+#include <malloc.h>
#include <net.h>
#ifdef CONFIG_STATUS_LED
#include <status_led.h>
@@ -55,13 +56,6 @@ extern void malloc_bin_reloc (void);
typedef int (init_fnc_t) (void);
/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start = 0;
-static ulong mem_malloc_end = 0;
-static ulong mem_malloc_brk = 0;
-
-/*
* The Malloc area is immediately below the monitor copy in RAM
*/
static void mem_malloc_init (void)
@@ -74,18 +68,6 @@ static void mem_malloc_init (void)
mem_malloc_end - mem_malloc_start);
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
- return ((void *) old);
-}
-
/************************************************************************
* Initialization sequence *
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 6dd4d56..8a8cca1 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -136,13 +136,6 @@ ulong monitor_flash_len;
#include <bedbug/type.h>
#endif
-/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start = 0;
-static ulong mem_malloc_end = 0;
-static ulong mem_malloc_brk = 0;
-
/************************************************************************
* Utilities *
************************************************************************
@@ -164,18 +157,6 @@ static void mem_malloc_init (void)
mem_malloc_end - mem_malloc_start);
}
-void *sbrk (ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
- return ((void *) old);
-}
-
/*
* All attempts to come up with a "common" initialization sequence
* that works for all boards and architectures failed: some of the
diff --git a/lib_sh/board.c b/lib_sh/board.c
index 829455d..001e89c 100644
--- a/lib_sh/board.c
+++ b/lib_sh/board.c
@@ -38,10 +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 unsigned long mem_malloc_start;
-static unsigned long mem_malloc_end;
-static unsigned long mem_malloc_brk;
-
static void mem_malloc_init(void)
{
@@ -52,20 +48,6 @@ static void mem_malloc_init(void)
(mem_malloc_end - mem_malloc_start));
}
-void *sbrk(ptrdiff_t increment)
-{
- unsigned long old = mem_malloc_brk;
- unsigned long new = old + increment;
-
- if ((new < mem_malloc_start) ||
- (new > mem_malloc_end)) {
- return NULL;
- }
-
- mem_malloc_brk = new;
- return (void *) old;
-}
-
static int sh_flash_init(void)
{
DECLARE_GLOBAL_DATA_PTR;
diff --git a/lib_sparc/board.c b/lib_sparc/board.c
index d40834b..37b7c0a 100644
--- a/lib_sparc/board.c
+++ b/lib_sparc/board.c
@@ -74,13 +74,6 @@ static char *failed = "*** failed ***\n";
ulong monitor_flash_len;
-/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong mem_malloc_start = 0;
-static ulong mem_malloc_end = 0;
-static ulong mem_malloc_brk = 0;
-
/************************************************************************
* Utilities *
************************************************************************
@@ -97,18 +90,6 @@ static void mem_malloc_init(void)
memset((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
}
-void *sbrk(ptrdiff_t increment)
-{
- ulong old = mem_malloc_brk;
- ulong new = old + increment;
-
- if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
- return (NULL);
- }
- mem_malloc_brk = new;
- return ((void *)old);
-}
-
/***********************************************************************/
/************************************************************************
--
1.6.2.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 2/3] Standardize mem_malloc_init() implementation
2009-08-22 4:05 [U-Boot] [PATCH 0/3] Clean up up malloc pool init Peter Tyser
2009-08-22 4:05 ` [U-Boot] [PATCH 1/3] Consolidate arch-specific sbrk() implementations Peter Tyser
@ 2009-08-22 4:05 ` Peter Tyser
2009-09-04 19:46 ` Wolfgang Denk
2009-08-22 4:05 ` [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations Peter Tyser
2 siblings, 1 reply; 13+ messages in thread
From: Peter Tyser @ 2009-08-22 4:05 UTC (permalink / raw)
To: u-boot
This lays the groundwork to allow architectures to share a common
mem_malloc_init().
Note that the x86 implementation was not modified as it did not fit the
mold of all other architectures.
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
lib_arm/board.c | 14 +++++++-------
lib_avr32/board.c | 17 +++++++----------
lib_blackfin/board.c | 12 ++++++------
lib_m68k/board.c | 17 +++++++----------
lib_microblaze/board.c | 13 +++++++------
lib_mips/board.c | 17 +++++++----------
lib_nios/board.c | 15 +++++++--------
lib_nios2/board.c | 13 ++++++-------
lib_ppc/board.c | 21 ++++++++++-----------
lib_sh/board.c | 14 +++++++-------
lib_sparc/board.c | 14 ++++++++------
11 files changed, 79 insertions(+), 88 deletions(-)
diff --git a/lib_arm/board.c b/lib_arm/board.c
index 9bd5eca..a923ddc 100644
--- a/lib_arm/board.c
+++ b/lib_arm/board.c
@@ -87,14 +87,13 @@ extern void rtl8019_get_enetaddr (uchar * addr);
#endif
static
-void mem_malloc_init (ulong dest_addr)
+void mem_malloc_init (ulong start, ulong size)
{
- mem_malloc_start = dest_addr;
- mem_malloc_end = dest_addr + CONFIG_SYS_MALLOC_LEN;
- mem_malloc_brk = mem_malloc_start;
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
- memset ((void *) mem_malloc_start, 0,
- mem_malloc_end - mem_malloc_start);
+ memset ((void *)mem_malloc_start, 0, size);
}
@@ -304,7 +303,8 @@ void start_armboot (void)
}
/* armboot_start is defined in the board-specific linker script */
- mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN);
+ mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN,
+ CONFIG_SYS_MALLOC_LEN);
#ifndef CONFIG_SYS_NO_FLASH
/* configure available FLASH banks */
diff --git a/lib_avr32/board.c b/lib_avr32/board.c
index 03a520c..ca1bd6f 100644
--- a/lib_avr32/board.c
+++ b/lib_avr32/board.c
@@ -50,20 +50,16 @@ 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(void)
+static void mem_malloc_init(ulong start, ulong size)
{
- unsigned long monitor_addr;
-
- monitor_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off;
- mem_malloc_end = monitor_addr;
- mem_malloc_start = mem_malloc_end - CONFIG_SYS_MALLOC_LEN;
- mem_malloc_brk = mem_malloc_start;
+ 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,
- mem_malloc_end - mem_malloc_start);
+ memset((void *)mem_malloc_start, 0, size);
}
#ifdef CONFIG_SYS_DMA_ALLOC_LEN
@@ -312,7 +308,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
#endif
timer_init();
- mem_malloc_init();
+ mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
+ CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
malloc_bin_reloc();
dma_alloc_init();
diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c
index b293c1b..80f70ca 100644
--- a/lib_blackfin/board.c
+++ b/lib_blackfin/board.c
@@ -44,13 +44,13 @@ static inline void serial_early_puts(const char *s)
#endif
}
-static void mem_malloc_init(void)
+static void mem_malloc_init(ulong start, ulong size)
{
- mem_malloc_start = (ulong)CONFIG_SYS_MALLOC_BASE;
- mem_malloc_end = (ulong)(CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN);
- mem_malloc_brk = mem_malloc_start;
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
- memset((void*)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
+ memset((void*)mem_malloc_start, 0, size);
}
static int display_banner(void)
@@ -311,7 +311,7 @@ void board_init_r(gd_t * id, ulong dest_addr)
#endif
/* initialize malloc() area */
- mem_malloc_init();
+ mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
malloc_bin_reloc();
#if !defined(CONFIG_SYS_NO_FLASH)
diff --git a/lib_m68k/board.c b/lib_m68k/board.c
index 4392bcc..cbc6b50 100644
--- a/lib_m68k/board.c
+++ b/lib_m68k/board.c
@@ -109,17 +109,13 @@ ulong monitor_flash_len;
/*
* The Malloc area is immediately below the monitor copy in DRAM
*/
-static void mem_malloc_init (void)
+static void mem_malloc_init(ulong start, ulong size)
{
- ulong dest_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off;
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
- mem_malloc_end = dest_addr;
- mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
- mem_malloc_brk = mem_malloc_start;
-
- memset ((void *) mem_malloc_start,
- 0,
- mem_malloc_end - mem_malloc_start);
+ memset ((void *)mem_malloc_start, 0, size);
}
/*
@@ -499,7 +495,8 @@ void board_init_r (gd_t *id, ulong dest_addr)
trap_init (CONFIG_SYS_SDRAM_BASE);
/* initialize malloc() area */
- mem_malloc_init ();
+ mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
+ TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
malloc_bin_reloc ();
#if !defined(CONFIG_SYS_NO_FLASH)
diff --git a/lib_microblaze/board.c b/lib_microblaze/board.c
index fc25a75..a5d924a 100644
--- a/lib_microblaze/board.c
+++ b/lib_microblaze/board.c
@@ -51,12 +51,13 @@ extern int getenv_IPaddr (char *);
* 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 (void)
+static void mem_malloc_init(ulong start, ulong size)
{
- mem_malloc_end = (CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN);
- mem_malloc_start = CONFIG_SYS_MALLOC_BASE;
- mem_malloc_brk = mem_malloc_start;
- memset ((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
+
+ memset ((void *)mem_malloc_start, 0, size);
}
/*
@@ -104,7 +105,7 @@ void board_init (void)
gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
/* Initialise malloc() area */
- mem_malloc_init ();
+ mem_malloc_init (CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
WATCHDOG_RESET ();
diff --git a/lib_mips/board.c b/lib_mips/board.c
index 68a3697..b233a6c 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -77,17 +77,13 @@ 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 (void)
+static void mem_malloc_init(ulong start, ulong size)
{
- ulong dest_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off;
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
- mem_malloc_end = dest_addr;
- mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
- mem_malloc_brk = mem_malloc_start;
-
- memset ((void *) mem_malloc_start,
- 0,
- mem_malloc_end - mem_malloc_start);
+ memset ((void *)mem_malloc_start, 0, size);
}
@@ -352,7 +348,8 @@ void board_init_r (gd_t *id, ulong dest_addr)
bd = gd->bd;
/* initialize malloc() area */
- mem_malloc_init();
+ mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
+ TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
malloc_bin_reloc();
#ifndef CONFIG_SYS_NO_FLASH
diff --git a/lib_nios/board.c b/lib_nios/board.c
index 30cdb47..745e0a4 100644
--- a/lib_nios/board.c
+++ b/lib_nios/board.c
@@ -55,14 +55,13 @@ typedef int (init_fnc_t) (void);
/*
* The Malloc area is immediately below the monitor copy in RAM
*/
-static void mem_malloc_init (void)
+static void mem_malloc_init(ulong start, ulong size)
{
- mem_malloc_start = CONFIG_SYS_MALLOC_BASE;
- mem_malloc_end = mem_malloc_start + CONFIG_SYS_MALLOC_LEN;
- mem_malloc_brk = mem_malloc_start;
- memset ((void *) mem_malloc_start,
- 0,
- mem_malloc_end - mem_malloc_start);
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
+
+ memset ((void *)mem_malloc_start, 0, size);
}
@@ -125,7 +124,7 @@ void board_init (void)
}
WATCHDOG_RESET ();
- mem_malloc_init();
+ mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
malloc_bin_reloc();
WATCHDOG_RESET ();
diff --git a/lib_nios2/board.c b/lib_nios2/board.c
index e5a8d54..2c470dd 100644
--- a/lib_nios2/board.c
+++ b/lib_nios2/board.c
@@ -60,12 +60,11 @@ typedef int (init_fnc_t) (void);
*/
static void mem_malloc_init (void)
{
- mem_malloc_start = CONFIG_SYS_MALLOC_BASE;
- mem_malloc_end = mem_malloc_start + CONFIG_SYS_MALLOC_LEN;
- mem_malloc_brk = mem_malloc_start;
- memset ((void *) mem_malloc_start,
- 0,
- mem_malloc_end - mem_malloc_start);
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start
+
+ memset((void *)mem_malloc_start, 0, size);
}
@@ -131,7 +130,7 @@ void board_init (void)
}
WATCHDOG_RESET ();
- mem_malloc_init();
+ mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
malloc_bin_reloc();
WATCHDOG_RESET ();
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 8a8cca1..a49b896 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -144,17 +144,13 @@ ulong monitor_flash_len;
/*
* The Malloc area is immediately below the monitor copy in DRAM
*/
-static void mem_malloc_init (void)
+static void mem_malloc_init(ulong start, ulong size)
{
-#if !defined(CONFIG_RELOC_FIXUP_WORKS)
- mem_malloc_end = CONFIG_SYS_MONITOR_BASE + gd->reloc_off;
-#endif
- mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN;
- mem_malloc_brk = mem_malloc_start;
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
- memset ((void *) mem_malloc_start,
- 0,
- mem_malloc_end - mem_malloc_start);
+ memset ((void *)mem_malloc_start, 0, size);
}
/*
@@ -647,6 +643,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
#ifndef CONFIG_ENV_IS_NOWHERE
extern char * env_name_spec;
#endif
+ ulong malloc_start;
#ifndef CONFIG_SYS_NO_FLASH
ulong flash_size;
@@ -659,9 +656,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
#if defined(CONFIG_RELOC_FIXUP_WORKS)
gd->reloc_off = 0;
- mem_malloc_end = dest_addr;
+ malloc_start = dest_addr - TOTAL_MALLOC_LEN;
#else
gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
+ malloc_start = CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
+ TOTAL_MALLOC_LEN;
#endif
#ifdef CONFIG_SERIAL_MULTI
@@ -757,7 +756,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
asm ("sync ; isync");
/* initialize malloc() area */
- mem_malloc_init ();
+ mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
malloc_bin_reloc ();
#if !defined(CONFIG_SYS_NO_FLASH)
diff --git a/lib_sh/board.c b/lib_sh/board.c
index 001e89c..2691316 100644
--- a/lib_sh/board.c
+++ b/lib_sh/board.c
@@ -38,14 +38,13 @@ 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(void)
+static void mem_malloc_init(ulong start, ulong size)
{
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start;
- mem_malloc_start = (TEXT_BASE - CONFIG_SYS_GBL_DATA_SIZE - CONFIG_SYS_MALLOC_LEN);
- mem_malloc_end = (mem_malloc_start + CONFIG_SYS_MALLOC_LEN - 16);
- mem_malloc_brk = mem_malloc_start;
- memset((void *) mem_malloc_start, 0,
- (mem_malloc_end - mem_malloc_start));
+ memset((void *)mem_malloc_start, 0, size);
}
static int sh_flash_init(void)
@@ -96,7 +95,8 @@ static int sh_pci_init(void)
static int sh_mem_env_init(void)
{
- mem_malloc_init();
+ mem_malloc_init(TEXT_BASE - CONFIG_SYS_GBL_DATA_SIZE -
+ CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN - 16);
malloc_bin_reloc();
env_relocate();
jumptable_init();
diff --git a/lib_sparc/board.c b/lib_sparc/board.c
index 37b7c0a..e69431f 100644
--- a/lib_sparc/board.c
+++ b/lib_sparc/board.c
@@ -82,12 +82,13 @@ ulong monitor_flash_len;
/*
* The Malloc area is immediately below the monitor copy in RAM
*/
-static void mem_malloc_init(void)
+static void mem_malloc_init(ulong start, ulong size)
{
- mem_malloc_start = CONFIG_SYS_MALLOC_BASE;
- mem_malloc_end = CONFIG_SYS_MALLOC_END;
- mem_malloc_brk = mem_malloc_start;
- memset((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
+ mem_malloc_start = start;
+ mem_malloc_end = start + size;
+ mem_malloc_brk = start
+
+ memset((void *)mem_malloc_start, 0, size);
}
/***********************************************************************/
@@ -313,7 +314,8 @@ void board_init_f(ulong bootflag)
interrupt_init();
/* initialize malloc() area */
- mem_malloc_init();
+ mem_malloc_init(CONFIG_SYS_MALLOC_BASE,
+ CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE);
malloc_bin_reloc();
#if !defined(CONFIG_SYS_NO_FLASH)
--
1.6.2.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 4:05 [U-Boot] [PATCH 0/3] Clean up up malloc pool init Peter Tyser
2009-08-22 4:05 ` [U-Boot] [PATCH 1/3] Consolidate arch-specific sbrk() implementations Peter Tyser
2009-08-22 4:05 ` [U-Boot] [PATCH 2/3] Standardize mem_malloc_init() implementation Peter Tyser
@ 2009-08-22 4:05 ` Peter Tyser
2009-08-22 10:51 ` Jean-Christophe PLAGNIOL-VILLARD
2009-09-04 19:47 ` Wolfgang Denk
2 siblings, 2 replies; 13+ messages in thread
From: Peter Tyser @ 2009-08-22 4:05 UTC (permalink / raw)
To: u-boot
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
common/dlmalloc.c | 15 +++++++++++++++
include/malloc.h | 2 ++
lib_arm/board.c | 10 ----------
lib_avr32/board.c | 15 ++-------------
lib_blackfin/board.c | 9 ---------
lib_m68k/board.c | 14 +-------------
lib_microblaze/board.c | 20 +++++---------------
lib_mips/board.c | 14 +-------------
lib_nios/board.c | 14 ++------------
lib_nios2/board.c | 14 ++------------
lib_ppc/board.c | 14 +-------------
lib_sh/board.c | 9 ---------
lib_sparc/board.c | 21 +--------------------
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 a923ddc..d38db7a 100644
--- a/lib_arm/board.c
+++ b/lib_arm/board.c
@@ -86,16 +86,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 80f70ca..0ab10ed 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 a49b896..5c099aa 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
@@ -654,6 +642,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;
@@ -755,7 +744,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();
--
1.6.2.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 4:05 ` [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations Peter Tyser
@ 2009-08-22 10:51 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-22 11:54 ` Wolfgang Denk
2009-08-22 16:45 ` Peter Tyser
2009-09-04 19:47 ` Wolfgang Denk
1 sibling, 2 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-22 10:51 UTC (permalink / raw)
To: u-boot
On 23:05 Fri 21 Aug , Peter Tyser wrote:
> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
> ---
> common/dlmalloc.c | 15 +++++++++++++++
> include/malloc.h | 2 ++
> lib_arm/board.c | 10 ----------
> lib_avr32/board.c | 15 ++-------------
> lib_blackfin/board.c | 9 ---------
> lib_m68k/board.c | 14 +-------------
> lib_microblaze/board.c | 20 +++++---------------
> lib_mips/board.c | 14 +-------------
> lib_nios/board.c | 14 ++------------
> lib_nios2/board.c | 14 ++------------
> lib_ppc/board.c | 14 +-------------
> lib_sh/board.c | 9 ---------
> lib_sparc/board.c | 21 +--------------------
> 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
could we have a generic name (not arch)
CONFIG_GENERIC_MALLOC_INIT
and then define it in the configs/arch.h
> +/*
> + * 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;
>
Best Regards,
J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 10:51 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-08-22 11:54 ` Wolfgang Denk
2009-08-22 12:32 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-22 16:45 ` Peter Tyser
1 sibling, 1 reply; 13+ messages in thread
From: Wolfgang Denk @ 2009-08-22 11:54 UTC (permalink / raw)
To: u-boot
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message <20090822085428.GA11950@game.jcrosoft.org> you wrote:
>
> > common/dlmalloc.c | 15 +++++++++++++++
> > include/malloc.h | 2 ++
> > lib_arm/board.c | 10 ----------
> > lib_avr32/board.c | 15 ++-------------
> > lib_blackfin/board.c | 9 ---------
> > lib_m68k/board.c | 14 +-------------
> > lib_microblaze/board.c | 20 +++++---------------
> > lib_mips/board.c | 14 +-------------
> > lib_nios/board.c | 14 ++------------
> > lib_nios2/board.c | 14 ++------------
> > lib_ppc/board.c | 14 +-------------
> > lib_sh/board.c | 9 ---------
> > lib_sparc/board.c | 21 +--------------------
> > 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
> could we have a generic name (not arch)
> CONFIG_GENERIC_MALLOC_INIT
That would mean you have to touch N board configurations. To me it
sounds as if this was not per-board choice, but an architecture-
specific decision. And a CONFIG_* name seems wrong (it should be
CONFIG_SYS_* at least).
> and then define it in the configs/arch.h
What is configs/arch.h? There is no such file, and the name does not
make sense to me.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Star Trek Lives!
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 11:54 ` Wolfgang Denk
@ 2009-08-22 12:32 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-22 12:49 ` Wolfgang Denk
0 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-22 12:32 UTC (permalink / raw)
To: u-boot
On 13:54 Sat 22 Aug , Wolfgang Denk wrote:
> Dear Jean-Christophe PLAGNIOL-VILLARD,
>
> In message <20090822085428.GA11950@game.jcrosoft.org> you wrote:
> >
> > > common/dlmalloc.c | 15 +++++++++++++++
> > > include/malloc.h | 2 ++
> > > lib_arm/board.c | 10 ----------
> > > lib_avr32/board.c | 15 ++-------------
> > > lib_blackfin/board.c | 9 ---------
> > > lib_m68k/board.c | 14 +-------------
> > > lib_microblaze/board.c | 20 +++++---------------
> > > lib_mips/board.c | 14 +-------------
> > > lib_nios/board.c | 14 ++------------
> > > lib_nios2/board.c | 14 ++------------
> > > lib_ppc/board.c | 14 +-------------
> > > lib_sh/board.c | 9 ---------
> > > lib_sparc/board.c | 21 +--------------------
> > > 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
> > could we have a generic name (not arch)
> > CONFIG_GENERIC_MALLOC_INIT
>
> That would mean you have to touch N board configurations. To me it
> sounds as if this was not per-board choice, but an architecture-
> specific decision. And a CONFIG_* name seems wrong (it should be
> CONFIG_SYS_* at least).
no the arch config file
>
> > and then define it in the configs/arch.h
>
> What is configs/arch.h? There is no such file, and the name does not
> make sense to me.
as introduce by Kumar
#include <asm/config.h>
Best Regards,
J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 12:32 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-08-22 12:49 ` Wolfgang Denk
0 siblings, 0 replies; 13+ messages in thread
From: Wolfgang Denk @ 2009-08-22 12:49 UTC (permalink / raw)
To: u-boot
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message <20090822123232.GB11950@game.jcrosoft.org> you wrote:
>
> > That would mean you have to touch N board configurations. To me it
> > sounds as if this was not per-board choice, but an architecture-
> > specific decision. And a CONFIG_* name seems wrong (it should be
> > CONFIG_SYS_* at least).
> no the arch config file
Yiour terminology is confusing. I guess what you write is not what you
mean. The closes thing to "arch config file" would be cpu/*/config.mk;
but I don;t think you mean that?
> > > and then define it in the configs/arch.h
> >
> > What is configs/arch.h? There is no such file, and the name does not
> > make sense to me.
> as introduce by Kumar
>
> #include <asm/config.h>
Ah. well, configs/arch.h != asm/config.h !!
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It would be illogical to assume that all conditions remain stable
-- Spock, "The Enterprise" Incident", stardate 5027.3
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 10:51 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-22 11:54 ` Wolfgang Denk
@ 2009-08-22 16:45 ` Peter Tyser
2009-08-22 22:48 ` Graeme Russ
1 sibling, 1 reply; 13+ messages in thread
From: Peter Tyser @ 2009-08-22 16:45 UTC (permalink / raw)
To: u-boot
Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 23:05 Fri 21 Aug , Peter Tyser wrote:
>> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
>> ---
>> common/dlmalloc.c | 15 +++++++++++++++
>> include/malloc.h | 2 ++
>> lib_arm/board.c | 10 ----------
>> lib_avr32/board.c | 15 ++-------------
>> lib_blackfin/board.c | 9 ---------
>> lib_m68k/board.c | 14 +-------------
>> lib_microblaze/board.c | 20 +++++---------------
>> lib_mips/board.c | 14 +-------------
>> lib_nios/board.c | 14 ++------------
>> lib_nios2/board.c | 14 ++------------
>> lib_ppc/board.c | 14 +-------------
>> lib_sh/board.c | 9 ---------
>> lib_sparc/board.c | 21 +--------------------
>> 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
> could we have a generic name (not arch)
> CONFIG_GENERIC_MALLOC_INIT
>
> and then define it in the configs/arch.h
I thought the cleanest fix would be to update the x86 call to
mem_malloc_init() to match all the other architectures', but didn't want
to delve into the x86 arch init code.
I think adding a new CONFIG_* option to handle 1 non-conforming
architecture is dirtier than syncing up the x86 init code in any case.
Best,
Peter
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 16:45 ` Peter Tyser
@ 2009-08-22 22:48 ` Graeme Russ
0 siblings, 0 replies; 13+ messages in thread
From: Graeme Russ @ 2009-08-22 22:48 UTC (permalink / raw)
To: u-boot
On Sun, Aug 23, 2009 at 2:45 AM, Peter Tyser<ptyser@xes-inc.com> wrote:
> Jean-Christophe PLAGNIOL-VILLARD wrote:
>> On 23:05 Fri 21 Aug , Peter Tyser wrote:
>>> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
>>> ---
[snip]
>>>
>>> +#ifndef CONFIG_X86
>> could we have a generic name (not arch)
>> CONFIG_GENERIC_MALLOC_INIT
>>
>> and then define it in the configs/arch.h
>
> I thought the cleanest fix would be to update the x86 call to
> mem_malloc_init() to match all the other architectures', but didn't want
> to delve into the x86 arch init code.
>
> I think adding a new CONFIG_* option to handle 1 non-conforming
> architecture is dirtier than syncing up the x86 init code in any case.
>
I am currently undertaking a fairly significant tidy up of some x86
loose ends. One that I noticed (and have not touched just yet) is how
the x86 allocates the malloc pool. After these (Peter's) patches get
applied, I will revisit the x86 malloc and bring it into line with the
other arches
Regards,
G
> Best,
> Peter
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 1/3] Consolidate arch-specific sbrk() implementations
2009-08-22 4:05 ` [U-Boot] [PATCH 1/3] Consolidate arch-specific sbrk() implementations Peter Tyser
@ 2009-09-04 19:45 ` Wolfgang Denk
0 siblings, 0 replies; 13+ messages in thread
From: Wolfgang Denk @ 2009-09-04 19:45 UTC (permalink / raw)
To: u-boot
Dear Peter Tyser,
In message <1250913921-15689-2-git-send-email-ptyser@xes-inc.com> you wrote:
> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
> ---
> common/dlmalloc.c | 18 +++++++++++++++++-
> include/malloc.h | 6 ++++++
> lib_arm/board.c | 20 --------------------
> lib_avr32/board.c | 19 -------------------
> lib_blackfin/board.c | 20 +++-----------------
> lib_i386/board.c | 21 ---------------------
> lib_m68k/board.c | 20 --------------------
> lib_microblaze/board.c | 19 -------------------
> lib_mips/board.c | 19 -------------------
> lib_nios/board.c | 20 +-------------------
> lib_nios2/board.c | 20 +-------------------
> lib_ppc/board.c | 19 -------------------
> lib_sh/board.c | 18 ------------------
> lib_sparc/board.c | 19 -------------------
> 14 files changed, 28 insertions(+), 230 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Unsichtbar macht sich die Dummheit, indem sie immer gr??ere Ausma?e
annimmt. -- Bertold Brecht: Der Tui-Roman
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 2/3] Standardize mem_malloc_init() implementation
2009-08-22 4:05 ` [U-Boot] [PATCH 2/3] Standardize mem_malloc_init() implementation Peter Tyser
@ 2009-09-04 19:46 ` Wolfgang Denk
0 siblings, 0 replies; 13+ messages in thread
From: Wolfgang Denk @ 2009-09-04 19:46 UTC (permalink / raw)
To: u-boot
Dear Peter Tyser,
In message <1250913921-15689-3-git-send-email-ptyser@xes-inc.com> you wrote:
> This lays the groundwork to allow architectures to share a common
> mem_malloc_init().
>
> Note that the x86 implementation was not modified as it did not fit the
> mold of all other architectures.
>
> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
> ---
> lib_arm/board.c | 14 +++++++-------
> lib_avr32/board.c | 17 +++++++----------
> lib_blackfin/board.c | 12 ++++++------
> lib_m68k/board.c | 17 +++++++----------
> lib_microblaze/board.c | 13 +++++++------
> lib_mips/board.c | 17 +++++++----------
> lib_nios/board.c | 15 +++++++--------
> lib_nios2/board.c | 13 ++++++-------
> lib_ppc/board.c | 21 ++++++++++-----------
> lib_sh/board.c | 14 +++++++-------
> lib_sparc/board.c | 14 ++++++++------
> 11 files changed, 79 insertions(+), 88 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If I ever needed a brain transplant, I'd choose a teenager's because
I'd want a brain that had never been used.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations
2009-08-22 4:05 ` [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations Peter Tyser
2009-08-22 10:51 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-09-04 19:47 ` Wolfgang Denk
1 sibling, 0 replies; 13+ messages in thread
From: Wolfgang Denk @ 2009-09-04 19:47 UTC (permalink / raw)
To: u-boot
Dear Peter Tyser,
In message <1250913921-15689-4-git-send-email-ptyser@xes-inc.com> you wrote:
> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
> ---
> common/dlmalloc.c | 15 +++++++++++++++
> include/malloc.h | 2 ++
> lib_arm/board.c | 10 ----------
> lib_avr32/board.c | 15 ++-------------
> lib_blackfin/board.c | 9 ---------
> lib_m68k/board.c | 14 +-------------
> lib_microblaze/board.c | 20 +++++---------------
> lib_mips/board.c | 14 +-------------
> lib_nios/board.c | 14 ++------------
> lib_nios2/board.c | 14 ++------------
> lib_ppc/board.c | 14 +-------------
> lib_sh/board.c | 9 ---------
> lib_sparc/board.c | 21 +--------------------
> 13 files changed, 32 insertions(+), 139 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q: How do you tell if you're making love to a nurse, a school-
teacher, or an airline stewardess?
A: A nurse says: "This won't hurt a bit." A schoolteacher says:
"We're going to have to do this over and over again until we get
it right." An airline stewardess says: "Just hold this over your
mouth and nose, and breath normally."
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-09-04 19:47 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-22 4:05 [U-Boot] [PATCH 0/3] Clean up up malloc pool init Peter Tyser
2009-08-22 4:05 ` [U-Boot] [PATCH 1/3] Consolidate arch-specific sbrk() implementations Peter Tyser
2009-09-04 19:45 ` Wolfgang Denk
2009-08-22 4:05 ` [U-Boot] [PATCH 2/3] Standardize mem_malloc_init() implementation Peter Tyser
2009-09-04 19:46 ` Wolfgang Denk
2009-08-22 4:05 ` [U-Boot] [PATCH 3/3] Consolidate arch-specific mem_malloc_init() implementations Peter Tyser
2009-08-22 10:51 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-22 11:54 ` Wolfgang Denk
2009-08-22 12:32 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-22 12:49 ` Wolfgang Denk
2009-08-22 16:45 ` Peter Tyser
2009-08-22 22:48 ` Graeme Russ
2009-09-04 19:47 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox