mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
OHCI USB host emulation.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1928 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
6650ee6d33
commit
0d92ed3022
11 changed files with 1306 additions and 84 deletions
4
hw/pc.c
4
hw/pc.c
|
@ -40,7 +40,6 @@ static fdctrl_t *floppy_controller;
|
|||
static RTCState *rtc_state;
|
||||
static PITState *pit;
|
||||
static IOAPICState *ioapic;
|
||||
static USBPort *usb_root_ports[2];
|
||||
|
||||
static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
|
||||
{
|
||||
|
@ -833,8 +832,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
|
|||
cmos_init(ram_size, boot_device, bs_table);
|
||||
|
||||
if (pci_enabled && usb_enabled) {
|
||||
usb_uhci_init(pci_bus, usb_root_ports, piix3_devfn + 2);
|
||||
usb_attach(usb_root_ports[0], vm_usb_hub);
|
||||
usb_uhci_init(pci_bus, piix3_devfn + 2);
|
||||
}
|
||||
|
||||
if (pci_enabled && acpi_enabled) {
|
||||
|
|
|
@ -506,7 +506,11 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
|
||||
arch_name = "MAC99";
|
||||
}
|
||||
|
||||
|
||||
if (usb_enabled) {
|
||||
usb_ohci_init(pci_bus, 3, -1);
|
||||
}
|
||||
|
||||
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
|
||||
graphic_depth = 15;
|
||||
|
||||
|
|
|
@ -665,6 +665,10 @@ static void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
cpu_register_physical_memory(0xFEFF0000, 0x1000, PPC_io_memory);
|
||||
#endif
|
||||
|
||||
if (usb_enabled) {
|
||||
usb_ohci_init(pci_bus, 3, -1);
|
||||
}
|
||||
|
||||
nvram = m48t59_init(8, 0, 0x0074, NVRAM_SIZE, 59);
|
||||
if (nvram == NULL)
|
||||
return;
|
||||
|
|
13
hw/usb-hub.c
13
hw/usb-hub.c
|
@ -179,6 +179,9 @@ static void usb_hub_attach(USBPort *port1, USBDevice *dev)
|
|||
else
|
||||
port->wPortStatus &= ~PORT_STAT_LOW_SPEED;
|
||||
port->port.dev = dev;
|
||||
/* send the attach message */
|
||||
dev->handle_packet(dev,
|
||||
USB_MSG_ATTACH, 0, 0, NULL, 0);
|
||||
} else {
|
||||
dev = port->port.dev;
|
||||
if (dev) {
|
||||
|
@ -188,6 +191,9 @@ static void usb_hub_attach(USBPort *port1, USBDevice *dev)
|
|||
port->wPortStatus &= ~PORT_STAT_ENABLE;
|
||||
port->wPortChange |= PORT_STAT_C_ENABLE;
|
||||
}
|
||||
/* send the detach message */
|
||||
dev->handle_packet(dev,
|
||||
USB_MSG_DETACH, 0, 0, NULL, 0);
|
||||
port->port.dev = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +523,7 @@ static int usb_hub_handle_packet(USBDevice *dev, int pid,
|
|||
return usb_generic_handle_packet(dev, pid, devaddr, devep, data, len);
|
||||
}
|
||||
|
||||
USBDevice *usb_hub_init(USBPort **usb_ports, int nb_ports)
|
||||
USBDevice *usb_hub_init(int nb_ports)
|
||||
{
|
||||
USBHubState *s;
|
||||
USBHubPort *port;
|
||||
|
@ -539,12 +545,9 @@ USBDevice *usb_hub_init(USBPort **usb_ports, int nb_ports)
|
|||
s->nb_ports = nb_ports;
|
||||
for(i = 0; i < s->nb_ports; i++) {
|
||||
port = &s->ports[i];
|
||||
qemu_register_usb_port(&port->port, s, i, usb_hub_attach);
|
||||
port->wPortStatus = PORT_STAT_POWER;
|
||||
port->wPortChange = 0;
|
||||
port->port.attach = usb_hub_attach;
|
||||
port->port.opaque = s;
|
||||
port->port.index = i;
|
||||
usb_ports[i] = &port->port;
|
||||
}
|
||||
return (USBDevice *)s;
|
||||
}
|
||||
|
|
1179
hw/usb-ohci.c
Normal file
1179
hw/usb-ohci.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -638,11 +638,10 @@ static void uhci_map(PCIDevice *pci_dev, int region_num,
|
|||
register_ioport_read(addr, 32, 1, uhci_ioport_readb, s);
|
||||
}
|
||||
|
||||
void usb_uhci_init(PCIBus *bus, USBPort **usb_ports, int devfn)
|
||||
void usb_uhci_init(PCIBus *bus, int devfn)
|
||||
{
|
||||
UHCIState *s;
|
||||
uint8_t *pci_conf;
|
||||
UHCIPort *port;
|
||||
int i;
|
||||
|
||||
s = (UHCIState *)pci_register_device(bus,
|
||||
|
@ -662,11 +661,7 @@ void usb_uhci_init(PCIBus *bus, USBPort **usb_ports, int devfn)
|
|||
pci_conf[0x60] = 0x10; // release number
|
||||
|
||||
for(i = 0; i < NB_PORTS; i++) {
|
||||
port = &s->ports[i];
|
||||
port->port.opaque = s;
|
||||
port->port.index = i;
|
||||
port->port.attach = uhci_attach;
|
||||
usb_ports[i] = &port->port;
|
||||
qemu_register_usb_port(&s->ports[i].port, s, i, uhci_attach);
|
||||
}
|
||||
s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
|
||||
|
||||
|
|
12
hw/usb.h
12
hw/usb.h
|
@ -137,12 +137,15 @@ struct USBDevice {
|
|||
int setup_index;
|
||||
};
|
||||
|
||||
typedef void (*usb_attachfn)(USBPort *port, USBDevice *dev);
|
||||
|
||||
/* USB port on which a device can be connected */
|
||||
struct USBPort {
|
||||
USBDevice *dev;
|
||||
void (*attach)(USBPort *port, USBDevice *dev);
|
||||
usb_attachfn attach;
|
||||
void *opaque;
|
||||
int index; /* internal port index, may be used with the opaque */
|
||||
struct USBPort *next; /* Used internally by qemu. */
|
||||
};
|
||||
|
||||
void usb_attach(USBPort *port, USBDevice *dev);
|
||||
|
@ -152,10 +155,13 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
|
|||
int set_usb_string(uint8_t *buf, const char *str);
|
||||
|
||||
/* usb hub */
|
||||
USBDevice *usb_hub_init(USBPort **usb_ports, int nb_ports);
|
||||
USBDevice *usb_hub_init(int nb_ports);
|
||||
|
||||
/* usb-uhci.c */
|
||||
void usb_uhci_init(PCIBus *bus, USBPort **usb_ports, int devfn);
|
||||
void usb_uhci_init(PCIBus *bus, int devfn);
|
||||
|
||||
/* usb-ohci.c */
|
||||
void usb_ohci_init(struct PCIBus *bus, int num_ports, int devfn);
|
||||
|
||||
/* usb-linux.c */
|
||||
USBDevice *usb_host_device_open(const char *devname);
|
||||
|
|
|
@ -374,6 +374,9 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
|
|||
pci_nic_init(pci_bus, nd);
|
||||
}
|
||||
}
|
||||
if (usb_enabled) {
|
||||
usb_ohci_init(pci_bus, 3, -1);
|
||||
}
|
||||
|
||||
pl011_init(0x101f1000, pic, 12, serial_hds[0]);
|
||||
pl011_init(0x101f2000, pic, 13, serial_hds[1]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue