#! /bin/sh

#export SDL_VIDEODRIVER=x11

# SDL_AUDIODRIVER=oss or alsa. Only meaningful if QEMU_AUDIO_DRV=sdl.
#export SDL_AUDIODRIVER=oss

# QEMU_AUDIO_DRV=oss or sdl or wav or none. See qemu -audio-help.
export QEMU_AUDIO_DRV=none

CORE_PARAMS="-M vexpress-a9 -smp cpus=2 -m 1024 -L /usr/share/qemu -name \
	stretch-armhf -daemonize -display vnc=:98 -chardev \
	socket,id=monsock,host=127.0.0.1,port=2998,ipv4,server,telnet,nowait \
	-mon chardev=monsock,mode=readline -uuid \
	a78aebf4-680d-4355-9890-be4fa64888d8"

NET_PARAMS='-net nic,macaddr=52:54:00:48:88:D8 -net tap,ifname=stretch-armhf'

LINUX_PARAMS="-kernel /usr/local/share/qemu/zImage-vexpress-4.19.34 -initrd \
	/usr/local/share/qemu/initrd9-vexpress-4.19.34 -dtb \
	/usr/local/share/qemu/vexpress-v2p-ca9.dtb -append \
	'root=/dev/mmcblk0p1 ro fbcon=map:1 nosplash'"

DISK_PARAMS="-drive \
	file=/dev/phoenix/stretch-armhf,if=sd,aio=native,cache.direct=on,format=raw"

# One of: a (floppy), c (hard disk), d (cdrom), n (network using PXE)          
BOOT_PARAMS='-boot order=c'

echo '== Display on 5998, monitor on 2998 ==='

eval qemu-system-arm $CORE_PARAMS $NET_PARAMS $LINUX_PARAMS $DISK_PARAMS \
	$BOOT_PARAMS
