mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
qdev/usb: add usb bus support to qdev, convert drivers.
* Add USBBus. * Add USBDeviceInfo, move device callbacks here. * Add usb-qdev helper functions. * Switch drivers to qdev. TODO: * make the rest of qemu aware of usb busses and kill the FIXMEs added by this patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
7557008854
commit
806b602482
17 changed files with 428 additions and 197 deletions
45
hw/usb-net.c
45
hw/usb-net.c
|
@ -1432,32 +1432,34 @@ static void usb_net_handle_destroy(USBDevice *dev)
|
|||
qemu_del_vlan_client(s->vc);
|
||||
}
|
||||
|
||||
USBDevice *usb_net_init(NICInfo *nd)
|
||||
static int usb_net_initfn(USBDevice *dev)
|
||||
{
|
||||
USBNetState *s;
|
||||
USBNetState *s = DO_UPCAST(USBNetState, dev, dev);
|
||||
|
||||
s = qemu_mallocz(sizeof(USBNetState));
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = usb_generic_handle_packet;
|
||||
|
||||
s->dev.handle_reset = usb_net_handle_reset;
|
||||
s->dev.handle_control = usb_net_handle_control;
|
||||
s->dev.handle_data = usb_net_handle_data;
|
||||
s->dev.handle_destroy = usb_net_handle_destroy;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
|
||||
s->rndis = 1;
|
||||
s->rndis_state = RNDIS_UNINITIALIZED;
|
||||
TAILQ_INIT(&s->rndis_resp);
|
||||
|
||||
s->medium = 0; /* NDIS_MEDIUM_802_3 */
|
||||
s->speed = 1000000; /* 100MBps, in 100Bps units */
|
||||
s->media_state = 0; /* NDIS_MEDIA_STATE_CONNECTED */;
|
||||
s->filter = 0;
|
||||
s->vendorid = 0x1234;
|
||||
return 0;
|
||||
}
|
||||
|
||||
USBDevice *usb_net_init(NICInfo *nd)
|
||||
{
|
||||
USBDevice *dev;
|
||||
USBNetState *s;
|
||||
|
||||
dev = usb_create_simple(NULL /* FIXME */, "QEMU USB Network Interface");
|
||||
s = DO_UPCAST(USBNetState, dev, dev);
|
||||
|
||||
memcpy(s->mac, nd->macaddr, 6);
|
||||
TAILQ_INIT(&s->rndis_resp);
|
||||
|
||||
pstrcpy(s->dev.devname, sizeof(s->dev.devname),
|
||||
"QEMU USB Network Interface");
|
||||
s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
|
||||
usbnet_can_receive,
|
||||
usbnet_receive,
|
||||
|
@ -1476,3 +1478,20 @@ USBDevice *usb_net_init(NICInfo *nd)
|
|||
|
||||
return (USBDevice *) s;
|
||||
}
|
||||
|
||||
static struct USBDeviceInfo net_info = {
|
||||
.qdev.name = "QEMU USB Network Interface",
|
||||
.qdev.size = sizeof(USBNetState),
|
||||
.init = usb_net_initfn,
|
||||
.handle_packet = usb_generic_handle_packet,
|
||||
.handle_reset = usb_net_handle_reset,
|
||||
.handle_control = usb_net_handle_control,
|
||||
.handle_data = usb_net_handle_data,
|
||||
.handle_destroy = usb_net_handle_destroy,
|
||||
};
|
||||
|
||||
static void usb_net_register_devices(void)
|
||||
{
|
||||
usb_qdev_register(&net_info);
|
||||
}
|
||||
device_init(usb_net_register_devices)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue