SPM: Redirect PSA API runtimely instead of statically

The previous PSA API redirecting is statically performed in header
files, based on C preprocessors exported by the configuration system.
The C preprocessors make the configuration maintenance harder, and
users could not find the exact PSA API name in debug symbols, which
is confusing.

Now the redirecting turns into a runtime behavior. SPRTL calls
corresponded ABI for PSA API. The ABI is set in the Secure Partition
local storage by SPM when booting, based on Secure Partition types.
Check 'prv_process_metadata' and 'psa_api_ipc.c' for details.

Co-authored-by: Ken Liu <ken.liu@arm.com>
Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: Ifc974941ddb6653389d9deca9f18f754b8f25b27
diff --git a/secure_fw/spm/ffm/backend_ipc.c b/secure_fw/spm/ffm/backend_ipc.c
index 07b01f5..8950e54 100644
--- a/secure_fw/spm/ffm/backend_ipc.c
+++ b/secure_fw/spm/ffm/backend_ipc.c
@@ -102,6 +102,9 @@
     return state;
 }
 
+extern struct psa_api_tbl_t psa_api_cross;
+extern struct psa_api_tbl_t psa_api_svc;
+
 static void prv_process_metadata(struct partition_t *p_pt)
 {
     const struct partition_load_info_t *p_pt_ldi;
@@ -128,6 +131,12 @@
                                     ARCH_CTXCTRL_ALLOCATED_PTR(ctx_ctrl);
 
     p_rt_meta->entry = p_pt_ldi->entry;
+#if TFM_LVL == 1
+    p_rt_meta->psa_fns = &psa_api_cross;
+#else
+    /* TODO: ABI for PRoT partitions needs to be updated based on implementations. */
+    p_rt_meta->psa_fns = &psa_api_svc;
+#endif
     p_rt_meta->n_sfn = 0;
     p_sfn_table = p_rt_meta->sfn_table;