Core: add PSA client API functions

NS client infrastructure for PSA API created in
conformance with v8M secure gateway call restrictions
and TF-M rules.

Note:
- S SVC handlers TBD
- Buffer read/write funtions TBD
- Sanity checks in S SVC handlers TBD

Change-Id: Ia2947c28247af699d337754db2f22e2e25235c41
Signed-off-by: Miklos Balint <miklos.balint@arm.com>
diff --git a/interface/src/tfm_psa_ns_api.c b/interface/src/tfm_psa_ns_api.c
new file mode 100644
index 0000000..80c3af8
--- /dev/null
+++ b/interface/src/tfm_psa_ns_api.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "interface/include/psa_client.h"
+#include "tfm_ns_lock.h"
+#include "tfm_api.h"
+
+/**** API functions ****/
+
+uint32_t psa_version(uint32_t sid)
+{
+    return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_version_veneer,
+                                sid,
+                                0,
+                                0,
+                                0);
+}
+
+psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version)
+{
+    return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_connect_veneer,
+                                sid,
+                                minor_version,
+                                0,
+                                0);
+}
+
+psa_error_t psa_call(psa_handle_t handle,
+                     const psa_invec *in_vec,
+                     size_t in_len,
+                     const psa_outvec *out_vec,
+                     size_t out_len)
+{
+    /* Due to v8M restrictions, TF-M NS API needs to add another layer of
+     * serialization in order for NS to pass arguments to S
+     */
+    psa_invec in_vecs, out_vecs;
+    in_vecs.base = in_vec;
+    in_vecs.len = in_len;
+    out_vecs.base = out_vec;
+    out_vecs.len = out_len;
+    return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_call_veneer,
+                                (uint32_t)handle,
+                                (uint32_t)&in_vecs,
+                                (uint32_t)&out_vecs,
+                                0);
+}
+
+void psa_close(psa_handle_t handle)
+{
+    tfm_ns_lock_dispatch((veneer_fn)tfm_psa_close_veneer,
+                         (uint32_t)handle,
+                         0,
+                         0,
+                         0);
+}
+