fix: swap LAVA YAML template generation for broken jobs

This change introduces two new hooks:

- `generate_lava_job_template` is expected to generate the initial LAVA
  job YAML file (`job.yaml`), which may include fields which are not
  yet known
- `generate_lava_job` is used to fill in anything in the LAVA job that
  was not known when the job YAML file was generated

Previously, these were incorporated into other hooks almost
arbitrarily, and in some jobs this meant that they were invoked in the
wrong order. These new hooks allow us to be explicit about the order
that these operations occur.

Change-Id: I07f96b91a7ddb04b599ccca674797d4714296c21
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/run_config/fvp-linux.tc b/run_config/fvp-linux.tc
index af6aae1..b309a32 100644
--- a/run_config/fvp-linux.tc
+++ b/run_config/fvp-linux.tc
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2019-2022 Arm Limited. All rights reserved.
+# Copyright (c) 2019-2022, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -8,9 +8,7 @@
 fetch_tf_resource() {
 	kernel_type="fvp-tc-kernel" get_kernel
 	initrd_type="fvp-tc-ramdisk" get_initrd
-	uart="1" set_primary="1" file="linux-rd-busybox.exp" track_expect
 
-	payload_type="linux" gen_fvp_yaml_template
 	# Use SCP binary from SCP build if it exists, or fetch pre-built ones.
 	if [ ! -f "$archive/scp_rom.bin" ]; then
 		# Pick the appropriate binary based on target platform variant
@@ -18,8 +16,6 @@
 		archive_file "scp_rom.bin"
 	fi
 
-	# Hold scp terminal_s0
-	uart="0" file="hold_uart.exp" track_expect
 
 	# RSS is applicable to TC2
 	if [ $plat_variant -eq 2 ]; then
@@ -111,3 +107,11 @@
 	    inject_bl1
 	fi
 }
+
+generate_lava_job_template() {
+	# Hold scp terminal_s0
+	uart="0" file="hold_uart.exp" track_expect
+	uart="1" set_primary="1" file="linux-rd-busybox.exp" track_expect
+
+	payload_type="linux" gen_fvp_yaml_template
+}