From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRxko-0002I0-8N for qemu-devel@nongnu.org; Sat, 27 Oct 2012 00:12:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRxkn-0007yH-BN for qemu-devel@nongnu.org; Sat, 27 Oct 2012 00:12:10 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:43242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRxkn-0007xu-4v for qemu-devel@nongnu.org; Sat, 27 Oct 2012 00:12:09 -0400 Received: by mail-ee0-f45.google.com with SMTP id b47so1437113eek.4 for ; Fri, 26 Oct 2012 21:12:07 -0700 (PDT) Date: Sat, 27 Oct 2012 06:12:00 +0200 From: "Edgar E. Iglesias" Message-ID: <20121027041159.GA20153@zapo> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [RFC] Memory API and fine grained Memory Regions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: Peter Maydell , John Williams , "qemu-devel@nongnu.org Developers" , Avi Kivity 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