On Fri, 15 Feb 2019 at 09:56, BALATON Zoltan <bala...@eik.bme.hu> wrote: > > Hello, > > Could someone please explain how the MemoryRegionOps > valid.{min,max}_access_size and unaligned and corresponding impl > constraints work and where are these implemented? And in particular if > this would work: > > static const MemoryRegionOps ops = { > .read = readfn, > .write = writefn, > .valid.min_access_size = 1, > .valid.max_access_size = 4, > .impl.min_access_size = 4, > .impl.max_access_size = 4, > .endianness = DEVICE_LITTLE_ENDIAN, > };
These are implemented in memory.c. The documentation is in the comments on the MemoryRegionOps struct in include/exec/memory.h. The .valid parts should specify what the device permits the guest to do (and where failures result in MemTxErrors usually meaning bus error/data abort). These ought to be handled by the memory_region_access_valid() function, but I can't see how the logic there actually does the right thing. Maybe Paolo understands that part better than me. The .impl parts specify what the implementation can deal with, and access_with_adjusted_size() takes care of making multiple accesses to the underlying device if necessary. (The fiddling of the data to put it in the right place is done at the next level down by memory_region_shift_read_access() and memory_region_shift_write_access().) I think your suggested MemoryRegionOps ought to work. thanks -- PMM