From d384266ca695e158c9f6c759a24843e7c42a92eb Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 29 Sep 2015 15:15:35 +0200 Subject: [PATCH] [liba] Overridable pointer for heap start/end --- ion/src/device/Makefile | 2 +- ion/src/device/boot/flash.ld | 4 ++-- ion/src/device/heap.c | 5 +++++ liba/src/malloc.c | 8 ++++---- 4 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 ion/src/device/heap.c diff --git a/ion/src/device/Makefile b/ion/src/device/Makefile index a27296c79..083f65748 100644 --- a/ion/src/device/Makefile +++ b/ion/src/device/Makefile @@ -1,4 +1,4 @@ include ion/src/device/boot/Makefile -objs += $(addprefix ion/src/device/, init.o) +objs += $(addprefix ion/src/device/, init.o heap.o) objs += $(addprefix ion/src/device/display/, display.o dma.o framebuffer.o gpio.o spi.o st7586.o) objs += $(addprefix ion/src/device/keyboard/, keyboard.o) diff --git a/ion/src/device/boot/flash.ld b/ion/src/device/boot/flash.ld index 2a9f13627..f560019e4 100644 --- a/ion/src/device/boot/flash.ld +++ b/ion/src/device/boot/flash.ld @@ -149,10 +149,10 @@ SECTIONS { } >SRAM .heap : { - _liba_heap_start = .; + _heap_start = .; /* Note: We don't increment "." here, we set it. */ . = (ORIGIN(SRAM) + LENGTH(SRAM) - FRAMEBUFFER_SIZE - STACK_SIZE); - _liba_heap_end = .; + _heap_end = .; } >SRAM .framebuffer : { diff --git a/ion/src/device/heap.c b/ion/src/device/heap.c new file mode 100644 index 000000000..9e61c0bc7 --- /dev/null +++ b/ion/src/device/heap.c @@ -0,0 +1,5 @@ +extern char _heap_start; +extern char _heap_end; + +char * _liba_heap_start = &_heap_start; +char * _liba_heap_end = &_heap_end; diff --git a/liba/src/malloc.c b/liba/src/malloc.c index 7585d1068..334325f17 100644 --- a/liba/src/malloc.c +++ b/liba/src/malloc.c @@ -2,8 +2,8 @@ #include #include -extern char _liba_heap_start; -extern char _liba_heap_end; +extern char * _liba_heap_start; +extern char * _liba_heap_end; heap_config_t HeapConfig = { .nHeap = 0 @@ -17,8 +17,8 @@ void * memsys5Realloc(void *pPrior, int nBytes); int memsys5Roundup(int n); static void configure_heap() { - HeapConfig.nHeap = (&_liba_heap_end - &_liba_heap_start); - HeapConfig.pHeap = &_liba_heap_start; + HeapConfig.nHeap = (_liba_heap_end - _liba_heap_start); + HeapConfig.pHeap = _liba_heap_start; HeapConfig.mnReq = 1; HeapConfig.bMemstat = 0; HeapConfig.xLog = 0;