add heap and _sbrk to mc13224v

This commit is contained in:
Mariano Alvira 2011-02-06 14:29:01 -05:00
parent 9572baa71b
commit f5ba70cd20
2 changed files with 25 additions and 2 deletions

View file

@ -36,6 +36,7 @@
#include <stdio.h>
#include "contiki.h"
#include "mc1322x.h"
#include <sys/types.h>
int raise(void)
{
@ -49,3 +50,25 @@ void srand(unsigned int seed) {
int rand(void) {
return (int)*MACA_RANDOM;
}
extern int __HEAP_START;
extern int __HEAP_END;
caddr_t _sbrk ( int incr )
{
static unsigned char *heap = NULL;
unsigned char *prev_heap;
if (heap == NULL) {
heap = (unsigned char *)&__HEAP_START;
}
prev_heap = heap;
/* check removed to show basic approach */
if((heap + incr) >= (unsigned char *)&__HEAP_END) return((void *)-1);
heap += incr;
return (caddr_t) prev_heap;
}

View file

@ -215,11 +215,11 @@ HEAP_SIZE = 1024;
. = ALIGN(32 / 8);
.heap : {
__heap_start__ = . ;
__heap_start__ = . ; PROVIDE(__HEAP_START = .);
*(.heap);
. += HEAP_SIZE;
. = ALIGN (4);
__heap_end__ = . ;
__heap_end__ = . ; PROVIDE(__HEAP_END = .);
}