From a483a167bc8d808145ca1224a2c238cda90aa60c Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Fri, 21 Aug 2009 23:05:20 -0500 Subject: Standardize mem_malloc_init() implementation 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 --- 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 62b787443..904ea89c2 100644 --- a/lib_arm/board.c +++ b/lib_arm/board.c @@ -83,14 +83,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); } @@ -300,7 +299,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 03a520cdd..ca1bd6fd3 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 9c405ba4b..17681f6f8 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 4392bccdb..cbc6b5025 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 fc25a7530..a5d924a1f 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 68a3697f7..b233a6c8a 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 30cdb477c..745e0a4d9 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 e5a8d5406..2c470dd9f 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 f0cc3ce8d..6cf773009 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); } /* @@ -650,6 +646,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; @@ -662,9 +659,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 @@ -760,7 +759,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 001e89c71..269131604 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 37b7c0a59..e69431f8b 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) -- cgit v1.2.3