SPM: Use signals to drive FFM API procedures

TFM_IPC_REPLY_SIGNAL was created to replace wait_obj to unify the
replied status and signals. After the waiting logic is converted
into signal-oriented, the existing synchronous API calling mechanism
such as setting thread status and injecting return values can be
updated. The synchronous mechanism concludes functions and data to
be called into one context, big critical sections need to be
available when calling to ensure there is no data inconsistency.
Using signals to communicate between FF-M API layer and thread
management can separate the contexts so big critical sections
can be avoided.

The new APIs in FFM API layer, backend_assert_signal() and
backend_wait_signals() which replace backend_wake_up() and
backend_wait() just set the signals in partition and do not change
the status of the thread now. Scheduler now manages threads by
querying the signal state in the partition with an assigned
callback. The scheduler runs in an individual context provided by
PendSV mode.

The partition behaviours when scheduler queries the state are:

 - If any waiting signal is asserted, the thread is required to
   return the context and run.
 - If NONE of waiting signals is asserted, it means the thread is
   requested to block.

The context return process is in thrd_next() according to the
THRD_STATE_RET_VAL_AVAIL to avoid the data operation in FFM.

Signed-off-by: Jianliang Shen <jianliang.shen@arm.com>
Change-Id: Id9444eb3f26ecce674b6409047cb29237a80b6e8
diff --git a/secure_fw/spm/ffm/psa_api.c b/secure_fw/spm/ffm/psa_api.c
index f72609b..adb8d70 100644
--- a/secure_fw/spm/ffm/psa_api.c
+++ b/secure_fw/spm/ffm/psa_api.c
@@ -136,17 +136,14 @@
     }
 
     /*
-     * backend_wake_up() blocks the caller thread if no signals are
-     * available. In this case, the return value of this function is temporary
-     * set into runtime context. After new signal(s) are available, the return
-     * value is updated with the available signal(s) and blocked thread gets
-     * to run.
+     * After new signal(s) are available, the return value will be updated in
+     * PendSV and blocked thread gets to run.
      */
     if (timeout == PSA_BLOCK) {
-        return backend_wait(partition, signal_mask);
+        return backend_wait_signals(partition, signal_mask);
+    } else {
+        return partition->signals_asserted & signal_mask;
     }
-
-    return partition->signals_asserted & signal_mask;
 }
 #endif
 
@@ -537,7 +534,7 @@
 {
     struct partition_t *p_pt = tfm_spm_get_partition_by_id(partition_id);
 
-    spm_assert_signal(p_pt, PSA_DOORBELL);
+    backend_assert_signal(p_pt, PSA_DOORBELL);
 }
 
 void tfm_spm_partition_psa_clear(void)