mirror of
https://github.com/qemu/qemu.git
synced 2025-08-12 00:08:07 +00:00
uhci: dynamic type generation
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
892776ce02
commit
2c2e852509
@ -88,6 +88,16 @@ enum {
|
|||||||
typedef struct UHCIState UHCIState;
|
typedef struct UHCIState UHCIState;
|
||||||
typedef struct UHCIAsync UHCIAsync;
|
typedef struct UHCIAsync UHCIAsync;
|
||||||
typedef struct UHCIQueue UHCIQueue;
|
typedef struct UHCIQueue UHCIQueue;
|
||||||
|
typedef struct UHCIInfo UHCIInfo;
|
||||||
|
|
||||||
|
struct UHCIInfo {
|
||||||
|
const char *name;
|
||||||
|
uint16_t vendor_id;
|
||||||
|
uint16_t device_id;
|
||||||
|
uint8_t revision;
|
||||||
|
int (*initfn)(PCIDevice *dev);
|
||||||
|
bool unplug;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pending async transaction.
|
* Pending async transaction.
|
||||||
@ -1293,143 +1303,77 @@ static Property uhci_properties[] = {
|
|||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static void piix3_uhci_class_init(ObjectClass *klass, void *data)
|
static void uhci_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
||||||
|
UHCIInfo *info = data;
|
||||||
|
|
||||||
k->init = usb_uhci_common_initfn;
|
k->init = info->initfn ? info->initfn : usb_uhci_common_initfn;
|
||||||
k->exit = usb_uhci_exit;
|
k->exit = info->unplug ? usb_uhci_exit : NULL;
|
||||||
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
k->vendor_id = info->vendor_id;
|
||||||
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_2;
|
k->device_id = info->device_id;
|
||||||
k->revision = 0x01;
|
k->revision = info->revision;
|
||||||
k->class_id = PCI_CLASS_SERIAL_USB;
|
k->class_id = PCI_CLASS_SERIAL_USB;
|
||||||
dc->vmsd = &vmstate_uhci;
|
dc->vmsd = &vmstate_uhci;
|
||||||
dc->props = uhci_properties;
|
dc->props = uhci_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TypeInfo piix3_uhci_info = {
|
static UHCIInfo uhci_info[] = {
|
||||||
|
{
|
||||||
.name = "piix3-usb-uhci",
|
.name = "piix3-usb-uhci",
|
||||||
.parent = TYPE_PCI_DEVICE,
|
.vendor_id = PCI_VENDOR_ID_INTEL,
|
||||||
.instance_size = sizeof(UHCIState),
|
.device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
|
||||||
.class_init = piix3_uhci_class_init,
|
.revision = 0x01,
|
||||||
};
|
.unplug = true,
|
||||||
|
},{
|
||||||
static void piix4_uhci_class_init(ObjectClass *klass, void *data)
|
|
||||||
{
|
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
||||||
|
|
||||||
k->init = usb_uhci_common_initfn;
|
|
||||||
k->exit = usb_uhci_exit;
|
|
||||||
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
|
||||||
k->device_id = PCI_DEVICE_ID_INTEL_82371AB_2;
|
|
||||||
k->revision = 0x01;
|
|
||||||
k->class_id = PCI_CLASS_SERIAL_USB;
|
|
||||||
dc->vmsd = &vmstate_uhci;
|
|
||||||
dc->props = uhci_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TypeInfo piix4_uhci_info = {
|
|
||||||
.name = "piix4-usb-uhci",
|
.name = "piix4-usb-uhci",
|
||||||
.parent = TYPE_PCI_DEVICE,
|
.vendor_id = PCI_VENDOR_ID_INTEL,
|
||||||
.instance_size = sizeof(UHCIState),
|
.device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
|
||||||
.class_init = piix4_uhci_class_init,
|
.revision = 0x01,
|
||||||
};
|
.unplug = true,
|
||||||
|
},{
|
||||||
static void vt82c686b_uhci_class_init(ObjectClass *klass, void *data)
|
|
||||||
{
|
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
||||||
|
|
||||||
k->init = usb_uhci_vt82c686b_initfn;
|
|
||||||
k->exit = usb_uhci_exit;
|
|
||||||
k->vendor_id = PCI_VENDOR_ID_VIA;
|
|
||||||
k->device_id = PCI_DEVICE_ID_VIA_UHCI;
|
|
||||||
k->revision = 0x01;
|
|
||||||
k->class_id = PCI_CLASS_SERIAL_USB;
|
|
||||||
dc->vmsd = &vmstate_uhci;
|
|
||||||
dc->props = uhci_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TypeInfo vt82c686b_uhci_info = {
|
|
||||||
.name = "vt82c686b-usb-uhci",
|
.name = "vt82c686b-usb-uhci",
|
||||||
.parent = TYPE_PCI_DEVICE,
|
.vendor_id = PCI_VENDOR_ID_VIA,
|
||||||
.instance_size = sizeof(UHCIState),
|
.device_id = PCI_DEVICE_ID_VIA_UHCI,
|
||||||
.class_init = vt82c686b_uhci_class_init,
|
.revision = 0x01,
|
||||||
};
|
.initfn = usb_uhci_vt82c686b_initfn,
|
||||||
|
.unplug = true,
|
||||||
static void ich9_uhci1_class_init(ObjectClass *klass, void *data)
|
},{
|
||||||
{
|
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
||||||
|
|
||||||
k->init = usb_uhci_common_initfn;
|
|
||||||
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
|
||||||
k->device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1;
|
|
||||||
k->revision = 0x03;
|
|
||||||
k->class_id = PCI_CLASS_SERIAL_USB;
|
|
||||||
dc->vmsd = &vmstate_uhci;
|
|
||||||
dc->props = uhci_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TypeInfo ich9_uhci1_info = {
|
|
||||||
.name = "ich9-usb-uhci1",
|
.name = "ich9-usb-uhci1",
|
||||||
.parent = TYPE_PCI_DEVICE,
|
.vendor_id = PCI_VENDOR_ID_INTEL,
|
||||||
.instance_size = sizeof(UHCIState),
|
.device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1,
|
||||||
.class_init = ich9_uhci1_class_init,
|
.revision = 0x03,
|
||||||
};
|
.unplug = false,
|
||||||
|
},{
|
||||||
static void ich9_uhci2_class_init(ObjectClass *klass, void *data)
|
|
||||||
{
|
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
||||||
|
|
||||||
k->init = usb_uhci_common_initfn;
|
|
||||||
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
|
||||||
k->device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2;
|
|
||||||
k->revision = 0x03;
|
|
||||||
k->class_id = PCI_CLASS_SERIAL_USB;
|
|
||||||
dc->vmsd = &vmstate_uhci;
|
|
||||||
dc->props = uhci_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TypeInfo ich9_uhci2_info = {
|
|
||||||
.name = "ich9-usb-uhci2",
|
.name = "ich9-usb-uhci2",
|
||||||
.parent = TYPE_PCI_DEVICE,
|
.vendor_id = PCI_VENDOR_ID_INTEL,
|
||||||
.instance_size = sizeof(UHCIState),
|
.device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2,
|
||||||
.class_init = ich9_uhci2_class_init,
|
.revision = 0x03,
|
||||||
};
|
.unplug = false,
|
||||||
|
},{
|
||||||
static void ich9_uhci3_class_init(ObjectClass *klass, void *data)
|
|
||||||
{
|
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
||||||
|
|
||||||
k->init = usb_uhci_common_initfn;
|
|
||||||
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
|
||||||
k->device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3;
|
|
||||||
k->revision = 0x03;
|
|
||||||
k->class_id = PCI_CLASS_SERIAL_USB;
|
|
||||||
dc->vmsd = &vmstate_uhci;
|
|
||||||
dc->props = uhci_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TypeInfo ich9_uhci3_info = {
|
|
||||||
.name = "ich9-usb-uhci3",
|
.name = "ich9-usb-uhci3",
|
||||||
.parent = TYPE_PCI_DEVICE,
|
.vendor_id = PCI_VENDOR_ID_INTEL,
|
||||||
.instance_size = sizeof(UHCIState),
|
.device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3,
|
||||||
.class_init = ich9_uhci3_class_init,
|
.revision = 0x03,
|
||||||
|
.unplug = false,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void uhci_register_types(void)
|
static void uhci_register_types(void)
|
||||||
{
|
{
|
||||||
type_register_static(&piix3_uhci_info);
|
TypeInfo uhci_type_info = {
|
||||||
type_register_static(&piix4_uhci_info);
|
.parent = TYPE_PCI_DEVICE,
|
||||||
type_register_static(&vt82c686b_uhci_info);
|
.instance_size = sizeof(UHCIState),
|
||||||
type_register_static(&ich9_uhci1_info);
|
.class_init = uhci_class_init,
|
||||||
type_register_static(&ich9_uhci2_info);
|
};
|
||||||
type_register_static(&ich9_uhci3_info);
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(uhci_info); i++) {
|
||||||
|
uhci_type_info.name = uhci_info[i].name;
|
||||||
|
uhci_type_info.class_data = uhci_info + i;
|
||||||
|
type_register(&uhci_type_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type_init(uhci_register_types)
|
type_init(uhci_register_types)
|
||||||
|
Loading…
Reference in New Issue
Block a user