SPM: Remove redundant 'tfm_spm_db_init' for IPC model

The job done by 'tfm_spm_db_init' can be covered in 'tfm_spm_init'. Do
not spend extra loop to bind static and memory data with runtime data.

- Remove function 'tfm_spm_db_init'.
- Remove the 'is_inited' member as it is not used under the IPC model.

Change-Id: Ic1b5c6c01ddfa255dfa11440af9882c4c17ce3a8
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
diff --git a/secure_fw/spm/cmsis_psa/main.c b/secure_fw/spm/cmsis_psa/main.c
index 7b8cb0c..e0a4de2 100644
--- a/secure_fw/spm/cmsis_psa/main.c
+++ b/secure_fw/spm/cmsis_psa/main.c
@@ -127,10 +127,6 @@
     /* Print the TF-M version */
     SPMLOG_INFMSG("\033[1;34mBooting TFM v"VERSION_FULLSTR"\033[0m\r\n");
 
-    if (tfm_spm_db_init() != SPM_ERR_OK) {
-        tfm_core_panic();
-    }
-
     /*
      * Prioritise secure exceptions to avoid NS being able to pre-empt
      * secure SVC or SecureFault. Do it before PSA API initialization.
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 177268c..836f838 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -649,11 +649,12 @@
 
     /* Init partition first for it will be used when init service */
     for (i = 0; i < g_spm_partition_db.partition_count; i++) {
+
         partition = &g_spm_partition_db.partitions[i];
 
-        if (!partition || !partition->memory_data || !partition->p_static) {
-            tfm_core_panic();
-        }
+        /* Skip NULL checking on statically reserved arraries. */
+        partition->p_static = &static_data_list[i];
+        partition->memory_data = &memory_data_list[i];
 
         if (!(partition->p_static->flags & SPM_PART_FLAG_IPC)) {
             tfm_core_panic();
@@ -1008,18 +1009,3 @@
         *res_ptr = (uint32_t)TFM_ERROR_INVALID_PARAMETER;
     }
 }
-
-enum spm_err_t tfm_spm_db_init(void)
-{
-    uint32_t i;
-
-    /* This function initialises partition db */
-
-    for (i = 0; i < g_spm_partition_db.partition_count; i++) {
-        g_spm_partition_db.partitions[i].p_static = &static_data_list[i];
-        g_spm_partition_db.partitions[i].memory_data = &memory_data_list[i];
-    }
-    g_spm_partition_db.is_init = 1;
-
-    return SPM_ERR_OK;
-}
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index 8d23c52..a91a492 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -117,7 +117,6 @@
 };
 
 struct spm_partition_db_t {
-    uint32_t is_init;
     uint32_t partition_count;
     struct partition_t *partitions;
 };
@@ -171,13 +170,6 @@
 };
 
 /**
- * \brief Initialize partition database
- *
- * \return Error code \ref spm_err_t
- */
-enum spm_err_t tfm_spm_db_init(void);
-
-/**
  * \brief                   Get the current partition mode.
  *
  * \param[in] partition_flags               Flags of current 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 59c5168..2d8961e 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
@@ -246,7 +246,6 @@
 };
 
 struct spm_partition_db_t g_spm_partition_db = {
-    .is_init = 0,
     .partition_count = sizeof(partition_list) / sizeof(partition_list[0]),
     .partitions = partition_list,
 };