On 05/18/2011 06:47 PM, Stefan Weil wrote:
I'm not a fan of having per-access type function pointers.
Do you think of something like these declaration:
typedef uint64_t (*MemoryReadFunc)(MemoryRegion *mr,
target_phys_addr_t addr, size_t size);
typedef void (*MemoryWriteFunc)(MemoryRegion *mr, target_phys_addr_t
addr, uint64_t data, size_tsize);
For 32 bit host / target, this would mean some unnecessary overhead.
Frankly, the overhead is pretty low. I think we can neglect it.
What about passing values by address:
typedef void (*MemoryReadFunc)(MemoryRegion *mr, target_phys_addr_t
addr, void *data, size_t size);
typedef void (*MemoryWriteFunc)(MemoryRegion *mr, target_phys_addr_t
addr, const void *data, size_t size);
Those void *s will be quite annoying. Especially on hosts which don't
allow misaligned data, you'll never know how to reference them.
If we keep per-access type function pointers, they should use
individual prototypes
for the different access types:
typedef uint8_t (*MemoryReadbFunc)(MemoryRegion *mr,
target_phys_addr_t addr);
typedef uint16_t (*MemoryReadwFunc)(MemoryRegion *mr,
target_phys_addr_t addr);
typedef uint32_t (*MemoryReadlFunc)(MemoryRegion *mr,
target_phys_addr_t addr);
typedef uint64_t (*MemoryReadllFunc)(MemoryRegion *mr,
target_phys_addr_t addr);
...
I prefer having size as an argument.
Something else I though about:
void memory_region_set_access_sizes(MemoryRegion *mr, int min, int max);
if, for example, min=2 and max=4, then byte accesses will be emulated as
word accesses (RMW for writes) and quad accesses will be emulated as two
long accesses. So a device that emulates 32-bit registers can set
min=max=4 and get all the other sizes for free.
--
error compiling committee.c: too many arguments to function