On 13/06/2018 12:36, Mark Cave-Ayland wrote: > Check out hw/dma/sparc32_dma.c for some ugly examples: > espdma_memory_read()/espdma_memory_write() update the DMA address > pointer register after each read/write, and > ledma_memory_read()/ledma_memory_write() need to determine if the pcnet > card has byte-swapping enabled: if so, then don't perform the required > lance 16-bit swap and if not, do perform the 16-bit swap.
Heh, those are disgusting indeed. :) So I guess it would have to stay, only MIPS can use the pure MemoryRegion-based approach. Regarding pcnet, is CSR_BSWP really a no-op on PCI cards? If not, an option could be to move that handling to pcnet.c - making the ledma swap unconditional and removing the do_bswap argument. The disadvantage is that SPARC would swap twice, and you'd have to keep the callback because of s->dmaregs[3], but maybe it's still worthwhile. Thanks, Paolo