[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/20] qdev: convert uhci.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 13/20] qdev: convert uhci. |
Date: |
Mon, 29 Jun 2009 14:46:14 +0200 |
Hookup pci device into qdev.
No usb bus yet, see following patches.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb-uhci.c | 74 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 41 insertions(+), 33 deletions(-)
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index ea83bdc..9ec270e 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -1070,18 +1070,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);
@@ -1105,37 +1098,52 @@ 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,
+ },{
+ /* end of list */
}
- s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
+};
- qemu_register_reset(uhci_reset, 0, s);
- uhci_reset(s);
+static void uhci_register(void)
+{
+ pci_qdev_register_many(uhci_info);
+}
+device_init(uhci_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.5
- [Qemu-devel] [PATCH 06/20] qdev/pci: misc fixes., (continued)
- [Qemu-devel] [PATCH 06/20] qdev/pci: misc fixes., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 02/20] qdev: replace bus_type enum with bus_info struct., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 09/20] qdev: convert piix acpi., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 08/20] qdev: convert piix-ide., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 07/20] qdev/pci: hook up i440fx., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 11/20] qdev: convert es1370., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 12/20] qdev: convert ac97., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 17/20] qdev: convert ohci., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 16/20] qdev/usb: print usb dev info, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 10/20] qdev: convert all vga, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 13/20] qdev: convert uhci.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 15/20] qdev/usb: make qemu aware of usb busses., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 14/20] qdev/usb: add usb bus support to qdev, convert drivers., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 19/20] debug/test patch: add ohci controller to pc, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 18/20] qdev/scsi: add scsi bus support to qdev, convert drivers., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 20/20] debug/test patch: allow specify busnr for -usbdevice, Gerd Hoffmann, 2009/06/29
- Re: [Qemu-devel] [PATCH 0/20] qdev patches., Anthony Liguori, 2009/06/29