diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index dffe59d9b..a522046f3 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -18,23 +18,23 @@ platform-headers := \ platform-libsys := \ _hol0.s \ + errno.s \ phys_to_user.s \ user_to_phys.s \ uart.s \ - write.c \ - -ifeq (x,y) - errno.s \ - _sys_rawread.s \ - _sys_rawwrite.s \ - open.c \ creat.c \ close.c \ + open.c \ read.c \ + write.c \ + isatty.c \ brk.c \ + +ifeq (x,y) + _sys_rawread.s \ + _sys_rawwrite.s \ getpid.c \ kill.c \ - isatty.c \ lseek.c \ time.c \ signal.c diff --git a/plat/rpi/libsys/brk.c b/plat/rpi/libsys/brk.c index cff32b9a9..2c44347d4 100644 --- a/plat/rpi/libsys/brk.c +++ b/plat/rpi/libsys/brk.c @@ -8,25 +8,25 @@ #include #include #include +#include #define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ -#define STACK_BUFFER 128 /* number of bytes to leave for stack */ +#define STACK_BUFFER 1024 /* number of bytes to leave for stack */ extern char _end[1]; static char* current = _end; +/* Top of heap: we assume that the block of memory the binary is loaded in + * is 256kB long. Because user pointers are always relative to the beginning + * of the block, this makes the end address easy to calculate. */ +static char* max = (char*) (256*1024); + int brk(void* newend) { - /* This variable is used to figure out the current stack pointer, - * by taking its address. */ - char dummy; - char* p = newend; - - if ((p > (&dummy - STACK_BUFFER)) || - (p < _end)) + if ((newend >= (void*)max) || (newend < (void*)_end)) return -1; - - current = p; + + current = newend; return 0; }