Core: Use the stack region in the linker file

Using array to store stack will consume lots of memory. To let all
platforms have enough RAM space, change to use every partition's own
stack from linker script.
 - Use tfm_spm_partition_memory_data_t to store memory information
   instead of unified stack size in level 1.
 - Initialize partition thread stack range with its own size.
 - Remove the unified stack size member from the spm_partition_desc_t
   structure for level 1.
 - Make tfm_spm_partition_get_stack_bottom() and
   tfm_spm_partition_get_stack_top() functions available for all levels.
 - Remove tfm_spm_partition_get_stack_base_ext() and
   tfm_spm_partition_get_stack_limit_ext() functions.

Change-Id: I2025a49957d60df47e693049fc04146a7ed97b62
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/secure_fw/spm/spm_api.c b/secure_fw/spm/spm_api.c
index 05d6c8d..5f10465 100644
--- a/secure_fw/spm/spm_api.c
+++ b/secure_fw/spm/spm_api.c
@@ -98,12 +98,10 @@
      */
 
     /* For the non secure Execution environment */
-#if TFM_LVL != 1
     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;
     }
@@ -119,14 +117,12 @@
     part_ptr->static_data.partition_flags = 0;
 #endif
 
-#if TFM_LVL != 1
     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 psp_stack_bottom to get RW access to stack
      */
     part_ptr->memory_data.rw_start     = psp_stack_bottom;
-#endif
 
     part_ptr->runtime_data.partition_state = SPM_PARTITION_STATE_UNINIT;
     tfm_nspm_configure_clients();
@@ -202,6 +198,17 @@
     }
 }
 
+uint32_t tfm_spm_partition_get_stack_bottom(uint32_t partition_idx)
+{
+    return g_spm_partition_db.partitions[partition_idx].
+            memory_data.stack_bottom;
+}
+
+uint32_t tfm_spm_partition_get_stack_top(uint32_t partition_idx)
+{
+    return g_spm_partition_db.partitions[partition_idx].memory_data.stack_top;
+}
+
 #if TFM_LVL != 1
 enum spm_err_t tfm_spm_partition_sandbox_config(uint32_t partition_idx)
 {
@@ -231,17 +238,6 @@
                                                   part->platform_data);
 }
 
-uint32_t tfm_spm_partition_get_stack_bottom(uint32_t partition_idx)
-{
-    return g_spm_partition_db.partitions[partition_idx].
-            memory_data.stack_bottom;
-}
-
-uint32_t tfm_spm_partition_get_stack_top(uint32_t partition_idx)
-{
-    return g_spm_partition_db.partitions[partition_idx].memory_data.stack_top;
-}
-
 uint32_t tfm_spm_partition_get_zi_start(uint32_t partition_idx)
 {
     return g_spm_partition_db.partitions[partition_idx].