9
0
Fork 0

svn_rev_167

ppc startup cleaunup
This commit is contained in:
Sascha Hauer 2007-07-05 18:01:29 +02:00 committed by Sascha Hauer
parent abfeb961e0
commit 53d3195be1
3 changed files with 49 additions and 0 deletions

10
arch/arm/lib/arm.c Normal file
View File

@ -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);

32
common/misc.c Normal file
View File

@ -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);
}

7
include/mem_malloc.h Normal file
View File

@ -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