aboutsummaryrefslogtreecommitdiffstats
path: root/hw/usb-desc.c
AgeCommit message (Collapse)AuthorFilesLines
2012-02-27usb-desc: fix user trigerrable segfaults (!config)Alon Levy1-3/+17
Check for dev->config being NULL in two places: USB_REQ_GET_CONFIGURATION and USB_REQ_GET_STATUS. The behavior of USB_REQ_GET_STATUS is unspecified in the Default state, that corresponds to dev->config being NULL (it defaults to NULL and is reset whenever a SET_CONFIGURATION with value 0, or attachment). I implemented it to correspond with the state before ed5a83ddd8c1d8ec7b1015315530cf29949e7c48, the commit moving SET_STATUS to usb-desc; if dev->config is not set we return whatever is in the first configuration. The behavior of USB_REQ_GET_CONFIGURATION is also undefined before any SET_CONFIGURATION, but here we just return 0 (same as specified for the Address state). A win7 guest failed to initialize the device before this patch, segfaulting when GET_STATUS was called with dev->config == NULL. With this patch the passthrough device still doesn't work but the failure is unrelated. Signed-off-by: Alon Levy <alevy@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-27usb: convert to QEMU Object ModelAnthony Liguori1-11/+11
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-17usb: add max_packet_size to USBEndpointGerd Hoffmann1-0/+2
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17usb-desc: USBEndpoint supportGerd Hoffmann1-0/+22
Initialize USBEndpoint structs from USBDesc* data. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13usb-desc: audio endpoint supportGerd Hoffmann1-3/+11
Add support for audio endpoints which have two more fields in the descriptor. Also add support for extra class specific endpoint descriptors. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13usb: track altsetting in USBDeviceGerd Hoffmann1-0/+71
Also handle {GET,SET}_INTERFACE in common code (usb-desc.c). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13usb: track configuration and interface count in USBDevice.Gerd Hoffmann1-8/+26
Move fields from USBHostDevice to USBDevice. Add bits to usb-desc.c to fill them for emulated devices too. Also allow to set configuration 0 (== None) for emulated devices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-3/+3
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-06-23usb: ignore USB_DT_DEBUGGerd Hoffmann1-0/+4
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23usb: Add a speedmask to devicesHans de Goede1-0/+10
This is used to indicate at which speed[s] the device can operate, so that this can be checked to match the ports capabilities when it gets attached to a bus. Note that currently all usb1 emulated device claim to be fullspeed, this seems to not cause any problems, but still seems wrong, because with real hardware keyboards, mice and tablets usually are lo-speed, so reporting these as fullspeed devices seems wrong. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb: Pass the packet to the device's handle_control callbackHans de Goede1-2/+2
This allows using the generic usb_generic_handle_packet function from device code which does ASYNC control requests (such as the linux host pass through code). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-05-26usb: add support for "grouped" interfaces and the Interface Association ↵Brad Hards1-0/+47
Descriptor This is used for some devices that have multiple interfaces that form a logic device. An example is Video Class, which has a Control interface and a Streaming interface. There can be additional interfaces on the same (physical) devices (e.g. a microphone), and Interface Association Descriptor handles this case. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26usb: remove fallback to bNumInterfaces if no .nifBrad Hards1-3/+2
All callers have been updated. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add device qualifier supportGerd Hoffmann1-0/+46
Add support for device_qualifier and other_speed_config descriptors. These are used to query the "other speed" configuration of usb 2.0 devices, i.e. in high-speed mode they return the full-speed configuration and visa versa. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: add usb_desc_attachGerd Hoffmann1-3/+33
Add usb_desc_attach() which sets up the device according to the speed the usb port is able to handle. This function can be hooked into the handle_attach callback. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: move remote wakeup handling to common codeGerd Hoffmann1-0/+26
This patch moves setting and clearing the remote_wakeup feature bit (via USB_REQ_{SET,CLEAR}_FEATURE) to common code. Also USB_REQ_GET_STATUS handling is moved to common code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common codeGerd Hoffmann1-4/+28
This patch adds fields to the USBDevice struct for the current speed (hard-wired to full speed for now) and current device configuration. Also a init function is added which inializes these fields. This allows USB_REQ_{GET,SET}_CONFIGURATION handling to be moved to common code. For most drivers the conversion is trivial ad they support a single configuration only anyway. One exception is bluetooth where some device-specific setup code runs after get/set configuration. The other is usb-net which actually has two configurations so the the code to check for the active configuration has been adapted. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: move USB_REQ_SET_ADDRESS handling to common codeGerd Hoffmann1-0/+6
USB_REQ_SET_ADDRESS handling is identical in *all* emulated devices. Move it to common code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb descriptors: add settable strings.Gerd Hoffmann1-8/+44
This patch allows to set usb descriptor strings per device instance. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11usb: data structs and helpers for usb descriptors.Gerd Hoffmann1-0/+238
This patch adds hw/usb-desc.[ch] files. They carry data structures for various usb descriptors and helper functions to generate usb packets from the structures. The intention is to have a internal representation of the device desription which is more usable than the current char array blobs, so we can have common code handle common usb device emulation using the device description. The usage of this infrastructure is optional for usb drivers as there are cases such as pass-through where it probably isn't very useful. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>