Define heap/stack start and size based on linker script symbols for ARM and GCC_ARM

pull/9092/head
Przemyslaw Stekiel 2018-12-20 10:09:17 +01:00
parent 14c6ac9c4b
commit 1739d7e6dd
4 changed files with 24 additions and 7 deletions

View File

@ -25,6 +25,10 @@ extern uint32_t __initial_sp[];
extern uint32_t __heap_base[];
extern uint32_t __heap_limit[];
#if !defined(ISR_STACK_SIZE)
#define ISR_STACK_SIZE ((uint32_t)1024)
#endif
/*
* mbed entry point for the MICROLIB toolchain
*

View File

@ -27,11 +27,20 @@
__value_in_regs struct __argc_argv __rt_lib_init(unsigned heapbase, unsigned heaptop);
void _platform_post_stackheap_init(void);
#if !defined(ISR_STACK_SIZE)
#if (defined(__CC_ARM))
extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[];
extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Length[];
#define ISR_STACK_START ((unsigned char*)Image$$ARM_LIB_STACK$$ZI$$Base)
#define ISR_STACK_SIZE ((uint32_t)Image$$ARM_LIB_STACK$$ZI$$Length)
#endif
#endif
#if !defined(HEAP_START)
/* Defined by linker script */
extern uint32_t Image$$RW_IRAM1$$ZI$$Limit[];
#define HEAP_START ((unsigned char*)Image$$RW_IRAM1$$ZI$$Limit)
#define HEAP_SIZE ((uint32_t)((uint32_t)INITIAL_SP - (uint32_t)HEAP_START))
#define HEAP_SIZE ((uint32_t)((uint32_t)ISR_STACK_START - (uint32_t)HEAP_START))
#endif
/*

View File

@ -29,11 +29,20 @@ static osMutexId_t env_mutex_id;
static mbed_rtos_storage_mutex_t env_mutex_obj;
static osMutexAttr_t env_mutex_attr;
#if !defined(ISR_STACK_SIZE)
#if (defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC_VERSION))
extern uint32_t __StackLimit;
extern uint32_t __StackTop;
#define ISR_STACK_START ((unsigned char*)&__StackLimit)
#define ISR_STACK_SIZE ((uint32_t)((uint32_t)&__StackTop - (uint32_t)&__StackLimit))
#endif
#endif
#if !defined(HEAP_START)
/* Defined by linker script */
extern uint32_t __end__[];
#define HEAP_START ((unsigned char*)__end__)
#define HEAP_SIZE ((uint32_t)((uint32_t)INITIAL_SP - (uint32_t)HEAP_START))
#define HEAP_SIZE ((uint32_t)((uint32_t)ISR_STACK_START - (uint32_t)HEAP_START))
#endif
extern void __libc_init_array(void);

View File

@ -50,11 +50,6 @@ extern "C" {
* @{
*/
/* Define stack sizes if they haven't been set already */
#if !defined(ISR_STACK_SIZE)
#define ISR_STACK_SIZE ((uint32_t)1024)
#endif
/* Heap limits - only used if set */
extern unsigned char *mbed_heap_start;
extern uint32_t mbed_heap_size;