From patchwork Mon Sep 12 10:51:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 114308 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 194AFB71C2 for ; Mon, 12 Sep 2011 20:51:41 +1000 (EST) Received: from localhost ([::1]:32779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R346y-0001lx-VG for incoming@patchwork.ozlabs.org; Mon, 12 Sep 2011 06:51:36 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R346e-0001YD-JH for qemu-devel@nongnu.org; Mon, 12 Sep 2011 06:51:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R346c-0006o5-Hf for qemu-devel@nongnu.org; Mon, 12 Sep 2011 06:51:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R346b-0006mj-VM for qemu-devel@nongnu.org; Mon, 12 Sep 2011 06:51:14 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8CApDTB006660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 12 Sep 2011 06:51:13 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8CApC7h015065 for ; Mon, 12 Sep 2011 06:51:12 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id CD331250B71; Mon, 12 Sep 2011 13:51:08 +0300 (IDT) From: Avi Kivity To: qemu-devel@nongnu.org Date: Mon, 12 Sep 2011 13:51:02 +0300 Message-Id: <1315824666-4214-25-git-send-email-avi@redhat.com> In-Reply-To: <1315824666-4214-1-git-send-email-avi@redhat.com> References: <1315824666-4214-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Error: [-] ERROR: /var/run/p0f.sock: Connection refused X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 24/28] etrax-eth: 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 From: "Edgar E. Iglesias" Signed-off-by: Edgar E. Iglesias Signed-off-by: Avi Kivity --- hw/etraxfs_eth.c | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index 48de6dc..246a279 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -320,6 +320,7 @@ static void mdio_cycle(struct qemu_mdio *bus) struct fs_eth { SysBusDevice busdev; + MemoryRegion mmio; NICState *nic; NICConf conf; int ethregs; @@ -373,7 +374,8 @@ static void eth_validate_duplex(struct fs_eth *eth) } } -static uint32_t eth_readl (void *opaque, target_phys_addr_t addr) +static uint64_t +eth_read(void *opaque, target_phys_addr_t addr, unsigned int size) { struct fs_eth *eth = opaque; uint32_t r = 0; @@ -417,9 +419,11 @@ static void eth_update_ma(struct fs_eth *eth, int ma) } static void -eth_writel (void *opaque, target_phys_addr_t addr, uint32_t value) +eth_write(void *opaque, target_phys_addr_t addr, + uint64_t val64, unsigned int size) { struct fs_eth *eth = opaque; + uint32_t value = val64; addr >>= 2; switch (addr) @@ -553,14 +557,14 @@ static void eth_set_link(VLANClientState *nc) eth->phy.link = !nc->link_down; } -static CPUReadMemoryFunc * const eth_read[] = { - NULL, NULL, - ð_readl, -}; - -static CPUWriteMemoryFunc * const eth_write[] = { - NULL, NULL, - ð_writel, +static const MemoryRegionOps eth_ops = { + .read = eth_read, + .write = eth_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4 + } }; static void eth_cleanup(VLANClientState *nc) @@ -589,7 +593,6 @@ static void eth_cleanup(VLANClientState *nc) static int fs_eth_init(SysBusDevice *dev) { struct fs_eth *s = FROM_SYSBUS(typeof(*s), dev); - int eth_regs; if (!s->dma_out || !s->dma_in) { hw_error("Unconnected ETRAX-FS Ethernet MAC.\n"); @@ -600,9 +603,8 @@ static int fs_eth_init(SysBusDevice *dev) s->dma_in->client.opaque = s; s->dma_in->client.pull = NULL; - eth_regs = cpu_register_io_memory(eth_read, eth_write, s, - DEVICE_LITTLE_ENDIAN); - sysbus_init_mmio(dev, 0x5c, eth_regs); + memory_region_init_io(&s->mmio, ð_ops, s, "etraxfs-eth", 0x5c); + sysbus_init_mmio_region(dev, &s->mmio); qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic = qemu_new_nic(&net_etraxfs_info, &s->conf,