Clean up up malloc pool init
cover Clean up up malloc pool init
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(-)
PATCH 1/3 Consolidate arch-specific sbrk() implementations
--- 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(-)
common/dlmalloc.c +17 -1
@@ -1502,7 +1502,23 @@ void malloc_bin_reloc (void) *p++ += gd->reloc_off; } } - + +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 */
include/malloc.h +6 -0
@@ -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" */
lib_arm/board.c +0 -20
@@ -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
lib_avr32/board.c +0 -19
@@ -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>
lib_blackfin/board.c +3 -17
@@ -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 )
lib_i386/board.c +0 -21
@@ -73,14 +73,6 @@ ulong i386boot_bios_size = (ulong)&_i386boot_bios_size; /* size of BIOSconst 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 * ************************************************************************
lib_m68k/board.c +0 -20
@@ -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
lib_microblaze/board.c +0 -19
@@ -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
lib_mips/board.c +0 -19
@@ -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 ) {
lib_nios/board.c +1 -19
@@ -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 *
lib_nios2/board.c +1 -19
@@ -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 *
lib_ppc/board.c +0 -19
@@ -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
lib_sh/board.c +0 -18
@@ -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 ;
lib_sparc/board.c +0 -19
@@ -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); -} -/***********************************************************************/ /************************************************************************
Signature · 1 line
1.6.2.1
Wolfgang Denk
AppliedPATCH 1/3 Consolidate arch-specific sbrk() implementations
Dear Peter Tyser,
Quoted 17 lines · In message <[email protected]> you wrote:
Signed-off-by Peter Tyser <[email protected]>--- 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
Signature · 5 lines
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
PATCH 2/3 Standardize mem_malloc_init() implementation
In reply to Peter TyserThis 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.
--- 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(-)
lib_arm/board.c +7 -7
@@ -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 */
lib_avr32/board.c +7 -10
@@ -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 ();
lib_blackfin/board.c +6 -6
@@ -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 )
lib_m68k/board.c +7 -10
@@ -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 )
lib_microblaze/board.c +7 -6
@@ -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 ();
lib_mips/board.c +7 -10
@@ -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
lib_nios/board.c +7 -8
@@ -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 ();
lib_nios2/board.c +6 -7
@@ -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 ();
lib_ppc/board.c +10 -11
@@ -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 )
lib_sh/board.c +7 -7
@@ -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 ();
lib_sparc/board.c +8 -6
@@ -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 )
Signature · 1 line
1.6.2.1
Wolfgang Denk
AppliedPATCH 2/3 Standardize mem_malloc_init() implementation
Dear Peter Tyser,
Quoted 7 lines · In message <[email protected]> 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 <[email protected]>
Quoted 13 lines
--- 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
Signature · 5 lines
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.
PATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
In reply to Peter Tyser--- 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(-)
common/dlmalloc.c +15 -0
@@ -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)
include/malloc.h +2 -0
@@ -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
lib_arm/board.c +0 -10
@@ -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
lib_avr32/board.c +2 -13
@@ -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 ();
lib_blackfin/board.c +0 -9
@@ -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);
lib_m68k/board.c +1 -13
@@ -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 ();
lib_microblaze/board.c +5 -15
@@ -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) {
lib_mips/board.c +1 -13
@@ -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 ();
lib_nios/board.c +2 -12
@@ -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 ();
lib_nios2/board.c +2 -12
@@ -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 ();
lib_ppc/board.c +1 -13
@@ -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 ();
lib_sh/board.c +0 -9
@@ -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 ;
lib_sparc/board.c +1 -20
@@ -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 ();
Signature · 1 line
1.6.2.1
PATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
Quoted 22 lines · Peter Tyser
Signed-off-by Peter Tyser <[email protected]>--- 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(-)common/dlmalloc.c +0
-0
common/dlmalloc.c void *sbrk(ptrdiff_t increment) · line 1523
Quoted 4 lines
common/dlmalloc.c +1
-0@@ -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
Quoted 22 lines
common/dlmalloc.c +14
-0+/* +* 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)include/malloc.h +0
-0
include/malloc.h extern ulong mem_malloc_start; · line 946
Quoted 3 lines
include/malloc.h +0
-0@@ -944,6 +944,8 @@ extern ulong mem_malloc_start;extern ulong mem_malloc_end;extern ulong mem_malloc_brk;
Best Regards,
J.
PATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 24 lines · In message <[email protected]> you wrote:
Quoted 24 lines
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(-)common/dlmalloc.c +0
-0@@ -1520,6 +1520,21 @@ void *sbrk(ptrdiff_t increment)return (void *)old; }
Quoted 3 lines
common/dlmalloc.c void *sbrk(ptrdiff_t increment) · line 1523
Quoted 1 line
common/dlmalloc.c +1
-0+#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).
Quoted 1 line
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
Signature · 4 lines
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!
PATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
Quoted 27 lines · Wolfgang Denk
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 24 lines · In message <[email protected]> you wrote:
Quoted 24 lines
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(-)common/dlmalloc.c +0
-0@@ -1520,6 +1520,21 @@ void *sbrk(ptrdiff_t increment)return (void *)old; }
Quoted 8 lines
Quoted 3 lines
common/dlmalloc.c void *sbrk(ptrdiff_t increment) · line 1523
Quoted 1 line
common/dlmalloc.c +1
-0+#ifndef CONFIG_X86 could we have a generic name (not arch)
CONFIG_GENERIC_MALLOC_INITThat 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
Quoted 5 lines
Quoted 2 lines
and then define it in the
configs/arch.hWhat 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.
PATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 5 lines
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?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
and then define it in the
configs/arch.hWhat 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
Signature · 5 lines
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
PATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 26 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 25 lines · Peter Tyser
Signed-off-by Peter Tyser <[email protected]>--- 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(-)common/dlmalloc.c +0
-0@@ -1520,6 +1520,21 @@ void *sbrk(ptrdiff_t increment)return (void *)old; }
Quoted 5 lines
common/dlmalloc.c void *sbrk(ptrdiff_t increment) · line 1523
Quoted 1 line
common/dlmalloc.c +1
-0+#ifndef CONFIG_X86 could we have a generic name (not arch)
CONFIG_GENERIC_MALLOC_INITand 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
PATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
Quoted 4 lines · Peter Tyser
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 2 lines · Peter Tyser
Signed-off-by Peter Tyser <[email protected]>---
[snip]
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
+#ifndef
CONFIG_X86could we have a generic name (not arch)
CONFIG_GENERIC_MALLOC_INIT
Quoted 9 lines
Quoted 1 line
and then define it in the
configs/arch.hI 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
Quoted 7 lines
Best,
Peter
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Wolfgang Denk
AppliedPATCH 3/3 Consolidate arch-specific mem_malloc_init() implementations
In reply to Peter TyserDear Peter Tyser,
Quoted 16 lines · In message <[email protected]> you wrote:
Signed-off-by Peter Tyser <[email protected]>--- 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
Signature · 9 lines
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."