SPM: Add runtime SFN backend

A backend for implementing 'SFN'. This runtime backend is selected
if:
- All partitions included in the current build are 'SFN' partitions.
- Isolation level 1.

The configuration is generated by tooling, and output to the
generated file 'config_impl.h'.

Change-Id: I819c78c7a912f86174d102d389a2714ae17e5062
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
Co-authored-by: Mingyang Sun <mingyang.sun@arm.com>
diff --git a/secure_fw/spm/include/current.h b/secure_fw/spm/include/current.h
new file mode 100644
index 0000000..e69473d
--- /dev/null
+++ b/secure_fw/spm/include/current.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+#ifndef __CURRENT_H__
+#define __CURRENT_H__
+
+#include "thread.h"
+#include "spm_ipc.h"
+
+/* Get current component */
+#define GET_CURRENT_COMPONENT()  GET_CTX_OWNER(CURRENT_THREAD->p_context_ctrl)
+/* Set current component */
+#define SET_CURRENT_COMPONENT(p) THRD_UPDATE_CUR_CTXCTRL(&(p)->ctx_ctrl)
+
+#endif /* __CURRENT_H__ */
diff --git a/secure_fw/spm/include/ffm/backend.h b/secure_fw/spm/include/ffm/backend.h
index 7b7ea00..5efeac0 100644
--- a/secure_fw/spm/include/ffm/backend.h
+++ b/secure_fw/spm/include/ffm/backend.h
@@ -37,9 +37,9 @@
 
     /*
      * Runtime model-specific message replying.
-     * Return the acked status.
+     * Return the connection handle or the acked status code.
      */
-    void (*replying)(struct tfm_msg_body_t *p_msg, psa_status_t status);
+    int32_t (*replying)(struct tfm_msg_body_t *p_msg, int32_t status);
 };
 
 /* RUNTIME MODEL BACKENDS DECLARATION */
diff --git a/secure_fw/spm/include/ffm/psa_api.h b/secure_fw/spm/include/ffm/psa_api.h
index 6ea3c46..1c78e46 100644
--- a/secure_fw/spm/include/ffm/psa_api.h
+++ b/secure_fw/spm/include/ffm/psa_api.h
@@ -247,14 +247,16 @@
  * \param[in] status            Message result value to be reported to the
  *                              client.
  *
- * \retval void                 Success.
+ * \retval Positive integer     Success, the connection handle.
+ * \retval PSA_SUCCESS          Success
  * \retval "PROGRAMMER ERROR"   The call is invalid, one or more of the
  *                              following are true:
  * \arg                         msg_handle is invalid.
  * \arg                         An invalid status code is specified for the
  *                              type of message.
  */
-void tfm_spm_partition_psa_reply(psa_handle_t msg_handle, psa_status_t status);
+int32_t tfm_spm_partition_psa_reply(psa_handle_t msg_handle,
+                                    psa_status_t status);
 
 /**
  * \brief Function body of \ref psa_norify.