blob: 29b8e6143a5892ad3bfcb729f4fe296f64a5673a [file] [log] [blame]
Harrison Mutaia197d5d2022-09-15 13:45:21 +01001#!/usr/bin/env bash
2#
3# Copyright (c) 2022 Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8set -u
9
10rootfs_url="$tfa_downloads/linux_boot/busybox.cpio.gz"
11uefi_url="$tfa_downloads/linux_boot/qemu/QEMU_EFI.fd"
12
13# Default QEMU model variables
14default_model_dtb="dtb.bin"
15
16# QEMU Kernel URLs
17declare -A plat_kernel_list=(
18 [qemu-busybox]="$tfa_downloads/linux_boot/Image.gz"
19)
20
21gen_qemu_yaml(){
22 model="${model:?}"
23 model_bin="${model_bin:qemu-system-aarch64}"
24
25 yaml_template_file="$workspace/qemu_template.yaml"
26 yaml_file="$workspace/qemu.yaml"
27 yaml_job_file="$workspace/job.yaml"
28 lava_model_params="$workspace/lava_model_params"
29
30 # this function expects a template, quit if it is not present
31 if [ ! -f "$yaml_template_file" ]; then
32 return
33 fi
34
35 prompt="${prompt:-root@tf-busyboot:/root#}"
36
37 # Any addition on this array requires an addition in the qemu
38 # templates.
39 declare -A qemu_artefact_urls=(
40 [kernel]="$(gen_bin_url kernel.bin)"
41 [bios]="$(gen_bin_url qemu_bios.bin)"
42 [initrd]="$(gen_bin_url rootfs.bin.gz)"
43 [uboot]="$(gen_bin_url uboot.bin)"
44 )
45
46 declare -A qemu_artefact_filters=(
47 [kernel]="kernel.bin"
48 [bios]="qemu_bios.bin"
49 [initrd]="rootfs.bin"
50 [uboot]="uboot.bin"
51 )
52
53 declare -A qemu_artefact_macros=(
54 ["kernel.bin"]="{kernel}"
55 ["qemu_bios.bin"]="{bios}"
56 ["rootfs.bin"]="{initrd}"
57 ["uboot.bin"]="{uboot}"
58 )
59
60 declare -a qemu_artefacts
61 filter_artefacts qemu_artefacts qemu_artefact_filters
62
63 lava_model_params="${lava_model_params}" \
64 gen_lava_model_params qemu_artefact_macros
65
66 yaml_template_file="$yaml_template_file" \
67 yaml_file="$yaml_file" \
68 yaml_job_file="$yaml_job_file" \
69 gen_lava_job_def qemu_artefacts qemu_artefact_urls
70}
71
72gen_qemu_image(){
73 local image=${image:?}
74 local bl1_path=${bl1_path:?}
75 local fip_path=${fip_path:?}
76
77 # Cocatenate bl1 and fip images to create a single BIOS consumed by QEMU.
78 cp $bl1_path "$image"
79 dd if=$fip_path of="$image" bs=64k seek=4
80
81 archive_file "$image"
82}
83
84set +u