:name: FastVDMA Cosimulation on Zynq
:description: This script runs Linux with built in FastVDMA driver on Zedboard.

using sysbus
$name?="Zynq-FastVDMA"
mach create $name

machine LoadPlatformDescription @platforms/boards/zedboard.repl
machine LoadPlatformDescriptionFromString 'dma: CoSimulated.CoSimulatedPeripheral @ sysbus <0x43c20000, +0x100> { frequency: 100000; limitBuffer: 100000; timeout: 10000; 0 -> gic@31; cosimToRenodeSignalRange: <0, +1>}'

sysbus Redirect 0xC0000000 0x0 0x10000000

$bin?=@https://dl.antmicro.com/projects/renode/zynq-fastvdma_vmlinux-s_13611036-802d102e9341668636631447e99389f79043c18d
$rootfs?=@https://dl.antmicro.com/projects/renode/zynq-fastvdma_rootfs.ext2-s_33554432-7a53506ed3e6cdaf247280ad7025ff1aa4cb98c5
$dtb?=@https://dl.antmicro.com/projects/renode/zynq-fastvdma.dtb-s_12284-4f3a630a9bce9e0984151b95e9efa581ef7525bf
$dmaLinux?=@https://dl.antmicro.com/projects/renode/libVfastvdma-Linux-x86_64-12746432362.so-s_2078168-e066add0a343381e311b24264f5f700434601b50
$dmaWindows?=@https://dl.antmicro.com/projects/renode/libVfastvdma-Windows-x86_64-12746432362.dll-s_3248733-b126ebbb295a6668560780c35b9f4652e2be833a
$dmaMacOS?=@https://dl.antmicro.com/projects/renode/libVfastvdma-macOS-x86_64-12746432362.dylib-s_235688-84b6822a41f9b46f9890284aa2129d90713fb4eb

### create externals ###

showAnalyzer sysbus.uart1

## set timer frequency ##
ttc0 Frequency 33333333
ttc1 Frequency 33333333

macro reset
"""
    ### set registers ###

    cpu SetRegister 0 0x000
    cpu SetRegister 1 0xD32 # board id
    cpu SetRegister 2 0x100 # device tree address

    ### load binaries ###

    sysbus LoadELF $bin
    sysbus LoadFdt $dtb 0x100 "console=ttyPS0,115200 root=/dev/ram0 rw initrd=0x1a000000,32M" false
    sysbus ZeroRange 0x1a000000 0x800000
    sysbus LoadBinary $rootfs 0x1a000000
"""
dma SimulationFilePathLinux $dmaLinux
dma SimulationFilePathWindows $dmaWindows
dma SimulationFilePathMacOS $dmaMacOS

runMacro $reset
