mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-06 01:33:34 +00:00
switch usb bus to inplace allocation.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
ca9c39faed
commit
b2317837f0
@ -14,16 +14,13 @@ static struct BusInfo usb_bus_info = {
|
|||||||
static int next_usb_bus = 0;
|
static int next_usb_bus = 0;
|
||||||
static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
|
static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
|
||||||
|
|
||||||
USBBus *usb_bus_new(DeviceState *host)
|
void usb_bus_new(USBBus *bus, DeviceState *host)
|
||||||
{
|
{
|
||||||
USBBus *bus;
|
qbus_create_inplace(&bus->qbus, &usb_bus_info, host, NULL);
|
||||||
|
|
||||||
bus = FROM_QBUS(USBBus, qbus_create(&usb_bus_info, host, NULL));
|
|
||||||
bus->busnr = next_usb_bus++;
|
bus->busnr = next_usb_bus++;
|
||||||
QTAILQ_INIT(&bus->free);
|
QTAILQ_INIT(&bus->free);
|
||||||
QTAILQ_INIT(&bus->used);
|
QTAILQ_INIT(&bus->used);
|
||||||
QTAILQ_INSERT_TAIL(&busses, bus, next);
|
QTAILQ_INSERT_TAIL(&busses, bus, next);
|
||||||
return bus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
USBBus *usb_bus_find(int busnr)
|
USBBus *usb_bus_find(int busnr)
|
||||||
|
@ -281,7 +281,7 @@ typedef struct {
|
|||||||
|
|
||||||
struct MUSBState {
|
struct MUSBState {
|
||||||
qemu_irq *irqs;
|
qemu_irq *irqs;
|
||||||
USBBus *bus;
|
USBBus bus;
|
||||||
USBPort port;
|
USBPort port;
|
||||||
|
|
||||||
int idx;
|
int idx;
|
||||||
@ -331,8 +331,8 @@ struct MUSBState {
|
|||||||
s->ep[i].epnum = i;
|
s->ep[i].epnum = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->bus = usb_bus_new(NULL /* FIXME */);
|
usb_bus_new(&s->bus, NULL /* FIXME */);
|
||||||
usb_register_port(s->bus, &s->port, s, 0, musb_attach);
|
usb_register_port(&s->bus, &s->port, s, 0, musb_attach);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ enum ohci_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
USBBus *bus;
|
USBBus bus;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
enum ohci_type type;
|
enum ohci_type type;
|
||||||
int mem;
|
int mem;
|
||||||
@ -1690,10 +1690,10 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
|
|||||||
ohci->irq = irq;
|
ohci->irq = irq;
|
||||||
ohci->type = type;
|
ohci->type = type;
|
||||||
|
|
||||||
ohci->bus = usb_bus_new(dev);
|
usb_bus_new(&ohci->bus, dev);
|
||||||
ohci->num_ports = num_ports;
|
ohci->num_ports = num_ports;
|
||||||
for (i = 0; i < num_ports; i++) {
|
for (i = 0; i < num_ports; i++) {
|
||||||
usb_register_port(ohci->bus, &ohci->rhport[i].port, ohci, i, ohci_attach);
|
usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, ohci_attach);
|
||||||
}
|
}
|
||||||
|
|
||||||
ohci->async_td = 0;
|
ohci->async_td = 0;
|
||||||
|
@ -122,7 +122,7 @@ typedef struct UHCIPort {
|
|||||||
|
|
||||||
typedef struct UHCIState {
|
typedef struct UHCIState {
|
||||||
PCIDevice dev;
|
PCIDevice dev;
|
||||||
USBBus *bus;
|
USBBus bus;
|
||||||
uint16_t cmd; /* cmd register */
|
uint16_t cmd; /* cmd register */
|
||||||
uint16_t status;
|
uint16_t status;
|
||||||
uint16_t intr; /* interrupt enable register */
|
uint16_t intr; /* interrupt enable register */
|
||||||
@ -1083,9 +1083,9 @@ static int usb_uhci_common_initfn(UHCIState *s)
|
|||||||
pci_conf[0x3d] = 4; // interrupt pin 3
|
pci_conf[0x3d] = 4; // interrupt pin 3
|
||||||
pci_conf[0x60] = 0x10; // release number
|
pci_conf[0x60] = 0x10; // release number
|
||||||
|
|
||||||
s->bus = usb_bus_new(&s->dev.qdev);
|
usb_bus_new(&s->bus, &s->dev.qdev);
|
||||||
for(i = 0; i < NB_PORTS; i++) {
|
for(i = 0; i < NB_PORTS; i++) {
|
||||||
usb_register_port(s->bus, &s->ports[i].port, s, i, uhci_attach);
|
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);
|
s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
|
||||||
|
|
||||||
|
2
hw/usb.h
2
hw/usb.h
@ -303,7 +303,7 @@ struct USBBus {
|
|||||||
QTAILQ_ENTRY(USBBus) next;
|
QTAILQ_ENTRY(USBBus) next;
|
||||||
};
|
};
|
||||||
|
|
||||||
USBBus *usb_bus_new(DeviceState *host);
|
void usb_bus_new(USBBus *bus, DeviceState *host);
|
||||||
USBBus *usb_bus_find(int busnr);
|
USBBus *usb_bus_find(int busnr);
|
||||||
void usb_qdev_register(USBDeviceInfo *info);
|
void usb_qdev_register(USBDeviceInfo *info);
|
||||||
void usb_qdev_register_many(USBDeviceInfo *info);
|
void usb_qdev_register_many(USBDeviceInfo *info);
|
||||||
|
Loading…
Reference in New Issue
Block a user