tc: Add tests on TC4

This patch adds tests on TC4:

  - SPM l3 boot test
  - nv counter test
  - rotpk test
  - Trusted boot test
  - Measured boot with DPE

Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Icen Zeyada <Icen.Zeyada2@arm.com>

Change-Id: I51847dddf13954b50b20930d6607b62bd6e69d01
diff --git a/group/spm-l3-boot-tests/tc-default,fvp-tc4-spm,fvp-tc-spm:fvp-tc.spm.tftf-tc4-debug b/group/spm-l3-boot-tests/tc-default,fvp-tc4-spm,fvp-tc-spm:fvp-tc.spm.tftf-tc4-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/spm-l3-boot-tests/tc-default,fvp-tc4-spm,fvp-tc-spm:fvp-tc.spm.tftf-tc4-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/group/tf-l2-boot-tests-arm-plats/fvp-tc4-nv-ctrs:fvp-linux.tc-fip.tc-tc.crash-tc4-debug b/group/tf-l2-boot-tests-arm-plats/fvp-tc4-nv-ctrs:fvp-linux.tc-fip.tc-tc.crash-tc4-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tf-l2-boot-tests-arm-plats/fvp-tc4-nv-ctrs:fvp-linux.tc-fip.tc-tc.crash-tc4-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/group/tf-l2-boot-tests-arm-plats/fvp-tc4-rotpk:fvp-linux.tc-fip.tc-tc.crash-tc4-debug b/group/tf-l2-boot-tests-arm-plats/fvp-tc4-rotpk:fvp-linux.tc-fip.tc-tc.crash-tc4-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tf-l2-boot-tests-arm-plats/fvp-tc4-rotpk:fvp-linux.tc-fip.tc-tc.crash-tc4-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/group/tf-l3-boot-tests-css/fvp-tc4-tbb:fvp-linux.tc-fip.tc-tc4-debug b/group/tf-l3-boot-tests-css/fvp-tc4-tbb:fvp-linux.tc-fip.tc-tc4-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tf-l3-boot-tests-css/fvp-tc4-tbb:fvp-linux.tc-fip.tc-tc4-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/group/tf-l3-boot-tests-misc/fvp-tc4-tbb-dpe:fvp-linux.tc-fip.tc-tc4-debug b/group/tf-l3-boot-tests-misc/fvp-tc4-tbb-dpe:fvp-linux.tc-fip.tc-tc4-debug
new file mode 100644
index 0000000..19363ec
--- /dev/null
+++ b/group/tf-l3-boot-tests-misc/fvp-tc4-tbb-dpe:fvp-linux.tc-fip.tc-tc4-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/model/tc4-ports.awk b/model/tc4-ports.awk
new file mode 100644
index 0000000..320eaee
--- /dev/null
+++ b/model/tc4-ports.awk
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2021-2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+/^terminal_uart:/ { ports[0] = $NF }
+/^rse_terminal_uart:/ { ports[1] = $NF }
+/^terminal_uart_ap:/ { ports[2] = $NF }
+/^terminal_uart1_ap:/ { ports[3] = $NF }
+END {
+	for (i = 0; i < num_uarts; i++) {
+		if (ports[i] != "")
+			print "ports[" i "]=" ports[i]
+	}
+}
diff --git a/model/tc4.sh b/model/tc4.sh
new file mode 100644
index 0000000..e9c7c56
--- /dev/null
+++ b/model/tc4.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2022-2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+set_model_path "$warehouse/SysGen/SubSystemModels/0.0/8404/models/$model_flavour/FVP_TC4"
+cat <<EOF >"$model_param_file"
+${fip_gpt_bin+-C board.flashloader0.fname=$fip_gpt_bin}
+-C board.pl011_uart2.unbuffered_output=1
+-C board.pl011_uart3.unbuffered_output=1
+-C css.pl011_uart1_ap.unbuffered_output=1
+-C css.pl011_uart_ap.unbuffered_output=1
+-C soc.pl011_uart0.unbuffered_output=1
+-C soc.pl011_uart1.unbuffered_output=1
+-C css.sms.scp.uart.unbuffered_output=1
+-C css.sms.rse_pl011_uart.unbuffered_output=1
+-C css.terminal_uart_ap.start_port=5000
+-C css.terminal_uart1_ap.start_port=5001
+-C css.sms.scp.terminal_uart.start_port=5002
+-C css.sms.rse_terminal_uart.start_port=5003
+-C displayController=2
+${rse_rom_bin+-C css.sms.rse.rom.raw_image=$rse_rom_bin}
+-C css.sms.rse.VMADDRWIDTH=16
+-C css.sms.rse.intchecker.ICBC_RESET_VALUE=0x0000011B
+-C css.sms.rse.sic.SIC_AUTH_ENABLE=1
+-C css.sms.rse.sic.SIC_DECRYPT_ENABLE=1
+${rse_encrypted_cm_provisioning_bundle_0_bin+--data css.sms.rse.sram0=${rse_encrypted_cm_provisioning_bundle_0_bin}@0x400}
+${rse_encrypted_dm_provisioning_bundle_bin+--data css.sms.rse.sram1=${rse_encrypted_dm_provisioning_bundle_bin}@0x0}
+-C css.cluster0.subcluster0.has_ete=1
+-C css.cluster0.subcluster1.has_ete=1
+-C css.cluster0.subcluster2.has_ete=1
+-C css.cluster0.NUM_CMES=2
+-C board.smsc_91c111.enabled=1
+-C board.hostbridge.userNetworking=1
+-C board.hostbridge.userNetPorts="8080=80,8022=22"
+${tc_fitimage_bin+--data board.dram=$tc_fitimage_bin@0x20000000}
+EOF
diff --git a/run_config/fvp-tc4 b/run_config/fvp-tc4
new file mode 100644
index 0000000..7d8eda8
--- /dev/null
+++ b/run_config/fvp-tc4
@@ -0,0 +1,11 @@
+generate_lava_job() {
+	local model="tc4"
+
+	uart="1" set_expect_variable "num_cpus" "8"
+
+	set_run_env "ports_script" "$ci_root/model/tc4-ports.awk"
+	set_run_env "num_uarts" "4"
+
+	model="$model" gen_model_params
+	model="$model" gen_fvp_yaml
+}
diff --git a/script/tf-coverity/tf-cov-make b/script/tf-coverity/tf-cov-make
index 3942b17..a9473f5 100755
--- a/script/tf-coverity/tf-cov-make
+++ b/script/tf-coverity/tf-cov-make
@@ -363,6 +363,12 @@
     MEASURED_BOOT=1 QCBOR_DIR=$(pwd)/qcbor TF_M_TESTS_PATH=$(pwd)/../tf-m-tests TF_M_EXTRAS_PATH=$(pwd)/../tf-m-extras
 clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=4 ${ARM_TBB_OPTIONS} \
     PLAT_MHU_VERSION=3
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=4 ${ARM_TBB_OPTIONS} PLATFORM_TEST=rse-rotpk
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=4 ${ARM_TBB_OPTIONS} PLATFORM_TEST=rse-nv-counters
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=4 ${ARM_TBB_OPTIONS} PLATFORM_TEST=tfm-testsuite \
+    TF_M_TESTS_PATH=$(pwd)/../tf-m-tests TF_M_EXTRAS_PATH=$(pwd)/../tf-m-extras
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=4 ${ARM_TBB_OPTIONS} MEASURED_BOOT=1 \
+    DICE_PROTECTION_ENVIRONMENT=1 QCBOR_DIR=$(pwd)/qcbor
 
 #
 # Morello platform
diff --git a/tf_config/fvp-tc4-nv-ctrs b/tf_config/fvp-tc4-nv-ctrs
new file mode 100644
index 0000000..95034af
--- /dev/null
+++ b/tf_config/fvp-tc4-nv-ctrs
@@ -0,0 +1,12 @@
+ARM_GPT_SUPPORT=1
+ARM_ROTPK_LOCATION=devel_ecdsa
+CROSS_COMPILE=aarch64-none-elf-
+GENERATE_COT=1
+PLAT=tc
+PLATFORM_TEST=rse-nv-counters
+ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_ecdsa.pem
+KEY_ALG=ecdsa
+SCP_BL2=/dev/null
+TARGET_PLATFORM=4
+TRUSTED_BOARD_BOOT=1
+CSS_LOAD_SCP_IMAGES=0
diff --git a/tf_config/fvp-tc4-rotpk b/tf_config/fvp-tc4-rotpk
new file mode 100644
index 0000000..35a0e5b
--- /dev/null
+++ b/tf_config/fvp-tc4-rotpk
@@ -0,0 +1,12 @@
+ARM_GPT_SUPPORT=1
+ARM_ROTPK_LOCATION=devel_ecdsa
+CROSS_COMPILE=aarch64-none-elf-
+GENERATE_COT=1
+PLAT=tc
+PLATFORM_TEST=rse-rotpk
+ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_ecdsa.pem
+KEY_ALG=ecdsa
+SCP_BL2=/dev/null
+TARGET_PLATFORM=4
+TRUSTED_BOARD_BOOT=1
+CSS_LOAD_SCP_IMAGES=0
diff --git a/tf_config/fvp-tc4-spm b/tf_config/fvp-tc4-spm
new file mode 100644
index 0000000..82302c7
--- /dev/null
+++ b/tf_config/fvp-tc4-spm
@@ -0,0 +1,8 @@
+ARM_GPT_SUPPORT=1
+CROSS_COMPILE=aarch64-none-elf-
+PLAT=tc
+SCP_BL2=/dev/null
+SPD=spmd
+SP_LAYOUT_FILE=${tftf_root}/build/tc/${bin_mode}/sp_layout.json
+TARGET_PLATFORM=4
+CSS_LOAD_SCP_IMAGES=0
diff --git a/tf_config/fvp-tc4-tbb b/tf_config/fvp-tc4-tbb
index d677768..d90d0e7 100644
--- a/tf_config/fvp-tc4-tbb
+++ b/tf_config/fvp-tc4-tbb
@@ -1,11 +1,11 @@
 ARM_GPT_SUPPORT=1
-ARM_ROTPK_LOCATION=devel_rsa
-BRANCH_PROTECTION=1
+ARM_ROTPK_LOCATION=devel_ecdsa
 CROSS_COMPILE=aarch64-none-elf-
-CTX_INCLUDE_PAUTH_REGS=1
 GENERATE_COT=1
 PLAT=tc
-ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem
+ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_ecdsa.pem
+KEY_ALG=ecdsa
 SCP_BL2=/dev/null
 TARGET_PLATFORM=4
 TRUSTED_BOARD_BOOT=1
+CSS_LOAD_SCP_IMAGES=0
diff --git a/tf_config/fvp-tc4-tbb-dpe b/tf_config/fvp-tc4-tbb-dpe
new file mode 100644
index 0000000..1435e98
--- /dev/null
+++ b/tf_config/fvp-tc4-tbb-dpe
@@ -0,0 +1,13 @@
+ARM_GPT_SUPPORT=1
+ARM_ROTPK_LOCATION=devel_ecdsa
+CROSS_COMPILE=aarch64-none-elf-
+DICE_PROTECTION_ENVIRONMENT=1
+GENERATE_COT=1
+MEASURED_BOOT=1
+PLAT=tc
+ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_ecdsa.pem
+KEY_ALG=ecdsa
+SCP_BL2=/dev/null
+TARGET_PLATFORM=4
+TRUSTED_BOARD_BOOT=1
+CSS_LOAD_SCP_IMAGES=0