Consolidate arch-specific sbrk() implementations
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
This commit is contained in:
parent
65f6f07b72
commit
5e93bd1c9a
|
@ -1502,7 +1502,23 @@ void malloc_bin_reloc (void)
|
||||||
*p++ += gd->reloc_off;
|
*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 */
|
/* field-extraction macros */
|
||||||
|
|
||||||
|
|
|
@ -937,6 +937,12 @@ int mALLOPt();
|
||||||
struct mallinfo mALLINFo();
|
struct mallinfo mALLINFo();
|
||||||
#endif
|
#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
|
#ifdef __cplusplus
|
||||||
}; /* end of extern "C" */
|
}; /* end of extern "C" */
|
||||||
|
|
|
@ -82,13 +82,6 @@ extern void rtl8019_get_enetaddr (uchar * addr);
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#endif
|
#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
|
static
|
||||||
void mem_malloc_init (ulong dest_addr)
|
void mem_malloc_init (ulong dest_addr)
|
||||||
{
|
{
|
||||||
|
@ -100,19 +93,6 @@ void mem_malloc_init (ulong dest_addr)
|
||||||
mem_malloc_end - mem_malloc_start);
|
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
|
* Coloured LED functionality
|
||||||
|
|
|
@ -41,13 +41,6 @@ const char version_string[] =
|
||||||
|
|
||||||
unsigned long monitor_flash_len;
|
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 */
|
/* Weak aliases for optional board functions */
|
||||||
static int __do_nothing(void)
|
static int __do_nothing(void)
|
||||||
{
|
{
|
||||||
|
@ -73,18 +66,6 @@ static void mem_malloc_init(void)
|
||||||
mem_malloc_end - mem_malloc_start);
|
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
|
#ifdef CONFIG_SYS_DMA_ALLOC_LEN
|
||||||
#include <asm/arch/cacheflush.h>
|
#include <asm/arch/cacheflush.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
|
|
@ -44,27 +44,13 @@ static inline void serial_early_puts(const char *s)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mem_malloc_start, *mem_malloc_end, *mem_malloc_brk;
|
|
||||||
|
|
||||||
static void mem_malloc_init(void)
|
static void mem_malloc_init(void)
|
||||||
{
|
{
|
||||||
mem_malloc_start = (void *)CONFIG_SYS_MALLOC_BASE;
|
mem_malloc_start = (ulong)CONFIG_SYS_MALLOC_BASE;
|
||||||
mem_malloc_end = (void *)(CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN);
|
mem_malloc_end = (ulong)(CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN);
|
||||||
mem_malloc_brk = mem_malloc_start;
|
mem_malloc_brk = mem_malloc_start;
|
||||||
memset(mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *sbrk(ptrdiff_t increment)
|
memset((void*)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int display_banner(void)
|
static int display_banner(void)
|
||||||
|
|
|
@ -73,14 +73,6 @@ ulong i386boot_bios_size = (ulong)&_i386boot_bios_size; /* size of BIOS
|
||||||
const char version_string[] =
|
const char version_string[] =
|
||||||
U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")";
|
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)
|
static int mem_malloc_init(void)
|
||||||
{
|
{
|
||||||
/* start malloc area right after the stack */
|
/* start malloc area right after the stack */
|
||||||
|
@ -96,19 +88,6 @@ static int mem_malloc_init(void)
|
||||||
return 0;
|
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 *
|
* Init Utilities *
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
|
|
@ -101,13 +101,6 @@ extern int watchdog_disable(void);
|
||||||
|
|
||||||
ulong monitor_flash_len;
|
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 *
|
* Utilities *
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -129,19 +122,6 @@ static void mem_malloc_init (void)
|
||||||
mem_malloc_end - mem_malloc_start);
|
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
|
* All attempts to come up with a "common" initialization sequence
|
||||||
* that works for all boards and architectures failed: some of the
|
* that works for all boards and architectures failed: some of the
|
||||||
|
|
|
@ -46,13 +46,6 @@ extern int eth_init (bd_t * bis);
|
||||||
extern int getenv_IPaddr (char *);
|
extern int getenv_IPaddr (char *);
|
||||||
#endif
|
#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
|
* The Malloc area is immediately below the monitor copy in DRAM
|
||||||
* aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
|
* 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);
|
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
|
* All attempts to come up with a "common" initialization sequence
|
||||||
* that works for all boards and architectures failed: some of the
|
* that works for all boards and architectures failed: some of the
|
||||||
|
|
|
@ -59,13 +59,6 @@ const char version_string[] =
|
||||||
|
|
||||||
static char *failed = "*** failed ***\n";
|
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
|
* mips_io_port_base is the begin of the address space to which x86 style
|
||||||
* I/O ports are mapped.
|
* I/O ports are mapped.
|
||||||
|
@ -97,18 +90,6 @@ static void mem_malloc_init (void)
|
||||||
mem_malloc_end - mem_malloc_start);
|
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)
|
static int init_func_ram (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <stdio_dev.h>
|
#include <stdio_dev.h>
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
|
#include <malloc.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#ifdef CONFIG_STATUS_LED
|
#ifdef CONFIG_STATUS_LED
|
||||||
#include <status_led.h>
|
#include <status_led.h>
|
||||||
|
@ -51,13 +52,6 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
extern void malloc_bin_reloc (void);
|
extern void malloc_bin_reloc (void);
|
||||||
typedef int (init_fnc_t) (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
|
* 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);
|
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 *
|
* Initialization sequence *
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <stdio_dev.h>
|
#include <stdio_dev.h>
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
|
#include <malloc.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#ifdef CONFIG_STATUS_LED
|
#ifdef CONFIG_STATUS_LED
|
||||||
#include <status_led.h>
|
#include <status_led.h>
|
||||||
|
@ -54,13 +55,6 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
extern void malloc_bin_reloc (void);
|
extern void malloc_bin_reloc (void);
|
||||||
typedef int (init_fnc_t) (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
|
* 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);
|
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 *
|
* Initialization sequence *
|
||||||
|
|
|
@ -136,13 +136,6 @@ ulong monitor_flash_len;
|
||||||
#include <bedbug/type.h>
|
#include <bedbug/type.h>
|
||||||
#endif
|
#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 *
|
* Utilities *
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -164,18 +157,6 @@ static void mem_malloc_init (void)
|
||||||
mem_malloc_end - mem_malloc_start);
|
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
|
* All attempts to come up with a "common" initialization sequence
|
||||||
* that works for all boards and architectures failed: some of the
|
* that works for all boards and architectures failed: some of the
|
||||||
|
|
|
@ -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;
|
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)
|
static void mem_malloc_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -52,20 +48,6 @@ static void mem_malloc_init(void)
|
||||||
(mem_malloc_end - mem_malloc_start));
|
(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)
|
static int sh_flash_init(void)
|
||||||
{
|
{
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
|
@ -74,13 +74,6 @@ static char *failed = "*** failed ***\n";
|
||||||
|
|
||||||
ulong monitor_flash_len;
|
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 *
|
* Utilities *
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -97,18 +90,6 @@ static void mem_malloc_init(void)
|
||||||
memset((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue