#!/bin/sh arch="${0##*-}" base="$(cd $(dirname $0); cd ..; pwd)" data="${base}/tmp" # arch specific config case "$arch" in i386) qemu="qemu-system-x86_64" craw="blobs/edk2-i386/OVMF_CODE.fd" vraw="blobs/edk2-i386/OVMF_VARS.fd" size="" ;; x86_64) qemu="qemu-system-x86_64" craw="blobs/edk2-x86_64/OVMF_CODE.fd" vraw="blobs/edk2-x86_64/OVMF_VARS.fd" size="" ;; arm) qemu="qemu-system-arm -M virt" craw="blobs/edk2-arm/QEMU_EFI.fd" vraw="blobs/edk2-arm/QEMU_VARS.fd" size="64M" ;; aarch64) qemu="qemu-system-aarch64 -M virt" craw="blobs/edk2-aarch64/QEMU_EFI.fd" vraw="blobs/edk2-aarch64/QEMU_VARS.fd" size="64M" ;; *) echo "unknown arch: $arch" exit 1 ;; esac # create qcow2 images for the firmware code="$data/$arch/efi-code.qcow2" vars="$data/$arch/efi-vars.qcow2" mkdir -p "$data/$arch" if test -f "$code" -a "$craw" -nt "$code"; then # remove stale files rm -f "$code" "$vars" fi if test ! -f "$code"; then qemu-img create -f qcow2 -b "$base/$craw" -F raw "$code" $size fi if test ! -f "$vars"; then qemu-img create -f qcow2 -b "$base/$vraw" -F raw "$vars" $size fi # run qemu exec $qemu \ -drive file="$code",format=qcow2,if=pflash,readonly=on \ -drive file="$vars",format=qcow2,if=pflash \ "$@"