From patchwork Tue Feb 9 22:01:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 44979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 32560B7E21 for ; Wed, 10 Feb 2010 09:35:57 +1100 (EST) Received: from localhost ([127.0.0.1]:55120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Neydz-0001fM-OZ for incoming@patchwork.ozlabs.org; Tue, 09 Feb 2010 17:33:19 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ney9w-0002UL-Mp for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:16 -0500 Received: from [199.232.76.173] (port=52499 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ney9w-0002Tv-BC for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:16 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ney9m-0005os-UH for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:15 -0500 Received: from e6.ny.us.ibm.com ([32.97.182.146]:41387) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ney9m-0005ng-HO for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:06 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e6.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o19LwVfO021134 for ; Tue, 9 Feb 2010 16:58:31 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o19M1wqM142888 for ; Tue, 9 Feb 2010 17:01:58 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o19M1vr2014890 for ; Tue, 9 Feb 2010 17:01:57 -0500 Received: from localhost.localdomain (sig-9-65-47-242.mts.ibm.com [9.65.47.242]) by d01av01.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o19M1eiM013399; Tue, 9 Feb 2010 17:01:56 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Tue, 9 Feb 2010 16:01:36 -0600 Message-Id: <1265752899-26980-13-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1265752899-26980-1-git-send-email-aliguori@us.ibm.com> References: <1265752899-26980-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Michael Tsirkin , Anthony Liguori , Alex Graf Subject: [Qemu-devel] [PATCH 12/15] ne2000: convert to new pci interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Anthony Liguori --- hw/ne2000.c | 50 +++++++++++++++++++++++++++++++++++--------------- 1 files changed, 35 insertions(+), 15 deletions(-) diff --git a/hw/ne2000.c b/hw/ne2000.c index 78fe14f..6952680 100644 --- a/hw/ne2000.c +++ b/hw/ne2000.c @@ -678,24 +678,44 @@ static const VMStateDescription vmstate_pci_ne2000 = { /***********************************************************/ /* PCI NE2000 definitions */ -static void ne2000_map(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) +static uint32_t ne2000_read(PCIDevice *dev, pcibus_t addr, int size) { - PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev); + PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, dev); NE2000State *s = &d->ne2000; + uint32_t value; - register_ioport_write(addr, 16, 1, ne2000_ioport_write, s); - register_ioport_read(addr, 16, 1, ne2000_ioport_read, s); + if (addr < 0x10) { + value = ne2000_ioport_read(s, addr); + } else if (addr < 0x1f) { + if (size == 4) { + value = ne2000_asic_ioport_readl(s, addr); + } else { + value = ne2000_asic_ioport_read(s, addr); + } + } else { + value = ne2000_reset_ioport_read(s, addr); + } - register_ioport_write(addr + 0x10, 1, 1, ne2000_asic_ioport_write, s); - register_ioport_read(addr + 0x10, 1, 1, ne2000_asic_ioport_read, s); - register_ioport_write(addr + 0x10, 2, 2, ne2000_asic_ioport_write, s); - register_ioport_read(addr + 0x10, 2, 2, ne2000_asic_ioport_read, s); - register_ioport_write(addr + 0x10, 4, 4, ne2000_asic_ioport_writel, s); - register_ioport_read(addr + 0x10, 4, 4, ne2000_asic_ioport_readl, s); + return value; +} - register_ioport_write(addr + 0x1f, 1, 1, ne2000_reset_ioport_write, s); - register_ioport_read(addr + 0x1f, 1, 1, ne2000_reset_ioport_read, s); +static void ne2000_write(PCIDevice *dev, pcibus_t addr, int size, + uint32_t value) +{ + PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, dev); + NE2000State *s = &d->ne2000; + + if (addr < 0x10) { + ne2000_ioport_write(s, addr, value); + } else if (addr < 0x1f) { + if (size == 4) { + ne2000_asic_ioport_writel(s, addr, value); + } else { + ne2000_asic_ioport_write(s, addr, value); + } + } else { + ne2000_reset_ioport_write(s, addr, value); + } } static void ne2000_cleanup(VLANClientState *nc) @@ -727,8 +747,8 @@ static int pci_ne2000_init(PCIDevice *pci_dev) /* TODO: RST# value should be 0. PCI spec 6.2.4 */ pci_conf[PCI_INTERRUPT_PIN] = 1; // interrupt pin 0 - pci_register_bar(&d->dev, 0, 0x100, - PCI_BASE_ADDRESS_SPACE_IO, ne2000_map); + pci_register_io_region(&d->dev, 0, 0x100, PCI_BASE_ADDRESS_SPACE_IO, + ne2000_read, ne2000_write); s = &d->ne2000; s->irq = d->dev.irq[0];