sim-card
/
qemu
Archived
10
0
Fork 0
Commit Graph

104 Commits

Author SHA1 Message Date
Gerd Hoffmann 079d0b7f1e usb: Set USBEndpoint in usb_packet_setup().
With the separation of the device lookup (via usb_find_device) and
packet processing we can lookup device and endpoint before setting up
the usb packet.  So we can initialize USBPacket->ep early and keep it
valid for the whole lifecycle of the USBPacket.  Also the devaddr and
devep fields are not needed any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:31:57 +01:00
Gerd Hoffmann 63095ab54c usb: add USBEndpoint->{nr,pid}
Add a "nr" and "pid" fields to USBEndpoint so you can easily figure the
endpoint number and direction of any given endpoint.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:31:57 +01:00
Gerd Hoffmann f53c398aa6 usb: USBPacket: add status, rename owner -> ep
Add enum to track the status of USBPackets, use that instead of the
owner pointer to figure whenever a usb packet is currently in flight
or not.  Add some more packet status sanity checks.  Also rename the
USBEndpoint pointer from "owner" to "ep".

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:31:57 +01:00
Gerd Hoffmann 7f74a56b14 usb: kill handle_packet callback
All drivers except usb-hub use usb_generic_handle_packet.  The only
reason the usb hub has its own function is that it used to be called
with packets which are intended for downstream devices.  With the new,
separate device lookup step this doesn't happen any more, so the need
for a different handle_packet callback is gone.

So we can kill the handle_packet callback and just call
usb_generic_handle_packet directly.  The special hub handling in
usb_handle_packet() can go away for the same reason.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:31:57 +01:00
Gerd Hoffmann 73796fe622 usb: add usb_find_device()
Add usb_find_device().  This function will check whenever a device with
a specific address is connected to the specified port.  Usually this
will just check state and address of the device hooked up to the port,
but in case of a hub it will ask the hub to check all hub ports for a
matching device.

This patch doesn't put the code into use yet, see the following patches
for details.

The master plan is to separate device lookup and packet processing.
Right now the usb code simply walks all devices, calls
usb_handle_packet() on each until one accepts the packet (by returning
something different that USB_RET_NODEV).  I want to have a device lookup
first, then call usb_handle_packet() once, for the device which actually
processes the packet.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:31:48 +01:00
Gerd Hoffmann 70fc20d4dc usb: kill usb_send_msg
No users left.  Zap it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:12:04 +01:00
Gerd Hoffmann d28f4e2d86 usb: kill USB_MSG_RESET
The USB subsystem pipes internal reset notifications through
usb_handle_packet() with a special magic PID.  This indirection
is a pretty pointless excercise as it ends up being handled by
usb_generic_handle_packet anyway.

Replace the USB_MSG_RESET with a usb_device_reset() function
which can be called directly.  Also rename the existing usb_reset()
function to usb_port_reset() to avoid confusion.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:12:04 +01:00
Gerd Hoffmann d1f8b53618 usb: kill USB_MSG_{ATTACH,DETACH}
The USB subsystem pipes internal attach/detach notifications through
usb_handle_packet() with a special magic PID.  This indirection is a
pretty pointless excercise as it ends up being handled by
usb_generic_handle_packet anyway.  Remove it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-10 11:12:04 +01:00
Anthony Liguori 39bffca203 qdev: register all types natively through QEMU Object Model
This was done in a mostly automated fashion.  I did it in three steps and then
rebased it into a single step which avoids repeatedly touching every file in
the tree.

The first step was a sed-based addition of the parent type to the subclass
registration functions.

The second step was another sed-based removal of subclass registration functions
while also adding virtual functions from the base class into a class_init
function as appropriate.

Finally, a python script was used to convert the DeviceInfo structures and
qdev_register_subclass functions to TypeInfo structures, class_init functions,
and type_register_static calls.

We are almost fully converted to QOM after this commit.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-03 10:41:06 -06:00
Anthony Liguori ba02430f1a usb: separate out legacy usb registration from type registration
Type registeration is going to get turned into a QOM call so decouple the
legacy support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-03 10:41:03 -06:00
Anthony Liguori 62aed76583 usb: convert to QEMU Object Model
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27 10:50:47 -06:00
Anthony Liguori 9ca2140ab1 Merge remote-tracking branch 'kraxel/usb.37' into staging
* kraxel/usb.37:
  usb-redir: Improve some debugging messages
  usb-redir: Try to keep our buffer size near the target size
  usb-redir: Pre-fill our isoc input buffer before sending pkts to the host
  usb-redir: Dynamically adjust iso buffering size based on ep interval
  usb-redir: Clear iso / irq error when stopping the stream
  usb: link packets to endpoints not devices
  usb: add max_packet_size to USBEndpoint
  usb/debug: add usb_ep_dump
  usb-desc: USBEndpoint support
  usb: add ifnum to USBEndpoint
  usb: add USBEndpoint
  xhci: Initial xHCI implementation
  usb: add audio device model
  usb-desc: audio endpoint support
  usb: track altsetting in USBDevice
  usb: track configuration and interface count in USBDevice.
  usb-host: rip out legacy procfs support
2012-01-19 08:34:38 -06:00
Gerd Hoffmann 25d5de7d81 usb: link packets to endpoints not devices
Add USBEndpoint for the control endpoint to USBDevices.  Link async
packets to the USBEndpoint instead of the USBDevice.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17 09:44:50 +01:00
Gerd Hoffmann f003397ce9 usb: add max_packet_size to USBEndpoint
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17 09:44:50 +01:00
Gerd Hoffmann 5b6780d045 usb/debug: add usb_ep_dump
Add function to dump endpoint data, for debugging purposes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17 09:44:50 +01:00
Gerd Hoffmann 82f02fe965 usb: add ifnum to USBEndpoint
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17 09:44:50 +01:00
Gerd Hoffmann d8e17efdec usb: add USBEndpoint
Start maintaining endpoint state at USBDevice level.  Add USBEndpoint
struct and some helper functions to deal with it.  For now it contains
the endpoint type only.  Moved over some bits from usb-linux.c

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-17 09:44:50 +01:00
Paolo Bonzini 701a8f76aa vmstate: extract declarations out of hw/hw.h
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-13 10:20:51 -06:00
H. Peter Anvin b870472db5 usb: add audio device model
This brings a usb audio device to qemu.  Output only, fixed at
16bit stereo @ 480000 Hz.  Based on a patch from
H. Peter Anvin <hpa@linux.intel.com>

Usage: add '-device usb-audio' to your qemu command line.

Works sorta ok on a idle machine.  Known issues:

 * Is *very* sensitive to latencies.
 * Burns quite some CPU due to usb polling.

In short:  It brings the qemu usb emulation to its limits.  Enjoy!

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13 10:25:44 +01:00
Gerd Hoffmann 1de14d43e2 usb: track altsetting in USBDevice
Also handle {GET,SET}_INTERFACE in common code (usb-desc.c).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-01-13 10:25:44 +01:00
Gerd Hoffmann 65360511a2 usb: track configuration and interface count in USBDevice.
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>
2012-01-13 10:25:44 +01:00
Gerd Hoffmann e0b8e72dd9 usb: fix port reset
commit 891fb2cd45 removed the implicit
detach before (re-)attaching in usb_attach().  Some usb host controllers
used that behavior though to do a port reset by a detach+attach
sequence.

This patch establishes old behavior by adding a new usb_reset() function
for port resets and putting it into use, thereby also unifying port
reset behavior of all host controllers.  The patch also adds asserts to
usb_attach() and usb_detach() to make sure the calls are symmetrical.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-10-13 12:58:51 +02:00
Juha Riihimäki 5b1cdb4ead usb-musb: Add reset function
Add a separate reset function musb_reset() to the usb-musb interface,
so that users who implement a reset function can also reset usb-musb.
Use this in tusb6010.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:27 +02:00
Peter Maydell 406c20754a usb-musb: Take a DeviceState* in init function
Initialise usb-musb by passing it a DeviceState* and the offset of the
IRQs in its gpio array, rather than a plain pointer to an irq array.
This is simpler for callers and also allows us to pass in a valid parent
to usb_bus_new(), so the USB bus actually appears in the qdev tree.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:27 +02:00
Peter Maydell 9147b75288 usb: Remove leading underscores from __musb_irq_max
Identifiers with double leading underscore are reserved, so rename
__musb_irq_max so we don't encroach on reserved namespace.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:27 +02:00
Gerd Hoffmann 891fb2cd45 usb: claim port at device initialization time.
This patch makes qemu assign a port when creating the device, not when
attaching it.  For most usb devices this isn't a noticable difference
because they are in attached state all the time.

The change affects usb-host devices which live in detached state while
the real device is unplugged from the host.  They have a fixed port
assigned all the time now instead of getting grabbing one on attach and
releasing it at detach, i.e. they stop floating around at the usb bus.

The change also allows to simplify usb-hub.  It doesn't need the
handle_attach() callback any more to configure the downstream ports.
This can be done at device initialitation time now.  The changed
initialization order (first grab upstream port, then register downstream
ports) also fixes some icky corner cases.  For example it is not possible
any more to plug the hub into one of its own downstream ports.

The usb host adapters must care too.  USBPort->dev being non-NULL
doesn't imply any more the device is in attached state.  The host
adapters must additionally check the USBPort->dev->attached flag.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:26 +02:00
Gerd Hoffmann f3aaaa242e usb-hid: remove usb_hid_datain_cb
No users left, all migrated over to hw/hid.[ch].
Yea!  Zap it!

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-10 14:14:00 +02:00
Gerd Hoffmann 4f4321c11f usb: use iovecs in USBPacket
Zap data pointer from USBPacket, add a QEMUIOVector instead.
Add a bunch of helper functions to manage USBPacket data.
Switch over users to the new interface.

Note that USBPacket->len was used for two purposes:  First to
pass in the buffer size and second to return the number of
transfered bytes or the status code on async transfers.  There
is a new result variable for the latter.  A new status code
was added to catch uninitialized result.

Nobody creates iovecs with more than one element (yet).
Some users are (temporarely) limited to iovecs with a single
element to keep the patch size as small as possible.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-04 15:51:22 +02:00
Hans de Goede 4706ab6cc0 usb: Replace device_destroy bus op with a child_detach port op
Note this fixes 2 things in one go, first of all the device_destroy bus
op should be a device_detach bus op, as pending async packets from the
device should be cancelled on detach not on destroy.

Secondly having this as a bus op won't work with companion controllers, since
then there will be 1 bus driven by the ehci controller and thus 1 set of bus
ops, but the device being detached may be downstream of a handed over port.
Making the detach of a downstream device a port op allows the ehci controller
to forward this to the companion controller port for handed over ports.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05 15:09:02 +02:00
Hans de Goede d47e59b8b8 usb: Make port wakeup and complete ops take a USBPort instead of a Device
This makes them consistent with the attach and detach ops, and in general
it makes sense to make portops take a port as argument. This also makes
adding support for a companion controller easier / cleaner.

[ kraxel: fix usb-musb.c build ]

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05 15:09:02 +02:00
Hans de Goede ae60fea97c usb: Add a register_companion USB bus op.
This is a preparation patch for adding support for USB companion controllers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-05 15:09:02 +02:00
Gerd Hoffmann a7fb71d1b2 usb: ignore USB_DT_DEBUG
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-23 17:15:55 +02:00
Hans de Goede ba3f9bfba9 usb: Add a speedmask to devices
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-06-23 11:28:06 +02:00
Brad Hards 8e257816b0 usb: Add defines for USB Serial Bus Release Number register
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:50 +02:00
Gerd Hoffmann 07771f6fce usb: cancel async packets on unplug
This patch adds USBBusOps struct with (for now) only a single callback
which is called when a device is about to be destroyed.  The USB Host
adapters are implementing this callback and use it to cancel any async
requests which might be in flight before the device actually goes away.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann eb5e680ae5 usb: move cancel callback to USBDeviceInfo
Remove the cancel callback from the USBPacket struct, move it over
to USBDeviceInfo.  Zap usb_defer_packet() which is obsolete now.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26 11:55:03 +02:00
Gerd Hoffmann 4ff658fb6c usb: keep track of packet owner.
Keep track of the device which owns the usb packet for async processing.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26 11:55:03 +02:00
Gerd Hoffmann 53aa8c0e2a usb: add usb_handle_packet
Add a usb_handle_packet function, put it into use everywhere.
Right now it just calls dev->info->handle_packet(), that will
change in future patches though.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26 11:55:03 +02:00
Hans de Goede 50b7963e72 usb-linux: use usb_generic_handle_packet()
Make the linux usb host passthrough code use the usb_generic_handle_packet()
function, rather then the curent DYI code. This removes 200 lines of almost
identical code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-05-26 11:55:02 +02:00
Hans de Goede 007fd62f4d usb: Pass the packet to the device's handle_control callback
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-26 11:55:02 +02:00
Brad Hards 6e625fc704 usb: add support for "grouped" interfaces and the Interface Association 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-26 11:55:02 +02:00
Brad Hards c6d3ad0fad usb: Add Interface Association Descriptor descriptor type
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-05-26 11:55:02 +02:00
Gerd Hoffmann 13a9a0d3e2 usb: move complete callback to port ops 2011-05-04 14:11:08 +02:00
Hans de Goede 19f3322379 usb: control buffer fixes
Windows allows control transfers to pass up to 4k of data, so raise our
control buffer size to 4k. For control out transfers the usb core code copies
the control request data to a buffer before calling the device's handle_control
callback. Add a check for overflowing the buffer before copying the data.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-05-04 12:25:52 +02:00
Gerd Hoffmann c1ecb40a61 usb core: add migration support
Yes, seriously.  There is no migration support at all for usb devices.
They loose state, especially the device address, and stop responding
because of that.  Oops.

Luckily there is so much broken usb hardware out there that the guest
usually just kicks the device hard (via port reset and
reinitialization), then continues without a hitch.  So we got away with
that in a surprising high number of cases.

The arrival of remote wakeup (which enables autosuspend support) changes
that picture though.  The usb devices also forget that it they are
supposed to wakeup, so they don't do that.  The host also doesn't notice
the device stopped working in case it suspended the device and thus
expects it waking up instead of polling it.  Result is that your mouse
is dead.

Lets start fixing that.  Add a vmstate struct for USBDevice.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-24 17:21:34 +01:00
Gerd Hoffmann ace1318b8e usb: zap pdev from usbport
It isn't needed any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-12 11:40:04 +01:00
Gerd Hoffmann 5f69076b8d usb: add port property.
This allows to explictily set the physical port where you want to
plug the usb device.  Example:

  -device usb-tablet,bus=usb.0,port=2

With explicit port addressing qemu can and will not automagically add
USB Hubs.  This means that:

  (a) You can plug two devices of your choice into the two uhci
      root ports.
  (b) If you want plug in more that two devices you have to care
      about adding a hub yourself.

Plugging a hub works this way:

  -device usb-hub,bus=usb.0,port=1

Use this to add a device to the hub:

  -device usb-tablet,bus=usb.0,port=1.1

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 17:27:44 +01:00
Gerd Hoffmann c7a2196a4f usb: keep track of physical port address.
Add a path string to USBPort.  Add usb_port_location() function to set
the physical location of the usb port.  Update all drivers implementing
usb ports to call it.  Update the monitor commands to print it.  Wind it
up in qdev.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 17:24:42 +01:00
Gerd Hoffmann 25620cba94 usb: add device qualifier support
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-11 17:15:24 +01:00
Gerd Hoffmann b6f77fbe23 usb: add attach callback
Add handle_attach() callback to USBDeviceInfo which is called by the
generic package handler when the device is attached to the usb bus
(i.e. plugged into a port).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 17:15:24 +01:00