Platform: Clean-up stack and heap allocation
Details:
- ARMCLANG: relocate heap and stack allocation to scatter file
from start-up assembly, to be aligned with GNUARM
- Explicitly distinguish main and process stack
- Reorder the allocation of heap and stack area in
RAM: main stack, process stack, heap
- Introduce shared data area b/w bootloader and runtime to exchange
data
- Main stack and shared area are overlapping sections in memory,
to prepare the recycling the shared area as stack
- Increase bootloader stack size to avoid overflow
- Remove unnecessary .heap(COPY) section from GCC linker script
Change-Id: Id8702fd9262764814250356868fb8de630b4a1af
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
diff --git a/secure_fw/spm/spm_api.c b/secure_fw/spm/spm_api.c
index 83d4414..b17ee99 100644
--- a/secure_fw/spm/spm_api.c
+++ b/secure_fw/spm/spm_api.c
@@ -83,8 +83,10 @@
/* For the non secure Execution environment */
#if TFM_LVL != 1
- extern uint32_t Stack_Mem[];
- extern uint32_t Stack_top[];
+ extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[];
+ extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Limit[];
+ uint32_t psp_stack_bottom = (uint32_t)Image$$ARM_LIB_STACK$$ZI$$Base;
+ uint32_t psp_stack_top = (uint32_t)Image$$ARM_LIB_STACK$$ZI$$Limit;
#endif
if (g_spm_partition_db.partition_count >= SPM_MAX_PARTITIONS) {
return SPM_ERR_INVALID_CONFIG;
@@ -95,12 +97,12 @@
part_ptr->static_data.partition_flags = 0;
#if TFM_LVL != 1
- part_ptr->memory_data.stack_bottom = (uint32_t)Stack_Mem;
- part_ptr->memory_data.stack_top = (uint32_t)Stack_top;
+ part_ptr->memory_data.stack_bottom = psp_stack_bottom;
+ part_ptr->memory_data.stack_top = psp_stack_top;
/* Since RW, ZI and stack are configured as one MPU region, configure
- * RW start address to Stack_Mem to get RW access to stack
+ * RW start address to psp_stack_bottom to get RW access to stack
*/
- part_ptr->memory_data.rw_start = (uint32_t)Stack_Mem;
+ part_ptr->memory_data.rw_start = psp_stack_bottom;
#endif
part_ptr->runtime_data.partition_state = SPM_PARTITION_STATE_UNINIT;