From b36147fbe9334c683cee61ec3aca735693c258c3 Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Sun, 10 Feb 2019 17:17:17 -0600 Subject: [PATCH] ISR_Stack_start/size defines are not needed, use linker file defines --- platform/mbed_retarget.cpp | 10 ++---- .../TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c | 14 +++----- rtos/TARGET_CORTEX/mbed_boot.c | 36 ++++++------------- targets/TARGET_RENESAS/mbed_rtx.h | 4 +-- 4 files changed, 18 insertions(+), 46 deletions(-) diff --git a/platform/mbed_retarget.cpp b/platform/mbed_retarget.cpp index 0fdf8af275..4c6fc93455 100644 --- a/platform/mbed_retarget.cpp +++ b/platform/mbed_retarget.cpp @@ -917,18 +917,12 @@ __asm(".global __use_no_semihosting\n\t"); #pragma import(__use_two_region_memory) #endif -#if !defined(ISR_STACK_START) -extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[]; -extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Length[]; -#define ISR_STACK_START Image$$ARM_LIB_STACK$$ZI$$Base -#define ISR_STACK_SIZE Image$$ARM_LIB_STACK$$ZI$$Length -#endif - #if !defined(HEAP_START) // Heap here is considered starting after ZI ends to Stack start +extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[]; extern uint32_t Image$$RW_IRAM1$$ZI$$Limit[]; #define HEAP_START Image$$RW_IRAM1$$ZI$$Limit -#define HEAP_SIZE ((uint32_t)((uint32_t)ISR_STACK_START - (uint32_t)HEAP_START)) +#define HEAP_SIZE ((uint32_t)((uint32_t) Image$$ARM_LIB_STACK$$ZI$$Base - (uint32_t) HEAP_START)) #endif #define HEAP_LIMIT ((uint32_t)((uint32_t)HEAP_START + (uint32_t)HEAP_SIZE)) diff --git a/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c b/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c index f3f6c16b4f..412058517d 100644 --- a/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c +++ b/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c @@ -27,18 +27,14 @@ __value_in_regs struct __argc_argv __rt_lib_init(unsigned heapbase, unsigned heaptop); void _platform_post_stackheap_init(void); -#if !defined(ISR_STACK_START) extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[]; extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Length[]; -#define ISR_STACK_START Image$$ARM_LIB_STACK$$ZI$$Base -#define ISR_STACK_SIZE Image$$ARM_LIB_STACK$$ZI$$Length -#endif #if !defined(HEAP_START) // Heap here is considered starting after ZI ends to Stack start extern uint32_t Image$$RW_IRAM1$$ZI$$Limit[]; #define HEAP_START Image$$RW_IRAM1$$ZI$$Limit -#define HEAP_SIZE ((uint32_t)((uint32_t)ISR_STACK_START - (uint32_t)HEAP_START)) +#define HEAP_SIZE ((uint32_t)((uint32_t)Image$$ARM_LIB_STACK$$ZI$$Base - (uint32_t)HEAP_START)) #endif /* @@ -58,10 +54,10 @@ extern uint32_t Image$$RW_IRAM1$$ZI$$Limit[]; */ void __rt_entry(void) { - mbed_stack_isr_start = (unsigned char *)ISR_STACK_START; - mbed_stack_isr_size = (uint32_t)ISR_STACK_SIZE; - mbed_heap_start = (unsigned char *)HEAP_START; - mbed_heap_size = (uint32_t)HEAP_SIZE; + mbed_stack_isr_start = (unsigned char *) Image$$ARM_LIB_STACK$$ZI$$Base; + mbed_stack_isr_size = (uint32_t) Image$$ARM_LIB_STACK$$ZI$$Length; + mbed_heap_start = (unsigned char *) HEAP_START; + mbed_heap_size = (uint32_t) HEAP_SIZE; mbed_init(); diff --git a/rtos/TARGET_CORTEX/mbed_boot.c b/rtos/TARGET_CORTEX/mbed_boot.c index c3f691888b..1f2460ba7e 100644 --- a/rtos/TARGET_CORTEX/mbed_boot.c +++ b/rtos/TARGET_CORTEX/mbed_boot.c @@ -40,34 +40,18 @@ * Memory layout notes: * ==================== * - * IAR Default Memory layout notes: - * -Heap defined by "HEAP" region in .icf file - * -Interrupt stack defined by "CSTACK" region in .icf file - * -Value INITIAL_SP is ignored + * IAR Memory layout : + * - Heap defined by "HEAP" region in .icf file + * - Interrupt stack defined by "CSTACK" region in .icf file + * - Value INITIAL_SP is ignored * - * IAR Custom Memory layout notes: - * -There is no custom layout available for IAR - everything must be defined in - * the .icf file and use the default layout + * GCC Memory layout : + * - Heap explicitly placed in linker script (*.ld file) and heap start (__end___) and heap end (__HeapLimit) should be defined in linker script + * - Interrupt stack placed in linker script **.ld file) and stack start (__StackTop) and stack end (__StackLimit) should be defined in linker script * - * - * GCC Default Memory layout notes: - * -Block of memory from symbol __end__ to define INITIAL_SP used to setup interrupt - * stack and heap in the function set_stack_heap() - * -ISR_STACK_SIZE can be overridden to be larger or smaller - * - * GCC Custom Memory layout notes: - * -Heap can be explicitly placed by defining both HEAP_START and HEAP_SIZE - * -Interrupt stack can be explicitly placed by defining both ISR_STACK_START and ISR_STACK_SIZE - * - * - * ARM Memory layout - * -Block of memory from end of region "RW_IRAM1" to define INITIAL_SP used to setup interrupt - * stack and heap in the function set_stack_heap() - * -ISR_STACK_SIZE can be overridden to be larger or smaller - * - * ARM Custom Memory layout notes: - * -Heap can be explicitly placed by defining both HEAP_START and HEAP_SIZE - * -Interrupt stack can be explicitly placed by defining both ISR_STACK_START and ISR_STACK_SIZE + * ARM Memory layout : + * - Heap can be explicitly placed by adding ARM_LIB_HEAP section in scatter file and defining both HEAP_START and HEAP_SIZE + * - Interrupt stack placed in scatter files (*.sct) by adding ARM_LIB_STACK section * */ diff --git a/targets/TARGET_RENESAS/mbed_rtx.h b/targets/TARGET_RENESAS/mbed_rtx.h index 572173d655..08336e2683 100644 --- a/targets/TARGET_RENESAS/mbed_rtx.h +++ b/targets/TARGET_RENESAS/mbed_rtx.h @@ -24,11 +24,9 @@ extern uint32_t Image$$ARM_LIB_STACK$$Base[]; extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Limit[]; extern uint32_t Image$$ARM_LIB_HEAP$$Base[]; - #define ISR_STACK_START Image$$ARM_LIB_STACK$$Base - #define ISR_STACK_SIZE (uint32_t)((uint32_t)Image$$ARM_LIB_STACK$$ZI$$Limit - (uint32_t)Image$$ARM_LIB_STACK$$Base) #define INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit #define HEAP_START Image$$ARM_LIB_HEAP$$Base - #define HEAP_SIZE (uint32_t)((uint32_t)ISR_STACK_START - (uint32_t)HEAP_START) + #define HEAP_SIZE (uint32_t)((uint32_t) Image$$ARM_LIB_STACK$$Base - (uint32_t) HEAP_START) #elif defined(__GNUC__) #define INITIAL_SP (&__StackTop) #elif defined(__ICCARM__)