SPM: boot OP-TEE as a guest Secure Partition on top of Hafnium

Add an SPM scenario where Hafnium is loaded as the SPMC at S-EL2
and OP-TEE is instanciated as a Secure Partition at S-EL1.
System boots Hafnium and OP-TEE in the SWd. OP-TEE is booted as
the first and unique Secure Partition. Later when TFTF is booted
in the NWd, the PSA FF-A direct messaging test perform a probing
of OP-TEE's version. The direct message is relayed from TFTF(NS-EL2)
to SPMD(EL3) to Hafnium(S-EL2) and down to OP-TEE(S-EL1). OP-TEE
replies with a direct message response on the way back to TFTF.

Change-Id: Iab033af3d933537df80cc16564bf4172c72f0f93
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/expect/spm-optee-sp-uart1.exp b/expect/spm-optee-sp-uart1.exp
new file mode 100644
index 0000000..9c97617
--- /dev/null
+++ b/expect/spm-optee-sp-uart1.exp
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2020, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+source [file join [file dirname [info script]] handle-arguments.inc]
+
+expect {
+	"OP-TEE version: 3.3"  {
+		puts "<<OP-TEE version>>"
+	}
+	timeout {
+		exit_uart -1
+	}
+}
+
+expect {
+	"Primary CPU switching to normal world boot"  {
+		puts "<<OP-TEE initialized>>"
+	}
+	timeout {
+		exit_uart -1
+	}
+}
+
+exit_uart 0
diff --git a/group/tf-l2-boot-tests-spm/fvp-spm-optee-sp,fvp-default:fvp-spm.optee.sp b/group/tf-l2-boot-tests-spm/fvp-spm-optee-sp,fvp-default:fvp-spm.optee.sp
new file mode 100644
index 0000000..d52947d
--- /dev/null
+++ b/group/tf-l2-boot-tests-spm/fvp-spm-optee-sp,fvp-default:fvp-spm.optee.sp
@@ -0,0 +1,6 @@
+#
+# Copyright (c) 2020, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
diff --git a/run_config/fvp-spm.optee.sp b/run_config/fvp-spm.optee.sp
new file mode 100644
index 0000000..3c963e0
--- /dev/null
+++ b/run_config/fvp-spm.optee.sp
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Copyright (c) 2020, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+post_tf_build() {
+	url="$project_filer/ci-files/spm-07-29-2020/secure_hafnium.bin" fetch_file
+	url="$project_filer/ci-files/spm-07-29-2020/spmc_sel2_optee_sel1.bin" fetch_file
+
+	archive_file "secure_hafnium.bin"
+	archive_file "spmc_sel2_optee_sel1.bin"
+
+	cp "${archive}/spmc_sel2_optee_sel1.bin" "${tf_root}/build/fvp/${bin_mode}"
+
+cat <<EOF > "${tf_root}/build/fvp/${bin_mode}/optee_sp_layout.json"
+{
+	"op-tee" : {
+		"image": "spmc_sel2_optee_sel1.bin",
+		"pm": "${tf_root}/fdts/optee_sp_manifest.dts"
+	}
+}
+EOF
+
+	build_fip BL33="$archive/tftf.bin" BL32="$archive/secure_hafnium.bin"
+}
+
+post_fetch_tf_resource() {
+	model="base-aemv8a" \
+	arch_version="8.4" \
+		gen_model_params
+}
+
+fetch_tf_resource() {
+	# Expect scripts
+	uart="0" file="tftf.exp" track_expect
+	uart="1" file="spm-optee-sp-uart1.exp" track_expect
+}
diff --git a/tf_config/fvp-spm-optee-sp b/tf_config/fvp-spm-optee-sp
new file mode 100644
index 0000000..7533f73
--- /dev/null
+++ b/tf_config/fvp-spm-optee-sp
@@ -0,0 +1,8 @@
+ARM_ARCH_MINOR=4
+ARM_SPMC_MANIFEST_DTS=plat/arm/board/fvp/fdts/fvp_spmc_optee_sp_manifest.dts
+CROSS_COMPILE=aarch64-none-elf-
+CTX_INCLUDE_EL2_REGS=1
+PLAT=fvp
+SPD=spmd
+SP_LAYOUT_FILE=${tf_root}/build/fvp/${bin_mode}/optee_sp_layout.json
+SPMD_SPM_AT_SEL2=1