From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Anthony Liguori Date: Tue, 9 Feb 2010 16:01:38 -0600 Message-Id: <1265752899-26980-15-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1265752899-26980-1-git-send-email-aliguori@us.ibm.com> References: <1265752899-26980-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 14/15] usb-uhci: convert to new pci interface List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Tsirkin , Anthony Liguori , Alex Graf 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; } -- 1.6.5.2