]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Standardize mem_malloc_init() implementation
authorPeter Tyser <ptyser@xes-inc.com>
Sat, 22 Aug 2009 04:05:20 +0000 (23:05 -0500)
committerTom Rix <Tom.Rix@windriver.com>
Sat, 3 Oct 2009 14:04:08 +0000 (09:04 -0500)
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
lib_avr32/board.c
lib_blackfin/board.c
lib_m68k/board.c
lib_microblaze/board.c
lib_mips/board.c
lib_nios/board.c
lib_nios2/board.c
lib_ppc/board.c
lib_sh/board.c
lib_sparc/board.c

index 62b78744372efbd62fce89a3ed88b8acec1c5253..904ea89c2d294772d39c2390ef8b37b8dc21f0b4 100644 (file)
@@ -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 */
index 03a520cddc30eda0166ecbcde34ac09c9f6a1963..ca1bd6fd3290c28e15098d41fce2843ce9b9e12b 100644 (file)
@@ -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();
 
index 9c405ba4bd6556b131aa467006cdcf42fcc15dff..17681f6f8ead52e9263082f40b2617de616b215d 100644 (file)
@@ -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)
index 4392bccdbaefda50621694e44c9737fc72339554..cbc6b50258a3cf088342b9e0bb384fee65e32acf 100644 (file)
@@ -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)
index fc25a7530529b1adffb49df5675b4aee3e442bed..a5d924a1f333aaa204b5981aef2b71d921d863b8 100644 (file)
@@ -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 ();
index 68a3697f74089f4ca43c47f5c4dc2ce76f1c31fe..b233a6c8a95e91caadf82466690012af8cdd97f7 100644 (file)
@@ -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
index 30cdb477cf0474076e5b3e7264214d1f1fa1b8ad..745e0a4d9831066a108e35b7d620aa56f11fc057 100644 (file)
@@ -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 ();
index e5a8d54069e652e86d2040ee15e1f4a84c4dc0d6..2c470dd9f41d3d4c3467781f1cc11287ec7cef9e 100644 (file)
@@ -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 ();
index f0cc3ce8d85e8c73913185cee4deaf73f4da8329..6cf773009510095b97d4bf8069974b58f9ea993f 100644 (file)
@@ -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)
index 001e89c7143c87184b920a9ab3bf7b93dd72e13a..26913160463387e4c9891469ff0997f53996dc46 100644 (file)
@@ -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();
index 37b7c0a5946a38d2cbb8e3c8d5fd0d3d8885dccb..e69431f8b896e5de9c1d6ea8f0c554ff192250fc 100644 (file)
@@ -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)