Two test SFN partitions for test purpose

As the SFN and IPC mixed model is not supported, all other IPC
partitions need to be shut down - Customized components such as
NS Agent and IDLE process are not generic partitions hence they
are allowed to exist in the system.

A standalone folder and manifest list are created for these two
partitions, to make them being included easily by specifying
'TFM_EXTRA_PARTITION_PATHS' and 'TFM_EXTRA_MANIFEST_LIST_FILES'.

Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
Change-Id: Id4ff8b18afc1d4b33ecff6fb114b8f0e3261b530
diff --git a/test/test_services/tfm_test_sfn_manifest_list.yaml b/test/test_services/tfm_test_sfn_manifest_list.yaml
new file mode 100644
index 0000000..b0aebd8
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_manifest_list.yaml
@@ -0,0 +1,43 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+{
+  "name": "TF-M secure partition manifests",
+  "type": "manifest_list",
+  "version_major": 0,
+  "version_minor": 1,
+  "manifest_list": [
+    {
+      "name": "TFM SFN Partition1 Service",
+      "short_name": "TFM_SFN_SP1",
+      "manifest": "tfm_test_sfn_partitions/sfn_partition1/sfn_partition1.yaml",
+      "output_path": "test_services/sfn_partition1",
+      "conditional": "TFM_PARTITION_SFN1",
+      "version_major": 0,
+      "version_minor": 1,
+      "linker_pattern": {
+        "library_list": [
+          "*tfm_*partition_sfn1.*"
+        ]
+      }
+    },
+    {
+      "name": "TFM SFN Partition2 Service",
+      "short_name": "TFM_SFN_SP2",
+      "manifest": "tfm_test_sfn_partitions/sfn_partition2/sfn_partition2.yaml",
+      "output_path": "test_services/sfn_partition2",
+      "conditional": "TFM_PARTITION_SFN2",
+      "version_major": 0,
+      "version_minor": 1,
+      "linker_pattern": {
+        "library_list": [
+          "*tfm_*partition_sfn2.*"
+        ]
+      }
+    },
+  ]
+}
diff --git a/test/test_services/tfm_test_sfn_partitions/CMakeLists.txt b/test/test_services/tfm_test_sfn_partitions/CMakeLists.txt
new file mode 100644
index 0000000..5d5618f
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_partitions/CMakeLists.txt
@@ -0,0 +1,14 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+if (TFM_PARTITION_SFN1)
+    add_subdirectory(sfn_partition1)
+endif()
+
+if (TFM_PARTITION_SFN2)
+    add_subdirectory(sfn_partition2)
+endif()
diff --git a/test/test_services/tfm_test_sfn_partitions/sfn_partition1/CMakeLists.txt b/test/test_services/tfm_test_sfn_partitions/sfn_partition1/CMakeLists.txt
new file mode 100644
index 0000000..31e68b0
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_partitions/sfn_partition1/CMakeLists.txt
@@ -0,0 +1,59 @@
+
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+if (NOT TFM_PARTITION_SFN1)
+    return()
+endif()
+
+cmake_minimum_required(VERSION 3.15)
+cmake_policy(SET CMP0079 NEW)
+
+add_library(tfm_app_rot_partition_sfn1 STATIC)
+
+target_sources(tfm_app_rot_partition_sfn1
+    PRIVATE
+        sfn_partition1.c
+)
+
+target_include_directories(tfm_partitions
+    INTERFACE
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition1
+)
+
+# The generated sources
+target_sources(tfm_app_rot_partition_sfn1
+    PRIVATE
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition1/auto_generated/intermedia_sfn_partition1.c
+)
+target_sources(tfm_partitions
+    INTERFACE
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition1/auto_generated/load_info_sfn_partition1.c
+)
+
+target_include_directories(tfm_app_rot_partition_sfn1
+    PRIVATE
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition1
+)
+
+target_link_libraries(tfm_app_rot_partition_sfn1
+    PRIVATE
+        tfm_secure_api
+        psa_interface
+        platform_s
+        tfm_sprt
+)
+
+############################ Partition Defs ####################################
+target_link_libraries(tfm_partitions
+    INTERFACE
+        tfm_app_rot_partition_sfn1
+)
+target_compile_definitions(tfm_partition_defs
+    INTERFACE
+        TFM_PARTITION_SFN1
+)
diff --git a/test/test_services/tfm_test_sfn_partitions/sfn_partition1/sfn_partition1.c b/test/test_services/tfm_test_sfn_partitions/sfn_partition1/sfn_partition1.c
new file mode 100644
index 0000000..3118b8d
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_partitions/sfn_partition1/sfn_partition1.c
@@ -0,0 +1,46 @@
+
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdint.h>
+#include "psa/service.h"
+#include "psa_manifest/sfn_partition1.h"
+#include "tfm_sp_log.h"
+
+/**
+ * \brief An example service implementation that prints out a message.
+ */
+psa_status_t tfm_sfn1_service1_sfn(const psa_msg_t* msg)
+{
+    psa_status_t status;
+
+    if (msg == NULL) {
+        psa_panic();
+    }
+
+    /* Decode the message */
+    switch (msg->type) {
+    case PSA_IPC_CALL:
+        LOG_INFFMT("[SFN1 partition] Service in SFN1 called!\r\n");
+        status = PSA_SUCCESS;
+        break;
+    default:
+        /* Invalid message type */
+        status = PSA_ERROR_PROGRAMMER_ERROR;
+        break;
+    }
+    return status;
+}
+
+/**
+ * \brief SFN partition's initialization function is optional.
+ */
+psa_status_t sfn_partition_example1_init(void)
+{
+    LOG_INFFMT("[SFN1 partition] SFN1 initialized.\r\n");
+    return PSA_SUCCESS;
+}
diff --git a/test/test_services/tfm_test_sfn_partitions/sfn_partition1/sfn_partition1.yaml b/test/test_services/tfm_test_sfn_partitions/sfn_partition1/sfn_partition1.yaml
new file mode 100644
index 0000000..439bb67
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_partitions/sfn_partition1/sfn_partition1.yaml
@@ -0,0 +1,27 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+{
+  "psa_framework_version": 1.1,
+  "name": "TFM_SFN_PARTITION1",
+  "type": "APPLICATION-ROT",
+  "priority": "NORMAL",
+  "model": "SFN",
+  "entry_init": "sfn_partition_example1_init",
+  "stack_size": "0x200",
+  "services": [
+    {
+      "name": "TFM_SFN1_SERVICE1",
+      "sid": "0x0000F100",
+      "non_secure_clients": true,
+      "connection_based": false,
+      "stateless_handle": "auto",
+      "version": 1,
+      "version_policy": "RELAXED"
+    }
+  ],
+}
diff --git a/test/test_services/tfm_test_sfn_partitions/sfn_partition2/CMakeLists.txt b/test/test_services/tfm_test_sfn_partitions/sfn_partition2/CMakeLists.txt
new file mode 100644
index 0000000..486efaf
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_partitions/sfn_partition2/CMakeLists.txt
@@ -0,0 +1,59 @@
+
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+if (NOT TFM_PARTITION_SFN2)
+    return()
+endif()
+
+cmake_minimum_required(VERSION 3.15)
+cmake_policy(SET CMP0079 NEW)
+
+add_library(tfm_app_rot_partition_sfn2 STATIC)
+
+target_sources(tfm_app_rot_partition_sfn2
+    PRIVATE
+        sfn_partition2.c
+)
+
+target_include_directories(tfm_partitions
+    INTERFACE
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition2
+)
+
+# The generated sources
+target_sources(tfm_app_rot_partition_sfn2
+    PRIVATE
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition2/auto_generated/intermedia_sfn_partition2.c
+)
+target_sources(tfm_partitions
+    INTERFACE
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition2/auto_generated/load_info_sfn_partition2.c
+)
+
+target_include_directories(tfm_app_rot_partition_sfn2
+    PRIVATE
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+        ${CMAKE_BINARY_DIR}/generated/test_services/sfn_partition2
+)
+
+target_link_libraries(tfm_app_rot_partition_sfn2
+    PRIVATE
+        tfm_secure_api
+        psa_interface
+        platform_s
+        tfm_sprt
+)
+
+############################ Partition Defs ####################################
+target_link_libraries(tfm_partitions
+    INTERFACE
+        tfm_app_rot_partition_sfn2
+)
+target_compile_definitions(tfm_partition_defs
+    INTERFACE
+        TFM_PARTITION_SFN2
+)
diff --git a/test/test_services/tfm_test_sfn_partitions/sfn_partition2/sfn_partition2.c b/test/test_services/tfm_test_sfn_partitions/sfn_partition2/sfn_partition2.c
new file mode 100644
index 0000000..fa5023f
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_partitions/sfn_partition2/sfn_partition2.c
@@ -0,0 +1,52 @@
+
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdint.h>
+#include "psa/service.h"
+#include "psa_manifest/sfn_partition2.h"
+#include "tfm_sp_log.h"
+#include "psa_manifest/sid.h"
+
+/**
+ * \brief An example service implementation that prints out a message.
+ */
+psa_status_t tfm_sfn2_service1_sfn(const psa_msg_t* msg)
+{
+    psa_status_t status;
+
+    if (msg == NULL) {
+        psa_panic();
+    }
+
+    /* Decode the message */
+    switch (msg->type) {
+    case PSA_IPC_CONNECT:
+    case PSA_IPC_DISCONNECT:
+        status = PSA_SUCCESS;
+        break;
+    case PSA_IPC_CALL:
+        LOG_INFFMT("[Example SFN2 partition] Service in SFN2 called!\r\n");
+        status = PSA_SUCCESS;
+        break;
+    default:
+        /* Invalid message type */
+        status = PSA_ERROR_PROGRAMMER_ERROR;
+        break;
+    }
+    return status;
+}
+
+/**
+ * \brief SFN partition's initialization function is optional.
+ */
+psa_status_t sfn_partition_example2_init(void)
+{
+    LOG_INFFMT("[SFN2 partition] SFN2 initialized.\r\n");
+    return psa_call(TFM_SFN1_SERVICE1_HANDLE, PSA_IPC_CALL,
+                    NULL, 0, NULL, 0);
+}
diff --git a/test/test_services/tfm_test_sfn_partitions/sfn_partition2/sfn_partition2.yaml b/test/test_services/tfm_test_sfn_partitions/sfn_partition2/sfn_partition2.yaml
new file mode 100644
index 0000000..06ce438
--- /dev/null
+++ b/test/test_services/tfm_test_sfn_partitions/sfn_partition2/sfn_partition2.yaml
@@ -0,0 +1,29 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+{
+  "psa_framework_version": 1.1,
+  "name": "TFM_SFN_PARTITION2",
+  "type": "APPLICATION-ROT",
+  "priority": "NORMAL",
+  "model": "SFN",
+  "entry_init": "sfn_partition_example2_init",
+  "stack_size": "0x200",
+  "services": [
+    {
+      "name": "TFM_SFN2_SERVICE1",
+      "sid": "0x0000F200",
+      "non_secure_clients": true,
+      "connection_based": true,
+      "version": 1,
+      "version_policy": "RELAXED"
+    }
+  ],
+  "dependencies": [
+    "TFM_SFN1_SERVICE1",
+  ]
+}