feat(spmc) Add TSP tests for EL3 SPMC to CI

TSP tests are designed to be exercised by the
FF-A Test Driver in the Normal World.
These have been designed to test basic functionality of the EL3 SPMC.

These tests currently ensure the following functionality:
  - Partition discovery.
  - Direct messaging.
  - Communication with a Logical SP.
  - Memory Sharing and Lending ABIs
  - Sharing of contiguous and non-contiguous memory regions.
  - Memory region descriptors spread of over multiple
    invocations.
  - Multiple endpoint memory transitions.

This test config builds TF-A with SPMC_AT_EL3
and uses prebuilt Linux Image with integrated
FF-A Test Driver in the Normal World.

Change-Id: Ib6ecca0f87b6696a647afd3bf5a253b5a88fd842
Signed-off-by: Shruti <shruti.gupta@arm.com>
diff --git a/expect-lava/ffa_test_driver.exp b/expect-lava/ffa_test_driver.exp
new file mode 100644
index 0000000..497ff45
--- /dev/null
+++ b/expect-lava/ffa_test_driver.exp
@@ -0,0 +1,24 @@
+#
+ # Copyright (c) 2022, Arm Limited. All rights reserved.
+ #
+ # SPDX-License-Identifier: BSD-3-Clause
+
+expect_string+=('i;buildroot login:')
+expect_string+=("i;;;;\n")
+expect_string+=("i;;;;root")
+expect_string+=("i;;;;\n")
+expect_string+=('i;#')
+expect_string+=("i;;;;\n")
+expect_string+=("i;#;;;ioctl 255")
+expect_string+=("i;;;;\n")
+expect_string+=('i;Test: Echo Message to SP')
+expect_string+=('i;Test: Message Relay vis SP to EL3 LSP.')
+expect_string+=('i;Test: Memory Send.')
+expect_string+=('i;Test: Memory Send in Fragments.')
+expect_string+=('i;Test: Memory Lend.')
+expect_string+=('i;Test: Memory Lend in Fragments.')
+expect_string+=('i;Test: Memory Send with Multiple Endpoints.')
+expect_string+=('i;Test: Memory Lend with Multiple Endpoints.')
+expect_string+=('i;Test: Ensure Duplicate Memory Send Requests are Rejected.')
+expect_string+=('i;Test: Ensure Duplicate Memory Lend Requests are Rejected.')
+expect_string+=('i;Total Failures: 0')
diff --git a/expect-lava/tsp_el3spmc.exp b/expect-lava/tsp_el3spmc.exp
new file mode 100644
index 0000000..751c0af
--- /dev/null
+++ b/expect-lava/tsp_el3spmc.exp
@@ -0,0 +1,13 @@
+#
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+expect_string+=('i;TSP FF-A endpoint id')
+expect_string+=('i;TSP FF-A endpoint id')
+expect_string+=('i;TSP Tests: echo message--')
+expect_string+=('i;TSP Tests: Relaying message--')
+expect_string+=('i;TSP Tests: Memory Share Request--')
+expect_string+=('i;TSP Tests: Memory Lend Request--')
+expect_string+=('i;TSP Tests: Multi Endpoint Memory Share Request--')
+expect_string+=('i;TSP Tests: Multi Endpoint Memory Lend Request--')
diff --git a/expect/ffa_test_driver.exp b/expect/ffa_test_driver.exp
new file mode 100644
index 0000000..28fd6da
--- /dev/null
+++ b/expect/ffa_test_driver.exp
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+source [file join [file dirname [info script]] handle-arguments.inc]
+
+expect {
+        "buildroot login:" {
+                send "\n\nroot\n"
+                puts "<<Linux Booted>>"
+        }
+        timeout {
+                exit_uart -1
+        }
+}
+
+expect {
+        "#" {
+                send "ioctl 255\n"
+        }
+        timeout {
+                exit_uart -1
+        }
+}
+
+expect_string "Test: Echo Message to SP"
+expect_string "Test: Message Relay vis SP to EL3 LSP."
+expect_string "Test: Memory Send."
+expect_string "Test: Memory Send in Fragments."
+expect_string "Test: Memory Lend."
+expect_string "Test: Memory Lend in Fragments."
+expect_string "Test: Memory Send with Multiple Endpoints."
+expect_string "Test: Memory Lend with Multiple Endpoints."
+expect_string "Test: Ensure Duplicate Memory Send Requests are Rejected."
+expect_string "Test: Ensure Duplicate Memory Lend Requests are Rejected."
+
+expect {
+        "Total Failures: 0" {
+                puts "<<SUCCESS>>"
+        }
+        timeout {
+                exit_uart -1
+        }
+}
+
+exit_uart 0
+
diff --git a/expect/tsp_el3spmc.exp b/expect/tsp_el3spmc.exp
new file mode 100644
index 0000000..69f18f7
--- /dev/null
+++ b/expect/tsp_el3spmc.exp
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+source [file join [file dirname [info script]] handle-arguments.inc]
+
+expect_string "TSP FF-A endpoint id"
+expect_string "TSP Tests: echo message--"
+expect_string "TSP Tests: Relaying message--"
+expect_string "TSP Tests: Memory Share Request--"
+expect_string "TSP Tests: Memory Lend Request--"
+expect_string "TSP Tests: Multi Endpoint Memory Share Request--"
+expect_string "TSP Tests: Multi Endpoint Memory Lend Request--"
+
+source [file join [file dirname [info script]] uart-hold.inc]
diff --git a/group/spm-l3-boot-tests/nil,fvp-el3-spmc-tsp,nil:fvp-tsp.rootfs b/group/spm-l3-boot-tests/nil,fvp-el3-spmc-tsp,nil:fvp-tsp.rootfs
new file mode 100644
index 0000000..2d67f85
--- /dev/null
+++ b/group/spm-l3-boot-tests/nil,fvp-el3-spmc-tsp,nil:fvp-tsp.rootfs
@@ -0,0 +1,4 @@
+#
+ # Copyright (c) 2022, Arm Limited. All rights reserved.
+ #
+ # SPDX-License-Identifier: BSD-3-Clause
diff --git a/run_config/fvp-tsp.rootfs b/run_config/fvp-tsp.rootfs
new file mode 100644
index 0000000..e09ca7a
--- /dev/null
+++ b/run_config/fvp-tsp.rootfs
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+ 
+#!/usr/bin/env bash
+
+post_tf_build() {
+        # Fetch EDK2 and pre-built partition files
+        url="$tfa_downloads/spm-el3/06-15-22/normal_world_multi.dts" saveas="normal_world_multi.dts" fetch_file
+        rootfs_url="$tfa_downloads/spm-el3/06-15-22/boot-fat.uefi.img" saveas="boot-fat.uefi.img" get_rootfs
+        url="$tfa_downloads/spm-el3/06-15-22/FVP_AARCH64_EFI.fd" saveas="FVP_AARCH64_EFI.fd" fetch_file
+        archive_file "normal_world_multi.dts"
+        archive_file "FVP_AARCH64_EFI.fd"
+        build_fip BL33="$archive/FVP_AARCH64_EFI.fd" NT_FW_CONFIG="$archive/normal_world_multi.dts"
+}
+
+fetch_tf_resource() {
+        # Expect scripts
+        uart="0" timeout="800" file="ffa_test_driver.exp" track_expect
+        uart="2" timeout="800" file="tsp_el3spmc.exp" track_expect
+        uart="1" timeout="800" file="hold_uart.exp" track_expect
+        payload_type="linux" gen_fvp_yaml_template
+}
+
+post_fetch_tf_resource() {
+        local model="base-aemv8a"
+        model="$model"  arch_version="8.4" gen_model_params
+        model="$model" gen_fvp_yaml
+}
+
diff --git a/tf_config/fvp-el3-spmc-tsp b/tf_config/fvp-el3-spmc-tsp
new file mode 100644
index 0000000..eec1206
--- /dev/null
+++ b/tf_config/fvp-el3-spmc-tsp
@@ -0,0 +1,10 @@
+ARM_SPMC_MANIFEST_DTS=plat/arm/board/fvp/fdts/fvp_tsp_sp_manifest.dts
+CROSS_COMPILE=aarch64-none-elf-
+CTX_INCLUDE_EL2_REGS=0
+CTX_INCLUDE_PAUTH_REGS=1
+EL3_EXCEPTION_HANDLING=0
+LOG_LEVEL=40
+PLAT=fvp
+SPD=spmd
+SPMC_AT_EL3=1
+SPMD_SPM_AT_SEL2=0