From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMjyJ-0007Z1-8t for qemu-devel@nongnu.org; Wed, 18 May 2011 12:51:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QMjyI-0004GR-FQ for qemu-devel@nongnu.org; Wed, 18 May 2011 12:51:43 -0400 Received: from mail-px0-f173.google.com ([209.85.212.173]:55878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMjyI-0004B0-AS for qemu-devel@nongnu.org; Wed, 18 May 2011 12:51:42 -0400 Received: by pxi16 with SMTP id 16so1187100pxi.4 for ; Wed, 18 May 2011 09:51:41 -0700 (PDT) Sender: Richard Henderson Message-ID: <4DD3F912.6040709@twiddle.net> Date: Wed, 18 May 2011 09:51:30 -0700 From: Richard Henderson MIME-Version: 1.0 References: <4DD3C5B9.1080908@redhat.com> <4DD3E0E5.2030700@codemonkey.ws> <4DD3EA2F.4080200@mail.berlios.de> <4DD3EE75.70408@redhat.com> In-Reply-To: <4DD3EE75.70408@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] Memory API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel On 05/18/2011 09:06 AM, Avi Kivity wrote: >> 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. The one thing that makes having these function pointers split apart nice is that it makes it easy to set policy for what different sized reads do. E.g. for devices for which only 4 byte reads are defined, you only fill in readl, and let the other sizes cause a machine-check. Alternately, for devices for which the fundamental size is 1 byte, but which does handle larger reads in a more-or-less memory-like fashion, you can fill in a common readw_via_readb function that does the composition for you, and without having to have code for that scattered through every device. r~