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

42 Commits

Author SHA1 Message Date
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 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
Gerd Hoffmann 6c2385270b usb-hub: remove unused descriptor arrays
Somehow they where left over when converting the hub
to the new usb descriptor infrastructure ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-08 11:26:10 +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
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 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 add750882f usb: update config descriptors to identify number of interfaces
Previously we relied on the .bNumInterfaces, but that won't always be
accurate after the introduction of grouped interfaces.

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
Gerd Hoffmann d15500902a usb hub: add migration support
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 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 843d4e0c63 usb: add speed mask to ports
Add a field to usb ports indicating the speed(s) they are
able to handle.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 17:15:23 +01:00
Gerd Hoffmann 34239c7bc9 usb: hub: remote wakeup support.
This patch makes the usb hub handle remote wakeup requests from devices
properly by updating the port status register and forwarding the wakeup
to the upstream port.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 17:01:02 +01:00
Gerd Hoffmann 618c169b57 usb: rework attach/detach workflow
Add separate detach callback to USBPortOps, split
uhci/ohci/musb/usbhub attach functions into two.

Move common code to the usb_attach() function, only
the hardware-specific bits remain in the attach/detach
callbacks.

Keep track of the port it is attached to for each usb device.

[ v3: fix tyops in usb-musb.c ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 17:01:02 +01:00
Gerd Hoffmann 0d86d2bebb usb: create USBPortOps, move attach there.
Create USBPortOps struct, move the attach function to that struct.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 17:01:02 +01:00
Gerd Hoffmann ed5a83ddd8 usb: move remote wakeup handling to common code
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-11 15:56:01 +01:00
Gerd Hoffmann a980a065fb usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common code
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-11 15:56:01 +01:00
Gerd Hoffmann 41c6abbdeb usb: move USB_REQ_SET_ADDRESS handling to common code
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-11 15:56:01 +01:00
Gerd Hoffmann 062651c7e7 usb hub: use new descriptor infrastructure.
Switch the usb hub driver over to the
new descriptor infrastructure.

It also removes the nr_ports variable and MAX_PORTS define and
introduces a NUM_PORTS define instead.  The numver of ports was
(and still is) fixed at 8 anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-11 15:56:00 +01:00
Gleb Natapov ab28ccc0c6 Record which USBDevice USBPort belongs too.
Ports on root hub will have NULL here. This is needed to reconstruct
path from device to its root hub to build device path.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11 21:32:44 +00:00
Gleb Natapov 779206de67 Introduce fw_name field to DeviceInfo structure.
Add "fw_name" to DeviceInfo to use in device path building. In
contrast to "name" "fw_name" should refer to functionality device
provides instead of particular device model like "name" does.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11 21:27:44 +00:00
Blue Swirl d4c4e6fdc7 usb: remove dead assignments, spotted by clang analyzer
Value stored is never read.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-04-25 18:23:04 +00:00
Riku Voipio 659139d780 Make USB hid devices self-powered
Simplifies power budget negotiation.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-18 23:23:56 +01:00
Markus Armbruster 556cd09885 qdev: Replace device names containing whitespace
Device names with whitespace require quoting in the shell and in the
monitor.  Some of the offenders are also overly long.  Some have a
more convenient alias, some don't.

The place for verbose device names is DeviceInfo member desc.  The
name should be short & sweet.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12 07:59:38 -06:00
Markus Armbruster 063846984c qdev: Separate USB product description from qdev name
Using the qdev name for the product description makes for inconvenient
qdev names.

Put the product description in new USBDeviceInfo member product_desc.
Make usb_qdev_init() use it.  No user or guest visible change, since
the value is still the same.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12 07:59:38 -06:00
Gerd Hoffmann a8e662b547 usb: hook unplug into qdev, cleanups + fixes.
Hook into DeviceInfo->exit().

handle_destroy() must not free the state struct, this is handled
by the new usb_qdev_exit() function now.

qdev_free(usb_device) works now.

Fix usb hub to qdev_free() all connected devices on unplug.
Unplugging a usb hub works now.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:48 -05:00
Gerd Hoffmann a5d2f7273c qdev/usb: make qemu aware of usb busses.
Move usb code from vl.c to usb-bus.c and make it use the new data
structures added by qdev conversion.  qemu usb core should be able
to handle multiple USB busses just fine now (untested though).

Kill some usb_*_init() legacy functions, use usb_create_simple()
instead.

Kill some FIXMEs added by the first qdev/usb patch.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09 14:55:17 -05:00
Gerd Hoffmann 806b602482 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>
2009-09-09 14:55:17 -05:00
aliguori 487414f1cb hw: remove error handling from qemu_malloc() callers (Avi Kivity)
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6529 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-05 22:06:05 +00:00
pbrook 87ecb68bdf Break up vl.h.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3674 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-17 17:14:51 +00:00
ths 3b46e62427 find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3177 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-17 08:09:54 +00:00
ths 5fafdf24ef find -type f | xargs sed -i 's/[\t ]$//g' # on most files
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-16 21:08:06 +00:00
pbrook 4d611c9a2f SCSI and USB async IO support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2107 c046a42c-6fe2-441c-8c8c-71466251a162
2006-08-12 01:04:27 +00:00
bellard 059809e451 usb destroy API change (Lonnie Mendez)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2066 c046a42c-6fe2-441c-8c8c-71466251a162
2006-07-19 18:06:15 +00:00
bellard 1f6e24e73c display device identifier string for user with info usb (Lonnie Mendez)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2029 c046a42c-6fe2-441c-8c8c-71466251a162
2006-06-26 21:00:51 +00:00
pbrook 2e5d83bbef Rearrange SCSI disk emulation code.
Add USB mass storage device emulation.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1940 c046a42c-6fe2-441c-8c8c-71466251a162
2006-05-25 23:58:51 +00:00
pbrook 0d92ed3022 OHCI USB host emulation.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1928 c046a42c-6fe2-441c-8c8c-71466251a162
2006-05-21 16:30:15 +00:00
bellard 67f3656039 patch in bLength for hub descriptor (Lonnie Mendez)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1905 c046a42c-6fe2-441c-8c8c-71466251a162
2006-05-05 20:05:35 +00:00
bellard 985d1742db fixes for more than 8 ports - return NAK if no change - FreeBSD workaround (Lonnie Mendez)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1872 c046a42c-6fe2-441c-8c8c-71466251a162
2006-04-30 21:53:59 +00:00
bellard 135e73c5f7 do not set PORT_STAT_C_ENABLE when doing port reset (Lonnie Mendez)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1849 c046a42c-6fe2-441c-8c8c-71466251a162
2006-04-24 21:25:26 +00:00
bellard 72899afc5d separate file for usb hub device
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1848 c046a42c-6fe2-441c-8c8c-71466251a162
2006-04-24 21:18:20 +00:00