diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2007-07-05 18:01:29 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-07-05 18:01:29 +0200 |
commit | 53d3195be1e45609f96b809bd5709eedee4c5829 (patch) | |
tree | e26d13287bf5841319e4f5509a39418f220df248 | |
parent | abfeb961e0ea5aed05acc8e672d497d9dfcc7835 (diff) | |
download | barebox-53d3195be1e45609f96b809bd5709eedee4c5829.tar.gz barebox-53d3195be1e45609f96b809bd5709eedee4c5829.tar.xz |
svn_rev_167
ppc startup cleaunup
-rw-r--r-- | arch/arm/lib/arm.c | 10 | ||||
-rw-r--r-- | common/misc.c | 32 | ||||
-rw-r--r-- | include/mem_malloc.h | 7 |
3 files changed, 49 insertions, 0 deletions
diff --git a/arch/arm/lib/arm.c b/arch/arm/lib/arm.c new file mode 100644 index 0000000000..937623ba00 --- /dev/null +++ b/arch/arm/lib/arm.c @@ -0,0 +1,10 @@ +#include <init.h> +#include <mem_malloc.h> + +int arm_mem_alloc_init(void) +{ + mem_alloc_init(_armboot_start - CFG_MALLOC_LEN, + _armboot_start); +} + +core_initcall(arm_mem_alloc_init); diff --git a/common/misc.c b/common/misc.c new file mode 100644 index 0000000000..b3c47ef62d --- /dev/null +++ b/common/misc.c @@ -0,0 +1,32 @@ + +#include <mem_malloc.h> + +/* + * 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; + +void mem_malloc_init (ulong start, ulong end) +{ + mem_malloc_start = start; + mem_malloc_end = end; + mem_malloc_brk = 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); +} diff --git a/include/mem_malloc.h b/include/mem_malloc.h new file mode 100644 index 0000000000..847eefc18f --- /dev/null +++ b/include/mem_malloc.h @@ -0,0 +1,7 @@ +#ifndef __MEM_MALLOC_H +#define __MEM_MALLOC_H + +void mem_malloc_init (ulong start, ulong end); +void *sbrk (ptrdiff_t increment); + +#endif |