Hello,
Some devices have bits that allow the guest to change endianness of memory
mapped resources, e.g. ati-vga should allow switching the regs BAR into
big endian on writing a bit. What's the best way to emulate this?
The naive way could be to just test for the bit in the memory ops call
backs and do the swap there, but that would add overhead when it's not
needed (most guests don't need it) and there are two BARs to access the
same registers (one is in an IO BAR that aliases part of the MEM space
BAR) and these may need to have different endianness so I'd rather have
the memory layer handle it.
Now the question is how can the endianness be changed from the memory ops
call back? Is it allowed to overwrite ops.endianness or replace ops with
another one that has DEVICE_BIG_ENDIAN? In MemoryRegion the ops field is
declared const and nothing seems to try to change it so I guess it might
not be changed.
Then do I need to define two memory regions one with little and another
with big endian and unmap/map those when the bit is written? Can this be
done when a write to the bit happens with LE ops then is it possible from
the callback ro unmap the memory region being written and replace it with
another? Is there any other easy simple way that I'm missing?
Regards,
BALATON Zoltan
- Memory region endianness BALATON Zoltan
-