From f52af4876b0ffc98055fba237fb01852f1bfaaae Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 12 Sep 2011 16:24:43 -0400 Subject: [support/ld] Add linker support for reconfigurable heap. - common_header.inc: Declare EXTERN symbols _lm_heap_start and _lm_heap_end. - common_rom.inc: Check for _lm_heap_start and _lm_heap_end. If they are defined, preserve their values. Otherwise, _lm_heap_start is starts after .bss, and _lm_heap_end is the end of SRAM. This allows existing linker scripts to continue using the old heap scheme, but allows for customizability elsewhere. - syscalls.c: Respect the addresses of _lm_heap_start and _lm_heap_end as the boundaries of the heap in _sbrk(). --- libmaple/syscalls.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'libmaple/syscalls.c') diff --git a/libmaple/syscalls.c b/libmaple/syscalls.c index f28202c..a3f12f1 100644 --- a/libmaple/syscalls.c +++ b/libmaple/syscalls.c @@ -29,20 +29,12 @@ #include #include -/* Set by the linker script */ -extern int _end; +/* Set by the linker */ +extern char _lm_heap_start; +extern char _lm_heap_end; -/* FIXME these should be determined by the linker script. - * - * Doing so will allow the heap to be configured on a per-board basis. - * Current values are just stopgaps for a heap in built-in SRAM. - * - * STACK_RESERVED_BYTES is just a hack to ensure a minimum stack size. - * It should probably go away as well. */ -#define STACK_RESERVED_BYTES 1024 -#define HEAP_START ((caddr_t)&_end) -#define HEAP_END ((caddr_t)((uint32)STM32_SRAM_END - \ - STACK_RESERVED_BYTES)) +#define HEAP_START ((caddr_t)&_lm_heap_start) +#define HEAP_END ((caddr_t)&_lm_heap_end) /* * _sbrk -- Increment the program break. -- cgit v1.2.3