Revision 6cf9b6f1 hw/usb-uhci.c
b/hw/usb-uhci.c | ||
---|---|---|
1071 | 1071 |
register_ioport_read(addr, 32, 1, uhci_ioport_readb, s); |
1072 | 1072 |
} |
1073 | 1073 |
|
1074 |
void usb_uhci_piix3_init(PCIBus *bus, int devfn)
|
|
1074 |
static int usb_uhci_common_initfn(UHCIState *s)
|
|
1075 | 1075 |
{ |
1076 |
UHCIState *s; |
|
1077 |
uint8_t *pci_conf; |
|
1076 |
uint8_t *pci_conf = s->dev.config; |
|
1078 | 1077 |
int i; |
1079 | 1078 |
|
1080 |
s = (UHCIState *)pci_register_device(bus, |
|
1081 |
"USB-UHCI", sizeof(UHCIState), |
|
1082 |
devfn, NULL, NULL); |
|
1083 |
pci_conf = s->dev.config; |
|
1084 |
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); |
|
1085 |
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_2); |
|
1086 | 1079 |
pci_conf[0x08] = 0x01; // revision number |
1087 | 1080 |
pci_conf[0x09] = 0x00; |
1088 | 1081 |
pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB); |
... | ... | |
1090 | 1083 |
pci_conf[0x3d] = 4; // interrupt pin 3 |
1091 | 1084 |
pci_conf[0x60] = 0x10; // release number |
1092 | 1085 |
|
1093 |
s->bus = usb_bus_new(NULL /* FIXME */);
|
|
1086 |
s->bus = usb_bus_new(&s->dev.qdev);
|
|
1094 | 1087 |
for(i = 0; i < NB_PORTS; i++) { |
1095 | 1088 |
usb_register_port(s->bus, &s->ports[i].port, s, i, uhci_attach); |
1096 | 1089 |
} |
... | ... | |
1105 | 1098 |
PCI_ADDRESS_SPACE_IO, uhci_map); |
1106 | 1099 |
|
1107 | 1100 |
register_savevm("uhci", 0, 1, uhci_save, uhci_load, s); |
1101 |
return 0; |
|
1108 | 1102 |
} |
1109 | 1103 |
|
1110 |
void usb_uhci_piix4_init(PCIBus *bus, int devfn)
|
|
1104 |
static int usb_uhci_piix3_initfn(PCIDevice *dev)
|
|
1111 | 1105 |
{ |
1112 |
UHCIState *s; |
|
1113 |
uint8_t *pci_conf; |
|
1114 |
int i; |
|
1106 |
UHCIState *s = DO_UPCAST(UHCIState, dev, dev); |
|
1107 |
uint8_t *pci_conf = s->dev.config; |
|
1108 |
|
|
1109 |
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); |
|
1110 |
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_2); |
|
1111 |
return usb_uhci_common_initfn(s); |
|
1112 |
} |
|
1113 |
|
|
1114 |
static int usb_uhci_piix4_initfn(PCIDevice *dev) |
|
1115 |
{ |
|
1116 |
UHCIState *s = DO_UPCAST(UHCIState, dev, dev); |
|
1117 |
uint8_t *pci_conf = s->dev.config; |
|
1115 | 1118 |
|
1116 |
s = (UHCIState *)pci_register_device(bus, |
|
1117 |
"USB-UHCI", sizeof(UHCIState), |
|
1118 |
devfn, NULL, NULL); |
|
1119 |
pci_conf = s->dev.config; |
|
1120 | 1119 |
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); |
1121 | 1120 |
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_2); |
1122 |
pci_conf[0x08] = 0x01; // revision number |
|
1123 |
pci_conf[0x09] = 0x00; |
|
1124 |
pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB); |
|
1125 |
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type |
|
1126 |
pci_conf[0x3d] = 4; // interrupt pin 3 |
|
1127 |
pci_conf[0x60] = 0x10; // release number |
|
1121 |
return usb_uhci_common_initfn(s); |
|
1122 |
} |
|
1128 | 1123 |
|
1129 |
s->bus = usb_bus_new(NULL /* FIXME */); |
|
1130 |
for(i = 0; i < NB_PORTS; i++) { |
|
1131 |
usb_register_port(s->bus, &s->ports[i].port, s, i, uhci_attach); |
|
1124 |
static PCIDeviceInfo uhci_info[] = { |
|
1125 |
{ |
|
1126 |
.qdev.name = "PIIX3 USB-UHCI", |
|
1127 |
.qdev.size = sizeof(UHCIState), |
|
1128 |
.init = usb_uhci_piix3_initfn, |
|
1129 |
},{ |
|
1130 |
.qdev.name = "PIIX4 USB-UHCI", |
|
1131 |
.qdev.size = sizeof(UHCIState), |
|
1132 |
.init = usb_uhci_piix4_initfn, |
|
1133 |
},{ |
|
1134 |
/* end of list */ |
|
1132 | 1135 |
} |
1133 |
s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
|
|
1136 |
};
|
|
1134 | 1137 |
|
1135 |
qemu_register_reset(uhci_reset, s); |
|
1136 |
uhci_reset(s); |
|
1138 |
static void uhci_register(void) |
|
1139 |
{ |
|
1140 |
pci_qdev_register_many(uhci_info); |
|
1141 |
} |
|
1142 |
device_init(uhci_register); |
|
1137 | 1143 |
|
1138 |
/* Use region 4 for consistency with real hardware. BSD guests seem
|
|
1139 |
to rely on this. */
|
|
1140 |
pci_register_bar(&s->dev, 4, 0x20,
|
|
1141 |
PCI_ADDRESS_SPACE_IO, uhci_map);
|
|
1144 |
void usb_uhci_piix3_init(PCIBus *bus, int devfn)
|
|
1145 |
{
|
|
1146 |
pci_create_simple(bus, devfn, "PIIX3 USB-UHCI");
|
|
1147 |
}
|
|
1142 | 1148 |
|
1143 |
register_savevm("uhci", 0, 1, uhci_save, uhci_load, s); |
|
1149 |
void usb_uhci_piix4_init(PCIBus *bus, int devfn) |
|
1150 |
{ |
|
1151 |
pci_create_simple(bus, devfn, "PIIX4 USB-UHCI"); |
|
1144 | 1152 |
} |
Also available in: Unified diff