diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2011-01-24 22:10:45 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2011-01-24 22:10:45 +0100 |
commit | 250095c7bc783f415b3958b1099216e8953600e7 (patch) | |
tree | e649e72f7a9659c1abe7121ef957f15c1aa49610 | |
parent | eee119de6a2bd0487e91daf69e7962351e2a3c9c (diff) |
The heap needs to be anonymous; adding generic __heap_start and __heap_end symbols. Also marking the beginning and the end of the rom-to-ram sections.
-rw-r--r-- | arch/arm/lpc17xx/ldscript | 15 | ||||
-rw-r--r-- | arch/arm/lpc17xx/ldscript-mpu | 18 | ||||
-rw-r--r-- | os/src/sbrk.c | 6 |
3 files changed, 36 insertions, 3 deletions
diff --git a/arch/arm/lpc17xx/ldscript b/arch/arm/lpc17xx/ldscript index 0f8fe23..422fe72 100644 --- a/arch/arm/lpc17xx/ldscript +++ b/arch/arm/lpc17xx/ldscript @@ -43,6 +43,9 @@ PROVIDE(__cs3_stack_size = __cs3_region_start_ram + __cs3_region_size_ram - _end PROVIDE(__cs3_heap_start = _end); PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram); +PROVIDE(__heap_start = __cs3_heap_start); +PROVIDE(__heap_end = __cs3_heap_end); + SECTIONS { .text : @@ -133,6 +136,12 @@ SECTIONS __cs3_region_size_rom = LENGTH(rom); __cs3_region_num = 1; + .data_begin : + { + . = ALIGN(8); + __rom_data_begin = .; + } > rom + .data : { __cs3_region_start_ram = .; @@ -155,6 +164,12 @@ SECTIONS _end = .; __end = .; } >ram AT>rom + .data_end : + { + . = ALIGN(8); + __rom_data_end = .; + } > rom + /* This used for USB RAM section */ .usb_ram (NOLOAD): { diff --git a/arch/arm/lpc17xx/ldscript-mpu b/arch/arm/lpc17xx/ldscript-mpu index 3af58a9..df8551c 100644 --- a/arch/arm/lpc17xx/ldscript-mpu +++ b/arch/arm/lpc17xx/ldscript-mpu @@ -43,6 +43,11 @@ PROVIDE(__cs3_stack_size = __cs3_region_start_ram + __cs3_region_size_ram - _end PROVIDE(__cs3_heap_start = _end); PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram); +PROVIDE(__rom_data_len = __rom_data_end - __rom_data_begin); + +PROVIDE(__heap_start = __cs3_heap_start); +PROVIDE(__heap_end = __cs3_heap_end); + SECTIONS { .text : @@ -147,10 +152,17 @@ SECTIONS } >rom __cs3_region_size_rom = LENGTH(rom); __cs3_region_num = 1; + + .data_begin : + { + . = ALIGN(8); + __rom_data_begin = .; + } > rom .data : { __cs3_region_start_ram = .; + __ram_data_begin = .; __privileged_data_start__ = .; *( privileged_data ) __privileged_data_end___len = . - __privileged_data_start__ - 1 ; @@ -181,6 +193,12 @@ SECTIONS _end = .; __end = .; } >ram AT>rom + .data_end : + { + . = ALIGN(8); + __rom_data_end = .; + } > rom + /* This used for USB RAM section */ .usb_ram (NOLOAD): { diff --git a/os/src/sbrk.c b/os/src/sbrk.c index 3c674ba..221c809 100644 --- a/os/src/sbrk.c +++ b/os/src/sbrk.c @@ -8,7 +8,7 @@ // Mostly stolen from mbed-freertos -extern unsigned int __cs3_heap_start, __cs3_heap_end; +extern unsigned int __heap_start, __heap_end; /* Low-level bulk RAM allocator -- used by Newlib's Malloc */ void *heap_end = NULL; @@ -21,7 +21,7 @@ PRIVILEGED_FUNCTION void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr) /* Initialize on first call */ if (heap_end == NULL) { - heap_end = (void *)&__cs3_heap_start; + heap_end = (void *)&__heap_start; } prev_heap_end = heap_end; @@ -30,7 +30,7 @@ PRIVILEGED_FUNCTION void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr) next_heap_end = (void *)((((unsigned int)heap_end + incr) + 7) & ~7); /* Check if this allocation would exceed the end of the ram - would probably get into the stack first however */ - if (next_heap_end > (void *)&__cs3_heap_end) + if (next_heap_end > (void *)&__heap_end) { ptr->_errno = ENOMEM; ret = NULL; |