SPM: Change partition structure member and name

As one part of SPM folder restructure, this patch does:

- Add some partition data member to partition structure for
  future use.
- Change partition structure name to 'partition_t' to make
  it clearer and more simple.

Change-Id: I8b37730ac5f9cdc9956b8d42da933b5b1f524906
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
diff --git a/secure_fw/spm/cmsis_psa/include/spm_ipc.h b/secure_fw/spm/cmsis_psa/include/spm_ipc.h
index d11aab5..c283560 100644
--- a/secure_fw/spm/cmsis_psa/include/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/include/spm_ipc.h
@@ -74,23 +74,30 @@
  * these fields are calculated at compile time, and set during initialisation
  * phase.
  */
-struct spm_partition_static_data_t {
+struct partition_static_t {
     uint32_t psa_framework_version;
     uint32_t partition_id;
     uint32_t partition_flags;
     uint32_t partition_priority;
     sp_entry_point partition_init;
+    uintptr_t stack_base;
+    size_t stack_size;
+    uintptr_t heap_base;
+    size_t heap_size;
     uint32_t dependencies_num;
-    int32_t *p_dependencies;
+    uint32_t *p_dependencies;
 };
 
 /**
  * Holds the fields that define a partition for SPM. The fields are further
  * divided to structures, to keep the related fields close to each other.
  */
-struct spm_partition_desc_t {
+struct partition_t {
     struct spm_partition_runtime_data_t runtime_data;
-    const struct spm_partition_static_data_t *static_data;
+    const struct partition_static_t *static_data;
+    void *p_platform;
+    void *p_interrupts;
+    void *p_metadata;
     /** A list of platform_data pointers */
     const struct tfm_spm_partition_platform_data_t **platform_data_list;
     const struct tfm_spm_partition_memory_data_t *memory_data;
@@ -99,7 +106,7 @@
 struct spm_partition_db_t {
     uint32_t is_init;
     uint32_t partition_count;
-    struct spm_partition_desc_t *partitions;
+    struct partition_t *partitions;
 };
 
 /* Service database defined by manifest */
@@ -116,7 +123,7 @@
 /* RoT Service data */
 struct tfm_spm_service_t {
     const struct tfm_spm_service_db_t *service_db;/* Service database pointer */
-    struct spm_partition_desc_t *partition;  /*
+    struct partition_t *partition;           /*
                                               * Point to secure partition
                                               * data
                                               */
@@ -142,8 +149,8 @@
                                          *  - non secure client endpoint id.
                                          */
     struct tfm_msg_body_t internal_msg; /* Internal message for message queue */
-    struct tfm_spm_service_t *service;  /* RoT service pointer               */
-    struct tfm_list_node_t list;        /* list node                         */
+    struct tfm_spm_service_t *service;  /* RoT service pointer                */
+    struct tfm_list_node_t list;        /* list node                          */
 };
 
 enum tfm_memory_access_e {
@@ -216,9 +223,9 @@
  *
  * \retval NULL             Failed
  * \retval "Not NULL"       Return the parttion context pointer
- *                          \ref spm_partition_desc_t structures
+ *                          \ref partition_t structures
  */
-struct spm_partition_desc_t *tfm_spm_get_running_partition(void);
+struct partition_t *tfm_spm_get_running_partition(void);
 
 /**
  * \brief                   Get the service context by service ID.
@@ -643,9 +650,8 @@
  *
  * \retval void                 Success.
  */
-void tfm_spm_validate_caller(struct spm_partition_desc_t *p_cur_sp,
-                             uint32_t *p_ctx, uint32_t exc_return,
-                             bool ns_caller);
+void tfm_spm_validate_caller(struct partition_t *p_cur_sp, uint32_t *p_ctx,
+                             uint32_t exc_return, bool ns_caller);
 
 /**
  * \brief Terminate execution within the calling Secure Partition and will not
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index cf5ca72..dcb2980 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -260,7 +260,7 @@
  * \brief                   Get the service context by signal.
  *
  * \param[in] partition     Partition context pointer
- *                          \ref spm_partition_desc_t structures
+ *                          \ref partition_t structures
  * \param[in] signal        Signal associated with inputs to the Secure
  *                          Partition, \ref psa_signal_t
  *
@@ -269,7 +269,7 @@
  *                          \ref tfm_spm_service_t structures
  */
 static struct tfm_spm_service_t *
-    tfm_spm_get_service_by_signal(struct spm_partition_desc_t *partition,
+    tfm_spm_get_service_by_signal(struct partition_t *partition,
                                   psa_signal_t signal)
 {
     struct tfm_list_node_t *node, *head;
@@ -403,10 +403,9 @@
  *
  * \retval NULL             Failed
  * \retval "Not NULL"       Target partition context pointer,
- *                          \ref spm_partition_desc_t structures
+ *                          \ref partition_t structures
  */
-static struct spm_partition_desc_t *
-    tfm_spm_get_partition_by_id(int32_t partition_id)
+static struct partition_t *tfm_spm_get_partition_by_id(int32_t partition_id)
 {
     uint32_t idx = get_partition_idx(partition_id);
 
@@ -416,15 +415,15 @@
     return NULL;
 }
 
-struct spm_partition_desc_t *tfm_spm_get_running_partition(void)
+struct partition_t *tfm_spm_get_running_partition(void)
 {
     struct tfm_core_thread_t *pth = tfm_core_thrd_get_curr_thread();
-    struct spm_partition_desc_t *partition;
+    struct partition_t *partition;
     struct spm_partition_runtime_data_t *rt_data;
 
     rt_data = TFM_GET_CONTAINER_PTR(pth, struct spm_partition_runtime_data_t,
                                     sp_thrd);
-    partition = TFM_GET_CONTAINER_PTR(rt_data, struct spm_partition_desc_t,
+    partition = TFM_GET_CONTAINER_PTR(rt_data, struct partition_t,
                                       runtime_data);
     return partition;
 }
@@ -455,7 +454,7 @@
                                     struct tfm_spm_service_t *service,
                                     bool ns_caller)
 {
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
     int32_t i;
 
     TFM_CORE_ASSERT(service);
@@ -634,7 +633,7 @@
 
 uint32_t tfm_spm_partition_get_running_partition_id(void)
 {
-    struct spm_partition_desc_t *partition;
+    struct partition_t *partition;
 
     partition = tfm_spm_get_running_partition();
     if (partition && partition->static_data) {
@@ -680,7 +679,7 @@
 uint32_t tfm_spm_init(void)
 {
     uint32_t i, j, num;
-    struct spm_partition_desc_t *partition;
+    struct partition_t *partition;
     struct tfm_core_thread_t *pth, *p_ns_entry_thread = NULL;
     const struct tfm_spm_partition_platform_data_t **platform_data_p;
 
@@ -797,7 +796,7 @@
 void tfm_pendsv_do_schedule(struct tfm_arch_ctx_t *p_actx)
 {
 #if TFM_LVL == 2
-    struct spm_partition_desc_t *p_next_partition;
+    struct partition_t *p_next_partition;
     struct spm_partition_runtime_data_t *r_data;
     uint32_t is_privileged;
 #endif
@@ -810,7 +809,7 @@
                                        struct spm_partition_runtime_data_t,
                                        sp_thrd);
         p_next_partition = TFM_GET_CONTAINER_PTR(r_data,
-                                                 struct spm_partition_desc_t,
+                                                 struct partition_t,
                                                  runtime_data);
 
         if (p_next_partition->static_data->partition_flags &
@@ -868,7 +867,7 @@
     psa_invec *inptr;
     psa_outvec *outptr;
     size_t in_num, out_num;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
     uint32_t privileged;
     int32_t type;
     struct tfm_control_parameter_t ctrl_param;
@@ -937,7 +936,7 @@
 {
     psa_signal_t signal_mask;
     uint32_t timeout;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     TFM_CORE_ASSERT(args != NULL);
     signal_mask = (psa_signal_t)args[0];
@@ -989,7 +988,7 @@
     psa_msg_t *msg = NULL;
     struct tfm_spm_service_t *service = NULL;
     struct tfm_msg_body_t *tmp_msg = NULL;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
     uint32_t privileged;
 
     TFM_CORE_ASSERT(args != NULL);
@@ -1100,7 +1099,7 @@
     size_t bytes;
     struct tfm_msg_body_t *msg = NULL;
     uint32_t privileged;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     TFM_CORE_ASSERT(args != NULL);
     msg_handle = (psa_handle_t)args[0];
@@ -1223,7 +1222,7 @@
     size_t num_bytes;
     struct tfm_msg_body_t *msg = NULL;
     uint32_t privileged;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     TFM_CORE_ASSERT(args != NULL);
     msg_handle = (psa_handle_t)args[0];
@@ -1418,7 +1417,7 @@
  */
 static void notify_with_signal(int32_t partition_id, psa_signal_t signal)
 {
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     /*
      * The value of partition_id must be greater than zero as the target of
@@ -1479,7 +1478,7 @@
 
 void tfm_spm_psa_clear(void)
 {
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     partition = tfm_spm_get_running_partition();
     if (!partition) {
@@ -1539,7 +1538,7 @@
     psa_signal_t irq_signal;
     IRQn_Type irq_line = (IRQn_Type) 0;
     int32_t ret;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     TFM_CORE_ASSERT(args != NULL);
     irq_signal = (psa_signal_t)args[0];
@@ -1578,7 +1577,7 @@
     psa_signal_t irq_signal = svc_ctx->r0;
     IRQn_Type irq_line = (IRQn_Type) 0;
     int32_t ret;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     /* It is a fatal error if passed signal indicates more than one signals. */
     if (!tfm_is_one_bit_set(irq_signal)) {
@@ -1606,7 +1605,7 @@
     psa_signal_t irq_signal = svc_ctx->r0;
     IRQn_Type irq_line = (IRQn_Type) 0;
     int32_t ret;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
 
     /* It is a fatal error if passed signal indicates more than one signals. */
     if (!tfm_is_one_bit_set(irq_signal)) {
@@ -1628,9 +1627,8 @@
     tfm_spm_hal_disable_irq(irq_line);
 }
 
-void tfm_spm_validate_caller(struct spm_partition_desc_t *p_cur_sp,
-                             uint32_t *p_ctx, uint32_t exc_return,
-                             bool ns_caller)
+void tfm_spm_validate_caller(struct partition_t *p_cur_sp, uint32_t *p_ctx,
+                             uint32_t exc_return, bool ns_caller)
 {
     uintptr_t stacked_ctx_pos;
 
@@ -1674,7 +1672,7 @@
 {
     uint32_t *res_ptr = (uint32_t *)&svc_ctx->r0;
     uint32_t running_partition_flags = 0;
-    const struct spm_partition_desc_t *partition = NULL;
+    const struct partition_t *partition = NULL;
 
     /* Check permissions on request type basis */
 
diff --git a/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c b/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
index 9cd9a24..8583daf 100644
--- a/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
+++ b/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
@@ -29,7 +29,7 @@
                                uint32_t lr)
 {
     bool ns_caller = false;
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
     uint32_t veneer_base =
         (uint32_t)&REGION_NAME(Image$$, TFM_UNPRIV_CODE, $$RO$$Base);
     uint32_t veneer_limit =
diff --git a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc
index 1ddaf75..c261578 100644
--- a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc
+++ b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc
@@ -345,7 +345,7 @@
 /** Dependencies array for Secure Partition */
 /**************************************************************************/
 #ifdef TFM_PARTITION_PROTECTED_STORAGE
-static int32_t dependencies_TFM_SP_PS[] =
+static uint32_t dependencies_TFM_SP_PS[] =
 {
     TFM_CRYPTO_SID,
     TFM_ITS_SET_SID,
@@ -357,7 +357,7 @@
 #endif /* TFM_PARTITION_PROTECTED_STORAGE */
 
 #ifdef TFM_PARTITION_CRYPTO
-static int32_t dependencies_TFM_SP_CRYPTO[] =
+static uint32_t dependencies_TFM_SP_CRYPTO[] =
 {
     TFM_ITS_SET_SID,
     TFM_ITS_GET_SID,
@@ -367,14 +367,14 @@
 #endif /* TFM_PARTITION_CRYPTO */
 
 #ifdef TFM_PARTITION_INITIAL_ATTESTATION
-static int32_t dependencies_TFM_SP_INITIAL_ATTESTATION[] =
+static uint32_t dependencies_TFM_SP_INITIAL_ATTESTATION[] =
 {
     TFM_CRYPTO_SID,
 };
 #endif /* TFM_PARTITION_INITIAL_ATTESTATION */
 
 #ifdef TFM_PARTITION_TEST_CORE
-static int32_t dependencies_TFM_SP_CORE_TEST[] =
+static uint32_t dependencies_TFM_SP_CORE_TEST[] =
 {
     SPM_CORE_TEST_2_INVERT_SID,
     SPM_CORE_TEST_2_GET_EVERY_SECOND_BYTE_SID,
@@ -383,7 +383,7 @@
 #endif /* TFM_PARTITION_TEST_CORE */
 
 #ifdef TFM_PARTITION_TEST_SECURE_SERVICES
-static int32_t dependencies_TFM_SP_SECURE_TEST_PARTITION[] =
+static uint32_t dependencies_TFM_SP_SECURE_TEST_PARTITION[] =
 {
     TFM_SECURE_CLIENT_2_SID,
     TFM_CRYPTO_SID,
@@ -406,7 +406,7 @@
 #endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
 
 #ifdef TFM_PARTITION_TEST_CORE_IPC
-static int32_t dependencies_TFM_SP_IPC_CLIENT_TEST[] =
+static uint32_t dependencies_TFM_SP_IPC_CLIENT_TEST[] =
 {
     IPC_SERVICE_TEST_PSA_ACCESS_APP_READ_ONLY_MEM_SID,
     IPC_SERVICE_TEST_PSA_ACCESS_APP_MEM_SID,
@@ -416,7 +416,7 @@
 #endif /* TFM_PARTITION_TEST_CORE_IPC */
 
 #ifdef TFM_PARTITION_TEST_PS
-static int32_t dependencies_TFM_SP_PS_TEST[] =
+static uint32_t dependencies_TFM_SP_PS_TEST[] =
 {
     TFM_CRYPTO_SID,
     TFM_ITS_GET_SID,
@@ -425,7 +425,7 @@
 #endif /* TFM_PARTITION_TEST_PS */
 
 #ifdef TFM_PARTITION_TEST_SECURE_SERVICES
-static int32_t dependencies_TFM_SP_SECURE_CLIENT_2[] =
+static uint32_t dependencies_TFM_SP_SECURE_CLIENT_2[] =
 {
     TFM_ITS_GET_SID,
     TFM_CRYPTO_SID,
@@ -435,7 +435,7 @@
 /**************************************************************************/
 /** The static data of the partition list */
 /**************************************************************************/
-const struct spm_partition_static_data_t static_data_list[] =
+const struct partition_static_t static_data_list[] =
 {
     {
         .psa_framework_version = 0x0100,
@@ -1008,7 +1008,7 @@
 /**************************************************************************/
 /** The partition list for the DB */
 /**************************************************************************/
-static struct spm_partition_desc_t partition_list [] =
+static struct partition_t partition_list [] =
 {
     {{0}}, /* placeholder for Non-secure internal partition */
 
diff --git a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template
index 33549e3..2439f03 100644
--- a/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template
+++ b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template
@@ -83,7 +83,7 @@
         {% if manifest.attr.conditional %}
 #ifdef {{manifest.attr.conditional}}
         {% endif %}
-static int32_t dependencies_{{manifest.manifest.name}}[] =
+static uint32_t dependencies_{{manifest.manifest.name}}[] =
 {
         {% for dependence in manifest.manifest.dependencies %}
             {% for service in manifest.manifest.services %}
@@ -103,7 +103,7 @@
 /**************************************************************************/
 /** The static data of the partition list */
 /**************************************************************************/
-const struct spm_partition_static_data_t static_data_list[] =
+const struct partition_static_t static_data_list[] =
 {
     {
         .psa_framework_version = 0x0100,
@@ -241,7 +241,7 @@
 /**************************************************************************/
 /** The partition list for the DB */
 /**************************************************************************/
-static struct spm_partition_desc_t partition_list [] =
+static struct partition_t partition_list [] =
 {
     {{'{{0}}'}}, /* placeholder for Non-secure internal partition */
 
diff --git a/secure_fw/spm/common/init/tfm_boot_data.c b/secure_fw/spm/common/init/tfm_boot_data.c
index 8057318..af52db3 100644
--- a/secure_fw/spm/common/init/tfm_boot_data.c
+++ b/secure_fw/spm/common/init/tfm_boot_data.c
@@ -150,7 +150,7 @@
                 tfm_spm_partition_get_running_partition_idx();
     uint32_t res;
 #else
-    struct spm_partition_desc_t *partition = NULL;
+    struct partition_t *partition = NULL;
     uint32_t privileged;
 #endif