From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGujz-000111-6V for qemu-devel@nongnu.org; Wed, 17 Jun 2009 08:59:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGuju-0000vt-0B for qemu-devel@nongnu.org; Wed, 17 Jun 2009 08:59:46 -0400 Received: from [199.232.76.173] (port=50760 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGujt-0000vX-K2 for qemu-devel@nongnu.org; Wed, 17 Jun 2009 08:59:41 -0400 Received: from mx2.redhat.com ([66.187.237.31]:48435) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MGujr-0004Wi-R6 for qemu-devel@nongnu.org; Wed, 17 Jun 2009 08:59:40 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5HCxdgV013322 for ; Wed, 17 Jun 2009 08:59:39 -0400 From: Gerd Hoffmann Date: Wed, 17 Jun 2009 14:59:23 +0200 Message-Id: <1245243565-24807-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1245243565-24807-1-git-send-email-kraxel@redhat.com> References: <1245243565-24807-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 08/10] qdev-ify: uhci List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/usb-uhci.c | 71 +++++++++++++++++++++++++++++++------------------------- 1 files changed, 39 insertions(+), 32 deletions(-) diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 00e740b..e3a501c 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -1069,18 +1069,11 @@ static void uhci_map(PCIDevice *pci_dev, int region_num, register_ioport_read(addr, 32, 1, uhci_ioport_readb, s); } -void usb_uhci_piix3_init(PCIBus *bus, int devfn) +static void usb_uhci_common_initfn(UHCIState *s) { - UHCIState *s; - uint8_t *pci_conf; + uint8_t *pci_conf = s->dev.config; int i; - s = (UHCIState *)pci_register_device(bus, - "USB-UHCI", sizeof(UHCIState), - devfn, NULL, NULL); - pci_conf = s->dev.config; - pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); - pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_2); pci_conf[0x08] = 0x01; // revision number pci_conf[0x09] = 0x00; pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB); @@ -1103,36 +1096,50 @@ void usb_uhci_piix3_init(PCIBus *bus, int devfn) register_savevm("uhci", 0, 1, uhci_save, uhci_load, s); } -void usb_uhci_piix4_init(PCIBus *bus, int devfn) +static void usb_uhci_piix3_initfn(PCIDevice *dev) { - UHCIState *s; - uint8_t *pci_conf; - int i; + UHCIState *s = DO_UPCAST(UHCIState, dev, dev); + uint8_t *pci_conf = s->dev.config; + + pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); + pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_2); + usb_uhci_common_initfn(s); +} + +static void usb_uhci_piix4_initfn(PCIDevice *dev) +{ + UHCIState *s = DO_UPCAST(UHCIState, dev, dev); + uint8_t *pci_conf = s->dev.config; - s = (UHCIState *)pci_register_device(bus, - "USB-UHCI", sizeof(UHCIState), - devfn, NULL, NULL); - pci_conf = s->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_2); - pci_conf[0x08] = 0x01; // revision number - pci_conf[0x09] = 0x00; - pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB); - pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type - pci_conf[0x3d] = 4; // interrupt pin 3 - pci_conf[0x60] = 0x10; // release number + usb_uhci_common_initfn(s); +} - for(i = 0; i < NB_PORTS; i++) { - qemu_register_usb_port(&s->ports[i].port, s, i, uhci_attach); +static PCIDeviceInfo uhci_info[] = { + { + .qdev.name = "PIIX3 USB-UHCI", + .qdev.size = sizeof(UHCIState), + .init = usb_uhci_piix3_initfn, + },{ + .qdev.name = "PIIX4 USB-UHCI", + .qdev.size = sizeof(UHCIState), + .init = usb_uhci_piix4_initfn, } - s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s); +}; - uhci_reset(s); +static void acpi_register(void) +{ + pci_qdev_register(uhci_info, ARRAY_SIZE(uhci_info)); +} +device_init(acpi_register); - /* Use region 4 for consistency with real hardware. BSD guests seem - to rely on this. */ - pci_register_bar(&s->dev, 4, 0x20, - PCI_ADDRESS_SPACE_IO, uhci_map); +void usb_uhci_piix3_init(PCIBus *bus, int devfn) +{ + pci_create_simple(bus, devfn, "PIIX3 USB-UHCI"); +} - register_savevm("uhci", 0, 1, uhci_save, uhci_load, s); +void usb_uhci_piix4_init(PCIBus *bus, int devfn) +{ + pci_create_simple(bus, devfn, "PIIX4 USB-UHCI"); } -- 1.6.2.2