Core: Remove the index member in runtime data structure

Remove the index member in runtime data structure to minimize
the memory usage. Refine the implementation of
tfm_spm_partition_get_privileged_mode by passing partition
flags instead of partition index.

Change-Id: I6d2bc92dccfb8fe79ca282e5648625ff6c780ef2
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index aebcc5a..b9b344a 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -108,7 +108,6 @@
                                          * Service signal mask passed by
                                          * psa_wait()
                                          */
-    uint32_t index;                     /* Partition index */
 };
 
 #ifdef TFM_PSA_API
@@ -415,12 +414,12 @@
 /**
  * \brief                   Get the current partition mode.
  *
- * \param[in] partition_idx                 Index of current partition
+ * \param[in] partition_flags               Flags of current partition
  *
  * \retval TFM_PARTITION_PRIVILEGED_MODE    Privileged mode
  * \retval TFM_PARTITION_UNPRIVILEGED_MODE  Unprivileged mode
  */
-uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_idx);
+uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags);
 
 /******************** Service handle management functions ********************/
 
diff --git a/secure_fw/spm/spm_api_ipc.c b/secure_fw/spm/spm_api_ipc.c
index 6a7231f..2b701ed 100644
--- a/secure_fw/spm/spm_api_ipc.c
+++ b/secure_fw/spm/spm_api_ipc.c
@@ -437,9 +437,9 @@
     return IPC_ERROR_MEMORY_CHECK;
 }
 
-uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_idx)
+uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
 {
-    if (tfm_spm_partition_get_flags(partition_idx) & SPM_PART_FLAG_PSA_ROT) {
+    if (partition_flags & SPM_PART_FLAG_PSA_ROT) {
         return TFM_PARTITION_PRIVILEGED_MODE;
     } else {
         return TFM_PARTITION_UNPRIVILEGED_MODE;
@@ -463,7 +463,6 @@
     for (i = 0; i < g_spm_partition_db.partition_count; i++) {
         partition = &g_spm_partition_db.partitions[i];
         tfm_spm_hal_configure_default_isolation(partition->platform_data);
-        partition->runtime_data.index = i;
         if ((tfm_spm_partition_get_flags(i) & SPM_PART_FLAG_IPC) == 0) {
             continue;
         }