On Fri, Oct 26, 2012 at 05:03:04PM +1000, Peter Crosthwaite wrote:
> In my recent USB series Avi mentioned he wanted to do some work with
> the memory API and encourage devices to use the memory API to do
> fine-grained register decoding, i.e. each register is its own
> MemoryRegion. This has the advantage of getting rid of the symmetric
> switch statements in the read and write handlers. The big drawback I
> am seeing is however is indexing into the register file. For example
> in a device i'm working on ATM I have this read handler for my device
> registers:
> 
> static uint64_t devcfg_read (void *opaque, hwaddr addr,
>         unsigned size)
> {
>     struct XilinxDevcfg *s = opaque;
>     uint32_t ret;
> 
>     addr >>= 2;
>     switch (addr)
>     {
>         //TODO: implement any read side effects
>     }
>     ret = s->regs[addr];
>     DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr * 4, ret);
>     return ret;
> }


Hi,

If well designed, most hw has a well designed symtery between regs
that makes things simpler if you can just opencode the decding.
IMO, an mr per reg would just add a massive overhead for no win.
And also, hw implemented decoders look very much like
switch cases in qemu which make things easy to map.

What is the win?

Cheers,
Edgar

Reply via email to