qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC] Memory API


From: Avi Kivity
Subject: Re: [Qemu-devel] [RFC] Memory API
Date: Wed, 18 May 2011 19:06:13 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Thunderbird/3.1.10

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]