#@TYPE: Machine
#@NAME: Generic Zynq
#@DESCRIPTION: Generic Zynq Device

# Deprecated board config
USE_BOARD = "${@"conf/machine/include/xilinx-board-pre.inc" if d.getVar("BOARD") or d.getVar("BOARD_VARIANT") else ""}"
require ${USE_BOARD}
unset USE_BOARD

#### Preamble
MACHINEOVERRIDES =. "${@['', 'zynq-generic:']['zynq-generic' != '${MACHINE}']}"
#### Regular settings follow

require conf/machine/include/soc-zynq.inc
require conf/machine/include/machine-xilinx-default.inc
require conf/machine/include/machine-xilinx-qemu.inc

MACHINE_FEATURES += "rtc ext2 ext3 vfat usbhost usbgadget"

EXTRA_IMAGEDEPENDS += "libyaml-native python3-cython-native python3-pyyaml-native"

UBOOT_MACHINE ?= "xilinx_zynq_virt_defconfig"

SERIAL_CONSOLES ?= "115200;ttyPS0"

MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "device-tree"

HDF_MACHINE = "zc702-zynq7"

QB_MEM = "-m 1024"
QB_NETWORK_DEVICE = "-net nic,netdev=eth0 -netdev user,id=eth0,tftp=/tftpboot -net nic"
QB_DEFAULT_KERNEL:qemuboot-xilinx = "zImage"

QB_SYSTEM_NAME ?= "${@qemu_target_binary(d)}"
QB_DEFAULT_FSTYPE = "cpio.gz"
QB_DTB = "system.dtb"
QB_ROOTFS_OPT:qemuboot-xilinx = " -drive if=sd,index=1,file=@ROOTFS@,format=raw"

# Replicate BootROM like behaviour, having loaded SPL and PMU(ROM+FW)
QB_OPT_APPEND = " \
	-nographic -serial null -serial mon:stdio \
	-gdb tcp::9000 \
	-device loader,addr=0xf8000008,data=0xDF0D,data-len=4 \
	-device loader,addr=0xf8000140,data=0x00500801,data-len=4 \
	-device loader,addr=0xf800012c,data=0x1ed044d,data-len=4 \
	-device loader,addr=0xf8000108,data=0x0001e008,data-len=4 \
	-device loader,addr=0xF8000910,data=0xF,data-len=0x4 \
	"

#### No additional settings should be after the Postamble
#### Postamble
PACKAGE_EXTRA_ARCHS:append = "${@['', ' zynq_generic']['zynq-generic' != "${MACHINE}"]}"

# Deprecated board config
USE_BOARD = "${@"conf/machine/include/xilinx-board-post.inc" if d.getVar("BOARD") or d.getVar("BOARD_VARIANT") else ""}"
require ${USE_BOARD}
unset USE_BOARD
