Core: Add IPC Client and Service Secure Partition

Add Secure Partition for IPC Client and Service. Generate new partition
information by executing tfm_parse_manifest_list.py.

Change-Id: I8a0fe54113f9c5c2a32dd5d651a9722f0057dd2b
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/test/test_services/CMakeLists.inc b/test/test_services/CMakeLists.inc
index 85eda32..5ac6602 100644
--- a/test/test_services/CMakeLists.inc
+++ b/test/test_services/CMakeLists.inc
@@ -65,7 +65,8 @@
 if (NOT DEFINED CORE_TEST_IPC)
 	message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_IPC is undefined. ")
 elseif (CORE_TEST_IPC)
-	list(APPEND ALL_SRC_C_S "${CORE_TEST_DIR}/tfm_ipc_test/ipc_test_service.c"
+	list(APPEND ALL_SRC_C_S "${CORE_TEST_DIR}/tfm_ipc_service/ipc_service_test.c"
+		"${CORE_TEST_DIR}/tfm_ipc_client/ipc_client_test.c"
 		)
 endif()
 
diff --git a/test/test_services/tfm_ipc_client/ipc_client_test.c b/test/test_services/tfm_ipc_client/ipc_client_test.c
new file mode 100644
index 0000000..6c449eb
--- /dev/null
+++ b/test/test_services/tfm_ipc_client/ipc_client_test.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdio.h>
+#include "psa_client.h"
+#include "secure_utilities.h"
+
+/*
+ * FixMe: These SID should come from manifest.
+ * Temporarily adds them here for test.
+ */
+#define IPC_TEST_SERVICE1_SID        (01)
+#define IPC_TEST_SERVICE1_MIN_VER    (0x0001)
+
+int ipc_client_init(void)
+{
+    psa_handle_t handle;
+    psa_status_t status;
+    char str1[] = "123";
+    char str2[] = "456";
+    char str3[64], str4[64];
+    struct psa_invec invecs[2] = {{str1, sizeof(str1)/sizeof(char)},
+                                  {str2, sizeof(str2)/sizeof(char)}};
+    struct psa_outvec outvecs[2] = {{str3, sizeof(str3)/sizeof(char)},
+                                    {str4, sizeof(str4)/sizeof(char)}};
+
+
+    LOG_MSG("hello! this is ipc client test sp!");
+
+    handle = psa_connect(IPC_TEST_SERVICE1_SID, IPC_TEST_SERVICE1_MIN_VER);
+    if (handle > 0) {
+        LOG_MSG("Connect success!");
+    } else {
+        LOG_MSG("The RoT Service has refused the connection!");
+    }
+
+    status = psa_call(handle, invecs, 2, outvecs, 2);
+    if (status >= 0) {
+        LOG_MSG("Call success!");
+    } else {
+        LOG_MSG("Call failed!");
+    }
+
+    psa_close(handle);
+    return 0;
+}
diff --git a/test/test_services/tfm_ipc_client/manifest.yaml b/test/test_services/tfm_ipc_client/manifest.yaml
new file mode 100644
index 0000000..8c8ccdb
--- /dev/null
+++ b/test/test_services/tfm_ipc_client/manifest.yaml
@@ -0,0 +1,26 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+{
+  "name": "IPC_CLIENT",
+  "type": "SECURE",
+  "tfm_partition_name": "TFM_SP_IPC_CLIENT_TEST",
+  "priority": "NORMAL",
+  "id": "0x00000006",
+  "entry_point": "main",
+  "stack_size": "0x1000",
+  "heap_size": "0x0400",
+  "tfm_init_symbol": "ipc_client_init",
+  "source_files": [
+    "ipc_client_test.c",
+  ],
+  "tfm_linker_pattern": {
+    "library_list": [
+      "*ipc_client_test*"
+    ]
+  }
+}
diff --git a/test/test_services/tfm_ipc_test/ipc_test_service.c b/test/test_services/tfm_ipc_service/ipc_service_test.c
similarity index 64%
rename from test/test_services/tfm_ipc_test/ipc_test_service.c
rename to test/test_services/tfm_ipc_service/ipc_service_test.c
index 85ca0fb..279d1b1 100644
--- a/test/test_services/tfm_ipc_test/ipc_test_service.c
+++ b/test/test_services/tfm_ipc_service/ipc_service_test.c
@@ -13,30 +13,11 @@
 #include "secure_fw/core/tfm_secure_api.h"
 #include "tfm_api.h"
 
-#define IPC_SERVICE_BUFFER_LEN 256
-#define PSA_IPC_SIGNAL 1
+#define IPC_SERVICE_BUFFER_LEN 64
+#define IPC_BASIC_SIGNAL 1
 
 static int inuse = 0;
 
-static psa_status_t ipc_service_connect(psa_msg_t *msg)
-{
-    uint32_t minor_version;
-
-    if (msg->in_size[0] == 0) {
-        return PSA_CONNECTION_REFUSED;
-    }
-
-    psa_read(msg->handle, 0, &minor_version, sizeof(minor_version));
-    printf("Requested minor version for service1 connect: %d.\r\n",
-           minor_version);
-
-    /* notify client if accepted or refused */
-    if (minor_version == 0) {
-        return PSA_CONNECTION_REFUSED;
-    }
-    return PSA_SUCCESS;
-}
-
 static psa_status_t ipc_service_call(psa_msg_t *msg)
 {
     int i;
@@ -46,8 +27,6 @@
     for (i = 0; i < PSA_MAX_IOVEC; i++) {
         if (msg->in_size[i] != 0) {
             psa_read(msg->handle, i, rec_buf, IPC_SERVICE_BUFFER_LEN);
-            printf("receive buffer index is %d, data is %s.\r\n", i,
-                                            (char *)rec_buf);
         }
         if (msg->out_size[i] != 0) {
             psa_write(msg->handle, i, send_buf, IPC_SERVICE_BUFFER_LEN);
@@ -57,7 +36,7 @@
 }
 
 /* Test thread */
-void *ipc_test_partition_main(void *param)
+void ipc_service_test_main(void *param)
 {
     uint32_t signals = 0;
     psa_msg_t msg;
@@ -65,18 +44,15 @@
 
     while (1) {
         signals = psa_wait(PSA_WAIT_ANY, PSA_BLOCK);
-
-        printf("ipc get signals 0x%x\r\n", signals);
-
-        if (signals & PSA_IPC_SIGNAL) {
-            psa_get(PSA_IPC_SIGNAL, &msg);
+        if (signals & IPC_BASIC_SIGNAL) {
+            psa_get(IPC_BASIC_SIGNAL, &msg);
             switch (msg.type) {
             case PSA_IPC_CONNECT:
                 if (inuse) {
                     r = PSA_CONNECTION_REFUSED;
                 } else {
                     inuse = 1;
-                    r = ipc_service_connect(&msg);
+                    r = PSA_SUCCESS;
                 }
                 psa_reply(msg.handle, r);
                 break;
@@ -95,5 +71,5 @@
         }
     }
 
-    return NULL;
+    return;
 }
diff --git a/test/test_services/tfm_ipc_service/manifest.yaml b/test/test_services/tfm_ipc_service/manifest.yaml
new file mode 100644
index 0000000..8594f04
--- /dev/null
+++ b/test/test_services/tfm_ipc_service/manifest.yaml
@@ -0,0 +1,36 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+{
+  "name": "IPC_SERVICE_TEST",
+  "tfm_partition_name": "TFM_SP_IPC_SERVICE_TEST",
+  "type": "SECURE", "IPC",
+  "priority": "NORMAL",
+  "id": "0x00000007",
+  "entry_point": "main",
+  "stack_size": "0x1000",
+  "heap_size": "0x0400",
+  "tfm_init_symbol": "ipc_service_test_main",
+  "secure_functions": [
+    {
+      "sfid": "IPC_SERVICE_CALL_SFID",
+      "signal": "IPC_SERVICE_CALL",
+      "tfm_symbol": "ipc_service_call",
+      "non_secure_clients": true,
+      "minor_version": 1,
+      "minor_policy": "strict"
+    }
+  ],
+  "source_files": [
+    "./ipc_service_test.c",
+  ],
+  "tfm_linker_pattern": {
+    "library_list": [
+      "*ipc_service_test*"
+    ]
+  }
+}