From patchwork Thu Aug 11 11:47:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 109598 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 4AB8CB6F82 for ; Thu, 11 Aug 2011 21:48:51 +1000 (EST) Received: from localhost ([::1]:43253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrTkl-0000tz-07 for incoming@patchwork.ozlabs.org; Thu, 11 Aug 2011 07:48:47 -0400 Received: from eggs.gnu.org ([140.186.70.92]:45057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrTk7-0007Ix-Dk for qemu-devel@nongnu.org; Thu, 11 Aug 2011 07:48:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrTk2-0007gn-DW for qemu-devel@nongnu.org; Thu, 11 Aug 2011 07:48:07 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:51798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrTk2-0007T2-68 for qemu-devel@nongnu.org; Thu, 11 Aug 2011 07:48:02 -0400 Received: by mail-fx0-f45.google.com with SMTP id b27so1841923fxb.4 for ; Thu, 11 Aug 2011 04:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=BNCSVdSYZ9Hj+F/c312lCP6a22xI4881IZbiDkuqah0=; b=xdpY8kmwDQurInTua+ONjhtInHkXw/bsDaTvPscPOXCPReFUcADWFNAfGjn1uMKnrb szUPtnAQx2iHVmzDALUtzpCvDJJl5b3k7crlwdjPk99FT+7kUTTwK4mNFMQGFeA0mDUm lacLXaEiPuy+FvjARtgQ5R7Dk9NMgNM/I/PoE= Received: by 10.223.20.154 with SMTP id f26mr3356045fab.104.1313063281726; Thu, 11 Aug 2011 04:48:01 -0700 (PDT) Received: from localhost (h59ec324b.selukar.dyn.perspektivbredband.net [89.236.50.75]) by mx.google.com with ESMTPS id f3sm612022fah.10.2011.08.11.04.48.00 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Aug 2011 04:48:00 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Thu, 11 Aug 2011 13:47:48 +0200 Message-Id: <1313063268-4208-5-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1313063268-4208-1-git-send-email-edgar.iglesias@gmail.com> References: <1313063268-4208-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.45 Cc: "Edgar E. Iglesias" , avi@redhat.com, edgar@axis.com Subject: [Qemu-devel] [PATCH 5/5] 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 --- 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 92d4eca..38b33bf 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 NetClientInfo net_etraxfs_info = { 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,