From patchwork Wed Aug 24 17:28:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111387 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BFC74B6F62 for ; Thu, 25 Aug 2011 03:28:36 +1000 (EST) Received: from localhost ([::1]:34359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwHFg-0002ph-AC for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2011 13:28:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:45447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwHFa-0002mM-UU for qemu-devel@nongnu.org; Wed, 24 Aug 2011 13:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwHFa-0004Cc-1k for qemu-devel@nongnu.org; Wed, 24 Aug 2011 13:28:26 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:38026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwHFZ-0004C7-Kp for qemu-devel@nongnu.org; Wed, 24 Aug 2011 13:28:26 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QwHFV-0004oD-TA; Wed, 24 Aug 2011 18:28:21 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 24 Aug 2011 18:28:21 +0100 Message-Id: <1314206901-18462-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Avi Kivity , patches@linaro.org Subject: [Qemu-devel] [PATCH] hw/smc91c111: Convert to MemoryRegion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Peter Maydell --- This is against master and doesn't depend on or conflict with anything that's in Avi's branch. (I needed this because I've just rebased qemu-linaro on master and one of the omap3 boards connects an smc91c111 up to the omap_gpmc, which means it needs to be able to expose a MemoryRegion*.) hw/smc91c111.c | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-) diff --git a/hw/smc91c111.c b/hw/smc91c111.c index 3a8a85c..fc8c498 100644 --- a/hw/smc91c111.c +++ b/hw/smc91c111.c @@ -43,7 +43,7 @@ typedef struct { uint8_t data[NUM_PACKETS][2048]; uint8_t int_level; uint8_t int_mask; - int mmio_index; + MemoryRegion mmio; } smc91c111_state; static const VMStateDescription vmstate_smc91c111 = { @@ -717,16 +717,15 @@ static ssize_t smc91c111_receive(VLANClientState *nc, const uint8_t *buf, size_t return size; } -static CPUReadMemoryFunc * const smc91c111_readfn[] = { - smc91c111_readb, - smc91c111_readw, - smc91c111_readl -}; - -static CPUWriteMemoryFunc * const smc91c111_writefn[] = { - smc91c111_writeb, - smc91c111_writew, - smc91c111_writel +static const MemoryRegionOps smc91c111_mem_ops = { + /* The special case for 32 bit writes to 0xc means we can't just + * set .impl.min/max_access_size to 1, unfortunately + */ + .old_mmio = { + .read = { smc91c111_readb, smc91c111_readw, smc91c111_readl, }, + .write = { smc91c111_writeb, smc91c111_writew, smc91c111_writel, }, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void smc91c111_cleanup(VLANClientState *nc) @@ -747,11 +746,9 @@ static NetClientInfo net_smc91c111_info = { static int smc91c111_init1(SysBusDevice *dev) { smc91c111_state *s = FROM_SYSBUS(smc91c111_state, dev); - - s->mmio_index = cpu_register_io_memory(smc91c111_readfn, - smc91c111_writefn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, 16, s->mmio_index); + memory_region_init_io(&s->mmio, &smc91c111_mem_ops, s, + "smc91c111-mmio", 16); + sysbus_init_mmio_region(dev, &s->mmio); sysbus_init_irq(dev, &s->irq); qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic = qemu_new_nic(&net_smc91c111_info, &s->conf,