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/interface/include/config_impl.h.template b/interface/include/config_impl.h.template
index 5af682a..7557d57 100644
--- a/interface/include/config_impl.h.template
+++ b/interface/include/config_impl.h.template
@@ -51,9 +51,14 @@
  * CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR for reference, and allow
  * modification of the factor based on application situation. The stack size
  * value is aligned to 8 bytes.
+ * The minimum value is 0x400 to satisfy the SPM functional requirement.
+ * Manifest tool will assure this.
  */
+    {% if total_stk.size|int < 2048 %}
+        {% set total_stk.size = 2048 %}
+    {% endif %}
 #define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR             1
-#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \
+#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}  \
     ((({{"0x%x"|format(total_stk.size)}} >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7))
 
 {% elif sfn_partition_num > 0 and ipc_partition_num > 0 %}
diff --git a/interface/include/psa_interface_redirect.h b/interface/include/psa_interface_redirect.h
index 409f49a..9eca26f 100644
--- a/interface/include/psa_interface_redirect.h
+++ b/interface/include/psa_interface_redirect.h
@@ -62,6 +62,23 @@
 #define psa_unmap_outvec         psa_unmap_outvec_thread
 #endif /* PSA_FRAMEWORK_HAS_MM_IOVEC */
 
+#elif defined(CONFIG_TFM_PSA_API_SFN_CALL)
+
+#define psa_framework_version    psa_framework_version_sfn
+#define psa_version              psa_version_sfn
+#define psa_connect              psa_connect_sfn
+#define tfm_psa_call_pack        psa_call_pack_sfn
+#define psa_close                psa_close_sfn
+#define psa_wait                 psa_wait_sfn
+#define psa_read                 psa_read_sfn
+#define psa_skip                 psa_skip_sfn
+#define psa_write                psa_write_sfn
+#define psa_panic                psa_panic_sfn
+
+#else
+
+#error "NO ABI is chosen, check configurations."
+
 #endif
 
 #endif /* __PSA_INTERFACE_REDIRECT_H__ */