feat: add functions for retrieving prebuilts

Add generic functions for retrieving prebuilt binaries. At the moment,
the platforms implement some flavour of these in their *_utils.sh files.
None of these implementations do anything particularly special, for this
reason, should be made generic so future platforms can re-use as much as
possible.

Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
Change-Id: I16abf60e124fa9ef6e8f0016e7b8a6537f238e5e
diff --git a/qemu_utils.sh b/qemu_utils.sh
index 29b8e61..f5e5857 100644
--- a/qemu_utils.sh
+++ b/qemu_utils.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2022 Arm Limited. All rights reserved.
+# Copyright (c) 2023 Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -14,7 +14,7 @@
 default_model_dtb="dtb.bin"
 
 # QEMU Kernel URLs
-declare -A plat_kernel_list=(
+declare -A kernel_list=(
 	[qemu-busybox]="$tfa_downloads/linux_boot/Image.gz"
 )
 
diff --git a/run_config/qemu-linux.rootfs b/run_config/qemu-linux.rootfs
index fe5b4d1..982e6c1 100644
--- a/run_config/qemu-linux.rootfs
+++ b/run_config/qemu-linux.rootfs
@@ -1,11 +1,11 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2022 Arm Limited. All rights reserved.
+# Copyright (c) 2023 Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
 
 fetch_tf_resource() {
-	kernel_type="qemu-busybox" get_kernel
+	image="kernel" type="qemu-busybox" get_boot_image
 	url="$rootfs_url" filename="rootfs.bin" fetch_and_archive
 }
diff --git a/utils.sh b/utils.sh
index 2542277..008f945 100644
--- a/utils.sh
+++ b/utils.sh
@@ -264,13 +264,29 @@
 	fi
 }
 
-get_kernel() {
-	local kernel_type="${kernel_type:?}"
-	local url="${plat_kernel_list[$kernel_type]}"
+get_boot_image() {
+	local image=${image:?}
+	local type=${type:?}
 
-	url="${url:?}" filename="kernel.bin" fetch_and_archive
+	declare -n image_list=${image_list-${image}_list}
+
+	local url="${image_list[${type}]}"
+
+	url="${url:?}" filename="${image}.bin" fetch_and_archive
 }
 
+get_boot_image_from_fip() {(
+	local url="${url:?}"
+	local image="${image:?}"
+	local output_name="${output_name-bl32.bin}"
+
+	cd "$(mktempdir)"
+
+	extract_fip "$url"
+	mv "$image" "$output_name"
+	archive_file "$output_name"
+)}
+
 # Get the path to the run environment variables file.
 #
 # Run environment variables are the test-specific environment variables