On 13/06/2018 15:06, Mark Cave-Ayland wrote: >> >> Heh, those are disgusting indeed. :) So I guess it would have to stay, >> only MIPS can use the pure MemoryRegion-based approach. > > The only option I can think of is inserting an AddressSpace between the > esp/ledma device and the IOMMU AddressSpace which intercepts the DMA > request (addr, len, direction). > > I can then grab a reference to the device from the MemoryRegion opaque, > perform the magic, and then manually invoke address_space_rw() on iommu_as. > > Is there a hook somewhere in the memory API that could allow me to do this?
No, I don't think so. Only MMIO regions intercept reads/writes, and they only do it at 1/2/4/8 byte granularity. >> 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. > > Hmmm good question. If we can intercept the request above, that would be > my preferred option as something tells it me it might be useful for > other similar situations. Yeah, it wouldn't be a great improvement, but there would be the benefit of more accurate emulation. Paolo