#@TYPE: Machine
#@NAME: VirtIO ARMv8 machine
#@DESCRIPTION: Machine configuration for running an ARMv8 system on VirtIO based platform

require conf/machine/include/arm/arch-armv8a.inc
require conf/machine/include/virtio.inc

KERNEL_IMAGETYPE = "Image"

SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;hvc0"
SERIAL_CONSOLES_CHECK = "${SERIAL_CONSOLES}"

# For runqemu
QB_SYSTEM_NAME = "qemu-system-aarch64"
QB_MACHINE = "-machine virt"
QB_CPU = "-cpu cortex-a57"
QB_CPU_KVM = "-cpu host -machine gic-version=3"
QB_MEM = "-m 2048"
# Standard Serial console
QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0"
# Ensure virtio-mmio support VirtIO 1.0 required by virtio-gpu
QB_OPT_APPEND = "-global virtio-mmio.force-legacy=false"
# TODO: upstream to OE-core runqemu
QB_OPT_APPEND += "-device virtio-gpu-device -display gtk,gl=on -show-cursor"
# Virtio input
QB_OPT_APPEND += "-device virtio-mouse-device -device virtio-keyboard-device"
# Add the 'virtio-rng-device' device otherwise the guest may run out of entropy
QB_OPT_APPEND += "-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0"
# Virtio Networking support
QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"
QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
# Virtio block device
QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0"
# Virtio serial console
QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
QB_TCPSERIAL_OPT = "-device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon"