On Wed, 3 Mar 2021 at 13:53, Bin Meng <bmeng...@gmail.com> wrote: > > From: Xuzhou Cheng <xuzhou.ch...@windriver.com> > > ZynqMP QSPI supports SPI transfer using DMA mode, but currently this > is unimplemented. When QSPI is programmed to use DMA mode, QEMU will > crash. This is observed when testing VxWorks 7. > > This adds a Xilinx CSU DMA model and the implementation is based on > https://github.com/Xilinx/qemu/blob/master/hw/dma/csu_stream_dma.c. > The DST part of the model is verified along with ZynqMP GQSPI model. >
> +/* len is in bytes */ > +static uint32_t xlnx_csu_dma_read(XlnxCSUDMA *s, uint8_t *buf, uint32_t len) > +{ > + hwaddr addr = (hwaddr)s->regs[R_ADDR_MSB] << 32 | s->regs[R_ADDR]; > + MemTxResult result = MEMTX_OK; > + > + if (xlnx_csu_dma_burst_is_fixed(s)) { > + uint32_t i; > + > + for (i = 0; i < len && (result == MEMTX_OK); i += s->width) { > + uint32_t mlen = MIN(len - i, s->width); > + > + result = address_space_rw(s->dma_as, addr, s->attr, > + buf + i, mlen, false); > + } > + } else { > + result = address_space_rw(s->dma_as, addr, s->attr, buf, len, false); > + } > + > + if (result == MEMTX_OK) { > + xlnx_csu_dma_data_process(s, buf, len); > + } else { > + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address 0x%lx for mem read", > + __func__, addr); Using %lx to print a hwaddr (or other 64-bit values) won't compile on 32-bit hosts or on OSX. For hwaddr you need to use TARGET_FMT_plx. I've fixed up these issues in the pullreq. thanks -- PMM