]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Consolidate arch-specific sbrk() implementations
authorPeter Tyser <ptyser@xes-inc.com>
Sat, 22 Aug 2009 04:05:19 +0000 (23:05 -0500)
committerTom Rix <Tom.Rix@windriver.com>
Sat, 3 Oct 2009 14:04:08 +0000 (09:04 -0500)
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
14 files changed:
common/dlmalloc.c
include/malloc.h
lib_arm/board.c
lib_avr32/board.c
lib_blackfin/board.c
lib_i386/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 4a185620f98203d74c7bfdc30f2c669d7c8391da..f3bced463fd10773069ba14f5c23c6b781d84c69 100644 (file)
@@ -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 */
 
index a38464e62915c05362179d14e9381e2174f5babb..0382169b6a013b241340b926dbacaedd3b9a7246 100644 (file)
@@ -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" */
index fa87d51373156b7f87bd1d979c47e7053696c557..62b78744372efbd62fce89a3ed88b8acec1c5253 100644 (file)
@@ -82,13 +82,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)
 {
@@ -100,19 +93,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
index e2b0a2e1a2e9022398d34de551a5b403056aeba1..03a520cddc30eda0166ecbcde34ac09c9f6a1963 100644 (file)
@@ -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>
index 5b9efde7a23cc030589a63aea065bc19482432bf..9c405ba4bd6556b131aa467006cdcf42fcc15dff 100644 (file)
@@ -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)
index 54ef6e75a835543c4735a1fc2cbdbc2b6ad9fafa..0262b5e2cb8d77a220d6503b17126c06ac51b94f 100644 (file)
@@ -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                                                      *
  ************************************************************************
index 483c9b6df891a435f697214219bafcefe4e084fc..4392bccdbaefda50621694e44c9737fc72339554 100644 (file)
@@ -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
index cfed5fefcd7b958b87d41db10aa68c10167fc930..fc25a7530529b1adffb49df5675b4aee3e442bed 100644 (file)
@@ -46,13 +46,6 @@ extern int eth_init (bd_t * bis);
 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
@@ -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
index aa5b1295ce24d3f8dba3f294e68a548c36c29591..68a3697f74089f4ca43c47f5c4dc2ce76f1c31fe 100644 (file)
@@ -59,13 +59,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)
 {
index cd234578b7474cb16e74ddfae70592d882ea1e83..30cdb477cf0474076e5b3e7264214d1f1fa1b8ad 100644 (file)
@@ -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>
@@ -51,13 +52,6 @@ DECLARE_GLOBAL_DATA_PTR;
 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
  */
@@ -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                                             *
index b142c59613796fa894088d7b6f69508aa60071eb..e5a8d54069e652e86d2040ee15e1f4a84c4dc0d6 100644 (file)
@@ -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>
@@ -54,13 +55,6 @@ DECLARE_GLOBAL_DATA_PTR;
 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
  */
@@ -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                                             *
index 9faf7f2a0b438ebbc12f11f25a4ba7b010461abb..f0cc3ce8d85e8c73913185cee4deaf73f4da8329 100644 (file)
@@ -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
index 829455d8b12fa031b0801b64aa2b6443529877fe..001e89c7143c87184b920a9ab3bf7b93dd72e13a 100644 (file)
@@ -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;
index d40834b7b02cfb5094664bff804acaaeb584c0a7..37b7c0a5946a38d2cbb8e3c8d5fd0d3d8885dccb 100644 (file)
@@ -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);
-}
-
 /***********************************************************************/
 
 /************************************************************************