#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);
 }
 
 
        }
 
        /* 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 */
 
 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
 #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();
 
 
 #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)
 #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)
 
 /*
  * 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);
 }
 
 /*
        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)
 
  * 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);
 }
 
 /*
        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 ();
 
 /*
  * 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);
 }
 
 
        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
 
 /*
  * 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);
 }
 
 
        }
 
        WATCHDOG_RESET ();
-       mem_malloc_init();
+       mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
        malloc_bin_reloc();
 
        WATCHDOG_RESET ();
 
  */
 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);
 }
 
 
        }
 
        WATCHDOG_RESET ();
-       mem_malloc_init();
+       mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
        malloc_bin_reloc();
 
        WATCHDOG_RESET ();
 
 /*
  * 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);
 }
 
 /*
 #ifndef CONFIG_ENV_IS_NOWHERE
        extern char * env_name_spec;
 #endif
+       ulong malloc_start;
 
 #ifndef CONFIG_SYS_NO_FLASH
        ulong flash_size;
 
 #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
        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)
 
 
 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)
 
 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();
 
 /*
  * 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);
 }
 
 /***********************************************************************/
        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)