tc: Add support for TC3 platform

This includes scp-boot-tests, tf-a plat test, tf-a boot test, and spm-l3
boot tests.

As time being when submitting this patch, the measured boot and DPE are
not supported on TC3 yet, therefore, the measured boot and DPE test
scripts are not included.

We will introduce these tests on TC3 later when the functionalities are
ready.

Change-Id: I087cbb826cfc39d49614e0cc250f0867d06b204f
Signed-off-by: Quoc Khanh Le <QuocKhanh.Le@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
diff --git a/group/spm-l3-boot-tests/tc-default,fvp-tc3-spm,fvp-tc-spm:fvp-tc.spm.tftf-tc3-debug b/group/spm-l3-boot-tests/tc-default,fvp-tc3-spm,fvp-tc-spm:fvp-tc.spm.tftf-tc3-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/spm-l3-boot-tests/tc-default,fvp-tc3-spm,fvp-tc-spm:fvp-tc.spm.tftf-tc3-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/group/tf-l1-build-plat/fvp-tc3-tbb:nil b/group/tf-l1-build-plat/fvp-tc3-tbb:nil
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tf-l1-build-plat/fvp-tc3-tbb:nil
@@ -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-tc3-nv-ctrs:fvp-linux.tc-fip.tc-tc.crash-tc3-debug b/group/tf-l2-boot-tests-arm-plats/fvp-tc3-nv-ctrs:fvp-linux.tc-fip.tc-tc.crash-tc3-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tf-l2-boot-tests-arm-plats/fvp-tc3-nv-ctrs:fvp-linux.tc-fip.tc-tc.crash-tc3-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-tc3-rotpk:fvp-linux.tc-fip.tc-tc.crash-tc3-debug b/group/tf-l2-boot-tests-arm-plats/fvp-tc3-rotpk:fvp-linux.tc-fip.tc-tc.crash-tc3-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tf-l2-boot-tests-arm-plats/fvp-tc3-rotpk:fvp-linux.tc-fip.tc-tc.crash-tc3-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-tc3-tbb:fvp-linux.tc-fip.tc-tc3-debug b/group/tf-l3-boot-tests-css/fvp-tc3-tbb:fvp-linux.tc-fip.tc-tc3-debug
new file mode 100644
index 0000000..e337bb0
--- /dev/null
+++ b/group/tf-l3-boot-tests-css/fvp-tc3-tbb:fvp-linux.tc-fip.tc-tc3-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2024, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/model/tc3-ports.awk b/model/tc3-ports.awk
new file mode 100644
index 0000000..320eaee
--- /dev/null
+++ b/model/tc3-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/tc3.sh b/model/tc3.sh
new file mode 100644
index 0000000..8ba4565
--- /dev/null
+++ b/model/tc3.sh
@@ -0,0 +1,37 @@
+#!/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/8304/models/$model_flavour/FVP_TC3"
+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 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-linux.tc b/run_config/fvp-linux.tc
index 188110e..91be806 100644
--- a/run_config/fvp-linux.tc
+++ b/run_config/fvp-linux.tc
@@ -20,8 +20,8 @@
 		archive_file "scp_rom.bin"
 	fi
 
-	# RSE is applicable to TC2
-	if [ $plat_variant -eq 2 ]; then
+	# RSE is applicable to TC2 and TC3
+	if [ $plat_variant -eq 2 ] || [ $plat_variant -eq 3 ]; then
 
 	    # Hold RSE terminal_uart_ap
 	    uart="1" port="5003" file="hold_uart.exp" track_expect
diff --git a/run_config/fvp-tc3 b/run_config/fvp-tc3
new file mode 100644
index 0000000..688ebce
--- /dev/null
+++ b/run_config/fvp-tc3
@@ -0,0 +1,11 @@
+generate_lava_job() {
+	local model="tc3"
+
+	uart="1" set_expect_variable "num_cpus" "8"
+
+	set_run_env "ports_script" "$ci_root/model/tc3-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 0c2dc9a..0d2d531 100755
--- a/script/tf-coverity/tf-cov-make
+++ b/script/tf-coverity/tf-cov-make
@@ -349,6 +349,12 @@
 clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=2 ${ARM_TBB_OPTIONS} PLATFORM_TEST=rse-nv-counters
 clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=2 ${ARM_TBB_OPTIONS} PLATFORM_TEST=tfm-testsuite \
     MEASURED_BOOT=1 TF_M_TESTS_PATH=$(pwd)/../tf-m-tests TF_M_EXTRAS_PATH=$(pwd)/../tf-m-extras
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=3 ${ARM_TBB_OPTIONS} \
+    PLAT_MHU_VERSION=3
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=3 ${ARM_TBB_OPTIONS} PLATFORM_TEST=rse-rotpk
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=3 ${ARM_TBB_OPTIONS} PLATFORM_TEST=rse-nv-counters
+clean_build $(common_flags) PLAT=tc TARGET_PLATFORM=3 ${ARM_TBB_OPTIONS} PLATFORM_TEST=tfm-testsuite \
+    TF_M_TESTS_PATH=$(pwd)/../tf-m-tests TF_M_EXTRAS_PATH=$(pwd)/../tf-m-extras
 
 #
 # Morello platform
diff --git a/tf_config/fvp-tc3-nv-ctrs b/tf_config/fvp-tc3-nv-ctrs
new file mode 100644
index 0000000..7233107
--- /dev/null
+++ b/tf_config/fvp-tc3-nv-ctrs
@@ -0,0 +1,10 @@
+ARM_GPT_SUPPORT=1
+ARM_ROTPK_LOCATION=devel_rsa
+CROSS_COMPILE=aarch64-none-elf-
+GENERATE_COT=1
+PLAT=tc
+PLATFORM_TEST=rse-nv-counters
+ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem
+SCP_BL2=/dev/null
+TARGET_PLATFORM=3
+TRUSTED_BOARD_BOOT=1
diff --git a/tf_config/fvp-tc3-rotpk b/tf_config/fvp-tc3-rotpk
new file mode 100644
index 0000000..cb91c85
--- /dev/null
+++ b/tf_config/fvp-tc3-rotpk
@@ -0,0 +1,10 @@
+ARM_GPT_SUPPORT=1
+ARM_ROTPK_LOCATION=devel_rsa
+CROSS_COMPILE=aarch64-none-elf-
+GENERATE_COT=1
+PLAT=tc
+PLATFORM_TEST=rse-rotpk
+ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem
+SCP_BL2=/dev/null
+TARGET_PLATFORM=3
+TRUSTED_BOARD_BOOT=1
diff --git a/tf_config/fvp-tc3-spm b/tf_config/fvp-tc3-spm
new file mode 100644
index 0000000..b516f4d
--- /dev/null
+++ b/tf_config/fvp-tc3-spm
@@ -0,0 +1,12 @@
+ARM_ARCH_MINOR=5
+ARM_GPT_SUPPORT=1
+BRANCH_PROTECTION=1
+CROSS_COMPILE=aarch64-none-elf-
+CTX_INCLUDE_PAUTH_REGS=1
+ENABLE_FEAT_MTE2=1
+ENABLE_SVE_FOR_SWD=1
+PLAT=tc
+SCP_BL2=/dev/null
+SPD=spmd
+SP_LAYOUT_FILE=${tftf_root}/build/tc/${bin_mode}/sp_layout.json
+TARGET_PLATFORM=3
diff --git a/tf_config/fvp-tc3-tbb b/tf_config/fvp-tc3-tbb
new file mode 100644
index 0000000..5660d4a
--- /dev/null
+++ b/tf_config/fvp-tc3-tbb
@@ -0,0 +1,11 @@
+ARM_GPT_SUPPORT=1
+ARM_ROTPK_LOCATION=devel_rsa
+BRANCH_PROTECTION=1
+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
+SCP_BL2=/dev/null
+TARGET_PLATFORM=3
+TRUSTED_BOARD_BOOT=1