mirror of https://github.com/xemu-project/xemu.git
qdev/usb: convert uhci.
Hookup pci device into qdev. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
274945b633
commit
6cf9b6f17a
|
@ -1071,18 +1071,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 int 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);
|
||||
|
@ -1090,7 +1083,7 @@ void usb_uhci_piix3_init(PCIBus *bus, int devfn)
|
|||
pci_conf[0x3d] = 4; // interrupt pin 3
|
||||
pci_conf[0x60] = 0x10; // release number
|
||||
|
||||
s->bus = usb_bus_new(NULL /* FIXME */);
|
||||
s->bus = usb_bus_new(&s->dev.qdev);
|
||||
for(i = 0; i < NB_PORTS; i++) {
|
||||
usb_register_port(s->bus, &s->ports[i].port, s, i, uhci_attach);
|
||||
}
|
||||
|
@ -1105,40 +1098,55 @@ void usb_uhci_piix3_init(PCIBus *bus, int devfn)
|
|||
PCI_ADDRESS_SPACE_IO, uhci_map);
|
||||
|
||||
register_savevm("uhci", 0, 1, uhci_save, uhci_load, s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usb_uhci_piix3_initfn(PCIDevice *dev)
|
||||
{
|
||||
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);
|
||||
return usb_uhci_common_initfn(s);
|
||||
}
|
||||
|
||||
static int usb_uhci_piix4_initfn(PCIDevice *dev)
|
||||
{
|
||||
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_82371AB_2);
|
||||
return usb_uhci_common_initfn(s);
|
||||
}
|
||||
|
||||
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 */
|
||||
}
|
||||
};
|
||||
|
||||
static void uhci_register(void)
|
||||
{
|
||||
pci_qdev_register_many(uhci_info);
|
||||
}
|
||||
device_init(uhci_register);
|
||||
|
||||
void usb_uhci_piix3_init(PCIBus *bus, int devfn)
|
||||
{
|
||||
pci_create_simple(bus, devfn, "PIIX3 USB-UHCI");
|
||||
}
|
||||
|
||||
void usb_uhci_piix4_init(PCIBus *bus, int devfn)
|
||||
{
|
||||
UHCIState *s;
|
||||
uint8_t *pci_conf;
|
||||
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_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
|
||||
|
||||
s->bus = usb_bus_new(NULL /* FIXME */);
|
||||
for(i = 0; i < NB_PORTS; i++) {
|
||||
usb_register_port(s->bus, &s->ports[i].port, s, i, uhci_attach);
|
||||
}
|
||||
s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
|
||||
|
||||
qemu_register_reset(uhci_reset, s);
|
||||
uhci_reset(s);
|
||||
|
||||
/* 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);
|
||||
|
||||
register_savevm("uhci", 0, 1, uhci_save, uhci_load, s);
|
||||
pci_create_simple(bus, devfn, "PIIX4 USB-UHCI");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue