49 lines
1.1 KiB
Bash
Executable file
49 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
bin="$1"
|
|
|
|
canonicalised="$(realpath -- "$bin")"
|
|
parent="$(dirname -- "$canonicalised")"
|
|
bin_name="$(basename -- "$canonicalised")"
|
|
|
|
image="$parent/$bin_name.img"
|
|
|
|
|
|
cat > /tmp/limine.conf <<EOF
|
|
timeout: 0
|
|
serial: yes
|
|
serial_baudrate: 9600
|
|
|
|
/Kernel
|
|
protocol: limine
|
|
path: boot():/boot/kernel.elf
|
|
EOF
|
|
|
|
if [[ "$canonicalised" -nt "$image" ]]; then
|
|
echo "Creating image $image"
|
|
|
|
limine_datadir="$(limine --print-datadir)"
|
|
limine_uefi_path="$limine_datadir/BOOTX64.EFI"
|
|
|
|
dd if=/dev/zero of="$image" bs=1M count=64
|
|
mformat -i "$image" -F ::
|
|
|
|
mmd -i "$image" ::/boot
|
|
mmd -i "$image" ::/EFI
|
|
mmd -i "$image" ::/EFI/BOOT
|
|
|
|
mcopy -i "$image" /tmp/limine.conf ::/boot/limine.conf
|
|
mcopy -i "$image" "$canonicalised" ::/boot/kernel.elf
|
|
mcopy -i "$image" "$limine_uefi_path" ::/EFI/BOOT/BOOTX64.EFI
|
|
fi
|
|
|
|
qemu-system-x86_64 \
|
|
-drive file="$image",format=raw \
|
|
-machine q35,accel=kvm -enable-kvm \
|
|
-drive if=pflash,format=raw,readonly=on,file="$OVMF_PATH/FV/OVMF_CODE.fd" \
|
|
-serial stdio \
|
|
-vga std
|
|
|