Twincpu: Add RPC into TF-M PSA client call handling and reply routines

Add TF-M Remote Procedure Call (RPC) to deal with PSA client call
from NSPE in multi-core topology, in TF-M PSA client call handling
and reply routines.
- Insert tfm_rpc_client_call_handler() into PendSV handler to
  process PSA client call request from non-secure core.
- Add tfm_rpc_client_call_reply() into tfm_svcall_psa_reply() to
  return PSA client call return result to non-secure core.

Change-Id: I8ece001b5ac241f05236c02d93f42b7eca14688b
Signed-off-by: David Hu <david.hu@arm.com>
diff --git a/secure_fw/spm/spm_api_ipc.c b/secure_fw/spm/spm_api_ipc.c
index 98f7a0e..4677421 100644
--- a/secure_fw/spm/spm_api_ipc.c
+++ b/secure_fw/spm/spm_api_ipc.c
@@ -28,6 +28,7 @@
 #include "tfm_nspm.h"
 #include "tfm_memory_utils.h"
 #include "tfm_core_utils.h"
+#include "tfm_rpc.h"
 
 #include "secure_fw/services/tfm_service_list.inc"
 
@@ -375,7 +376,13 @@
     tfm_event_wake(&p_runtime_data->signal_evnt, (p_runtime_data->signals &
                                                   p_runtime_data->signal_mask));
 
-    tfm_event_wait(&msg->ack_evnt);
+    /*
+     * If it is a NS request via RPC, it is unnecessary to block current
+     * thread.
+     */
+    if (!is_tfm_rpc_msg(msg)) {
+        tfm_event_wait(&msg->ack_evnt);
+    }
 
     return IPC_SUCCESS;
 }
@@ -581,4 +588,10 @@
 
         tfm_thrd_context_switch(ctxb, pth_curr, pth_next);
     }
+
+    /*
+     * Handle pending mailbox message from NS in multi-core topology.
+     * Empty operation on single Armv8-M platform.
+     */
+    tfm_rpc_client_call_handler();
 }