feat(plat/fvp_r): add run and test configs to boot Yocto Linux on FVP-R

This patch adds the appropriate files to build TF-A for fvp_r
and then boot to the Yocto Linux command line. If the command
line is reached the test is considered successful.

This patch only adds support for ARM internal Jenkins CI, support for
OpenCI will be added in a future patch.

Files needed by Jenkins can be found here:
http://files.oss.arm.com/downloads/tf-a/fvp_r/

Change-Id: Id18f76b0233d67a8ae8967fedc5b93220a09002e
Signed-off-by: John Powell <john.powell@arm.com>
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
diff --git a/expect/fvp-r-yocto.exp b/expect/fvp-r-yocto.exp
new file mode 100644
index 0000000..ae1de8b
--- /dev/null
+++ b/expect/fvp-r-yocto.exp
@@ -0,0 +1,67 @@
+#

+# Copyright (c) 2021 Arm Limited. All rights reserved.

+#

+# SPDX-License-Identifier: BSD-3-Clause

+#

+# Expect script for booting Yocto linux on FVP-R

+#

+

+source [file join [file dirname [info script]] handle-arguments.inc]

+

+# FVP-R BL1

+expect {

+	"Booting Trusted Firmware" {

+		puts "<<Booting Trusted Firmware>>"

+	}

+	timeout {

+		exit_uart -1

+	}

+}

+

+expect {

+	"BL1: Booting BL33" {

+		puts "<<Booting BL33>>"

+	}

+	timeout {

+		exit_uart -1

+	}

+}

+

+# Uboot

+expect {

+	"U-Boot" {

+		puts "<<Entered Uboot>>"

+	}

+	timeout {

+		exit_uart -1

+	}

+}

+

+# Yocto

+expect {

+	"Booting Linux on physical CPU" {

+		puts "<<Booting Linux>>"

+	}

+	timeout {

+		exit_uart -1

+	}

+}

+

+expect {

+	"fvp-baser-aemv8r64 login:" {

+		puts "<<Yocto Login Prompt Received>>"

+		send "root\n"

+	}

+	timeout {

+		exit_uart -1

+	}

+}

+

+expect {

+	"#" {

+		puts "<<Successfully Reached Yocto Shell>>"

+	}

+	timeout {

+		exit_uart -1

+	}

+}

diff --git a/fvp_r_utils.sh b/fvp_r_utils.sh
new file mode 100644
index 0000000..52b5403
--- /dev/null
+++ b/fvp_r_utils.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+source "$ci_root/fvp_utils.sh"
diff --git a/fvp_utils.sh b/fvp_utils.sh
index e783bbf..4b6a765 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -45,6 +45,7 @@
 fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/FVP_Base"
 fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build};/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}"
 foundation_platform="fvp:foundation_platform_${model_version}_${model_build};/opt/model/Foundation_Platformpkg/models/${model_flavour}"
+fvp_base_aemv8r="fvp:fvp_base_aemv8r_${model_version}_${model_build};/opt/model/AEMv8R_base_pkg/models/${model_flavour}"
 
 # FVP associate array, run_config are keys and fvp container parameters are the values
 #   Container parameters syntax: <model name>;<model dir>;<model bin>
@@ -59,6 +60,7 @@
 [base-aemv8a-gic600ae]=";;;"
 [foundationv8]="${foundation_platform};Foundation_Platform"
 [base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
+[baser-aemv8r]=";;;"
 [cortex-a32x4]="${fvp_arm_std_library_11_12};FVP_Base_Cortex-A32x4"
 [cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
 [cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
diff --git a/lava-expect/fvp-r-yocto.exp b/lava-expect/fvp-r-yocto.exp
new file mode 100644
index 0000000..9f56db2
--- /dev/null
+++ b/lava-expect/fvp-r-yocto.exp
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for booting Yocto linux on FVP-R
+#
+
+# FVP-R BL1
+expect_string+=('i;Booting Trusted Firmware')
+expect_string+=('i;BL1: Booting BL33')
+
+# Uboot
+expect_string+=('i;U-Boot')
+
+# Yocto
+expect_string+=('i;Booting Linux on physical CPU')
+expect_string+=('i;fvp-baser-aemv8r64 login:;;;root\n')
+expect_string+=('i;#')
diff --git a/model/baser-aemv8r.sh b/model/baser-aemv8r.sh
new file mode 100644
index 0000000..b684881
--- /dev/null
+++ b/model/baser-aemv8r.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+if  is_arm_jenkins_env || upon "$local_ci"; then
+	# Internal ARM Jenkins environment path
+	set_model_path "$warehouse/SysGen/Models/$model_version/$model_build/external/models/$model_flavour/FVP_BaseR_AEMv8R"
+else
+	# OpenCI support will be added in a future patch
+	set_model_path ""
+fi
+
+# Write model command line options
+cat <<EOF >"$model_param_file"
+
+-C bp.pl011_uart0.unbuffered_output=1
+-C bp.pl011_uart0.untimed_fifos=true
+-C cache_state_modelled=0
+-C bp.vis.rate_limit-enable=0
+-C cluster0.NUM_CORES=4
+-C cluster0.has_aarch64=1
+-C bp.exclusive_monitor.monitor_access_level=1
+-C cluster0.cpu0.RVBAR=0x80000000
+-C cluster0.cpu1.RVBAR=0x80000000
+-C cluster0.cpu2.RVBAR=0x80000000
+-C cluster0.cpu3.RVBAR=0x80000000
+-C bp.dram_metadata.init_value=0
+-C bp.dram_metadata.is_enabled=true
+-C bp.dram_size=8
+-C bp.refcounter.non_arch_start_at_default=1
+-C bp.ve_sysregs.mmbSiteDefault=0
+-C cluster0.gicv3.cpuintf-mmap-access-level=2
+-C cluster0.gicv3.SRE-enable-action-on-mmap=2
+-C cluster0.gicv3.SRE-EL2-enable-RAO=1
+-C cluster0.gicv3.extended-interrupt-range-support=1
+-C cluster0.stage12_tlb_size=512
+-C gic_distributor.GICD_CTLR-DS-1-means-secure-only=1
+-C gic_distributor.GITS_BASER0-type=1
+-C gic_distributor.ITS-count=1
+-C gic_distributor.ITS-hardware-collection-count=1
+-C gic_distributor.direct-lpi-support=1
+-C gic_distributor.has-two-security-states=0
+-C pctl.startup=0.0.0.*
+-C bp.secureflashloader.fname=$bl1_bin
+-C bp.virtioblockdevice.image_path=$rootfs_bin
+--data cluster0.cpu0=$fip_bin@$fip_addr
+--data cluster0.cpu0=$dtb_bin@$dtb_addr
+--data cluster0.cpu0=$kernel_bin@$kernel_addr
+
+EOF
diff --git a/run_config/fvp-aemv8r.linux b/run_config/fvp-aemv8r.linux
new file mode 100755
index 0000000..8e597f0
--- /dev/null
+++ b/run_config/fvp-aemv8r.linux
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+post_tf_build() {
+	# Download and archive FVP-R files
+	url="$tfa_downloads/fvp_r/core-image-minimal-fvp-baser-aemv8r64.wic" saveas="rootfs.bin" fetch_file
+	url="$tfa_downloads/fvp_r/fvp-baser-aemv8r64.dtb" saveas="dtb.bin" fetch_file
+	url="$tfa_downloads/fvp_r/Image" saveas="kernel.bin" fetch_file
+	url="$tfa_downloads/fvp_r/u-boot.bin" saveas="uboot.bin" fetch_file
+
+	archive_file "rootfs.bin"
+	archive_file "dtb.bin"
+	archive_file "kernel.bin"
+	archive_file "uboot.bin"
+
+	# Build FIP image with Uboot as BL33
+	build_fip BL33="$archive/uboot.bin"
+}
+
+fetch_tf_resource() {
+	# Expect script for yocto linux boot
+	uart="0" file="fvp-r-yocto.exp" track_expect
+
+	# Generate FVP model YAML template
+	payload_type="linux" gen_fvp_yaml_template
+}
+
+post_fetch_tf_resource() {
+        local model="baser-aemv8r"
+
+        # Generate the model command parameters
+	model="$model" \
+	fip_addr=0x40000000 \
+	dtb_addr=0x03000000 \
+	kernel_addr=0x00800000 \
+	gen_model_params
+
+	# Generate the FVP yaml file
+	model="$model" gen_fvp_yaml
+}