From patchwork Tue Feb 9 22:01:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 44976 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 D8701B8039 for ; Wed, 10 Feb 2010 09:28:18 +1100 (EST) Received: from localhost ([127.0.0.1]:60562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeyXy-00053a-Qh for incoming@patchwork.ozlabs.org; Tue, 09 Feb 2010 17:27:06 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ney9q-0002ND-LP for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:11 -0500 Received: from [199.232.76.173] (port=52494 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ney9p-0002Lf-3n for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:09 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ney9n-0005p1-U4 for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:08 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:45739) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ney9n-0005ny-Fg for qemu-devel@nongnu.org; Tue, 09 Feb 2010 17:02:07 -0500 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e4.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o19Lpf38020221 for ; Tue, 9 Feb 2010 16:51:41 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o19M1xB3153046 for ; Tue, 9 Feb 2010 17:01:59 -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 o19M1xHV015051 for ; Tue, 9 Feb 2010 17:01:59 -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 o19M1eiO013399; Tue, 9 Feb 2010 17:01:59 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Tue, 9 Feb 2010 16:01:38 -0600 Message-Id: <1265752899-26980-15-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 14/15] usb-uhci: 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/usb-uhci.c | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 434070e..0d049d8 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -1047,17 +1047,34 @@ static void uhci_frame_timer(void *opaque) qemu_mod_timer(s->frame_timer, expire_time); } -static void uhci_map(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) +static uint32_t uhci_ioport_read(PCIDevice *dev, pcibus_t addr, int size) { - UHCIState *s = (UHCIState *)pci_dev; - - register_ioport_write(addr, 32, 2, uhci_ioport_writew, s); - register_ioport_read(addr, 32, 2, uhci_ioport_readw, s); - register_ioport_write(addr, 32, 4, uhci_ioport_writel, s); - register_ioport_read(addr, 32, 4, uhci_ioport_readl, s); - register_ioport_write(addr, 32, 1, uhci_ioport_writeb, s); - register_ioport_read(addr, 32, 1, uhci_ioport_readb, s); + UHCIState *s = DO_UPCAST(UHCIState, dev, dev); + uint32_t value; + + if (size == 1) { + value = uhci_ioport_readb(s, addr); + } else if (size == 2) { + value = uhci_ioport_readw(s, addr); + } else { + value = uhci_ioport_readl(s, addr); + } + + return value; +} + +static void uhci_ioport_write(PCIDevice *dev, pcibus_t addr, int size, + uint32_t value) +{ + UHCIState *s = DO_UPCAST(UHCIState, dev, dev); + + if (size == 1) { + uhci_ioport_writeb(s, addr, value); + } else if (size == 2) { + uhci_ioport_writew(s, addr, value); + } else { + uhci_ioport_writel(s, addr, value); + } } static int usb_uhci_common_initfn(UHCIState *s) @@ -1084,8 +1101,8 @@ static int usb_uhci_common_initfn(UHCIState *s) /* Use region 4 for consistency with real hardware. BSD guests seem to rely on this. */ - pci_register_bar(&s->dev, 4, 0x20, - PCI_BASE_ADDRESS_SPACE_IO, uhci_map); + pci_register_io_region(&s->dev, 4, 0x20, PCI_BASE_ADDRESS_SPACE_IO, + uhci_ioport_read, uhci_ioport_write); return 0; }