History log of /haiku/src/add-ons/kernel/bus_managers/usb/Pipe.cpp
Revision Date Author Comments
# 8c458fc4 29-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

USB: Initialize packet descriptors inside the stack.

Allows deletion of generic code from bus drivers.


# 55a46882 30-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Support physical-vector bulk requests.

Introduce a new utility method, "generic_memcpy", which takes
generic_addr_t plus indications of whether these specify virtual or
physical addresses (and potentially user addresess) and calls the
appropriate memcpy variant depending.

All bus drivers adjusted to support this at once. We don't actually
take advantage of the physical addresses in any way (yet), as USB
controllers have some pretty specific requirements that would have
to be carefully validated to use these directly.

All bus drivers tested and confirmed to still be working.

Change-Id: I66326667e148091147bb2b3d0843a26fb7e5bda6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6479
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 99626c29 29-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Use generic_io_vec in Transfer.

Prepares the way for actual physical-address request support,
which is not yet wired up.

Change-Id: I1b2d04a31e334a79b8361280fa0f3a5fbdb43d2b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6478
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 00096a9d 29-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

USB: Add default max packet size for SuperSpeed bulk endpoints.

We already had one for High-Speed endpoints, but SuperSpeed endpoints
also have a fixed size, similar to Control endpoints.

May help with some devices failing to configure.


# eeec7ed4 24-Feb-2022 Augustin Cavalier <waddlesplash@gmail.com>

USB: Change from an instant to an unlimited timeout in ControlPipe::SendRequest.

Otherwise we have a race (or worse): in the case where the transfer
has completed or is in the process of completion between CancelQueued
and here, the callback can still be invoked after we returned and
cause corruption.

Discovered while working on USB support in the FreeBSD compatibility
layer: a lock inversion problem meant these timeouts always occurred
but then the callback would be invoked later and corrupt stack.

With this change, such problems will instead cause deadlocks.
That's not an ideal situation to be in, but we should detect
such problems elsewhere and make them into asserts; deadlocks
are assuredly better than random memory corruption.


# 8d046e26 20-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Split WaitForUnbusy from Object::PutUSBID.

In a few instances, we need to not wait for objects to become unbusy
during ID puts because we expect they still will be, e.g. in the case
of Control pipes with submitted transfers that are still running. There,
we need to put the ID, cancel transfers, and only then wait for the
object to become unbusy.

Technically, this is a functional change, but at least in practice
it will have little real-world effect, for two reasons:

1. The DefaultPipe's Busy flag is basically never updated (the Device's
busy flag is generally used instead), so it will virtually never be
"busy".

2. Most devices have no Control endpoints besides that default one.

Change-Id: I32ff4094effeac9ec74546c9643ea2025418e1c1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4491
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 2ce316cc 20-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Refuse transfer submission on pipes that are being removed.

This mostly only matters for the Device DefaultPipe, which is still
accesible even after its USBID has been put, but it makes sense to
do this in general, too.

Change-Id: I6711f1ce8fe79dff54927e3b5e60dec15bb58b14
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4489
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 2f496b30 20-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Make Pipe::CancelQueuedTransfers virtual and add a ControlPipe variant.

Control pipes have internal structures to wait for queued requests.
When force-cancelling queued transfers, the callbacks will not be called,
and so such transfers would be left hanging until the timeout occurred
or the destructor destroys the semaphore and mutex.

This probably will not fix any hang-related tickets, though, as force
cancellation is pretty much only used during device/pipe teardown.

Change-Id: I41db7caf380cdd082bc3509e95262317489bf100
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4488
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 5ee91867 09-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Track object busy-ness and wait for an unbusy state before teardown.

This reverts and replaces hrev53141, hrev53200~1, and hrev53888.

Two years ago (in hrev53141), I added checks to validate that Devices
were not in the process of being torn down before using them, to fix
a race condition KDL. Further logic was added in hrev53200~1 and in
hrev53888 for Pipes.

Well, upon closer inspection following the reports of #16794 et al.,
it appears upon closer inspection there were still two more race
conditions lurking in there: the first between Get and InitCheck, and
the second between InitCheck and use.

To resolve both of these, a new atomic "busy" flag is added to objects,
which is incremented before unlocking the objects array, and then
waited on before actually proceeding with teardown.

The older checks about initialization status are now superfluous
and are removed in favor of an earlier PutUSBID() invocation in Device.

While #16794 was fixed by hrev55429, some of those or related KDLs
might have been caused by these races. This also re-resolves #15115,
along with #14949 and #15710.

Change-Id: Ifcae84945a81123af5ef4683a6e33dc1eec5b23c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4421
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 1e02632b 17-Feb-2020 Augustin Cavalier <waddlesplash@gmail.com>

USB: Detach pipes from the stack before tearing down their state.

This way, it is now actually impossible to submit a request to a
pipe that is in the process of being destroyed, solving several
race conditions.

Should fix the remaining KDL in #15710.


# 6e2bbbb1 12-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Rename USB_SPEED_SUPER to USB_SPEED_SUPERSPEED.

For consistency's sake with the others.


# 4f8124c5 17-Jun-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Add initialization checks to Pipe usages of Device.

Complements the ones added earlier to the module itself.
Should fix the panic portion of #15115.


# 086528f6 16-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB & XHCI: Refactor endpoint initialization to support SuperSpeed better.

SuperSpeed (USB3) devices have a "companion descriptor" along with the
endpoint descriptors that describes certain other attributes they have,
which are important for the controller to schedule transfers properly.
Previously we were just using USB2 values; now we are properly using USB3
ones.

Tested on an Intel Lynx Point controller. As far as I can tell, no
regressions, but #15000 is not fixed anyway.


# b62bb24f 30-Jan-2016 Michael Lotz <mmlr@mlotz.ch>

USB: Force spec mandated control pipe max packet sizes.

While the USB descriptors are specifically built in such a way that it's
always possible to correctly query the max packet size, some devices
unfortunatley use bogus values in their descriptors and rely on the
stack to use the mandated values.

This fixes USB devices in VirtualBox when EHCI emulation is used. This
really is a bug in their descriptor emulation though.


# 334c06ae 01-Dec-2013 Jérôme Duval <jerome.duval@gmail.com>

usb: enforce wMaxPacketSize on high speed bulk endpoints.

* according to the USB 2.0 specification.


# 0153c18e 20-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

That the members aren't initialized in the constructor as pointed out by
Coverity was intentional (as explained by the comment). That the fInterval
member was somehow totally forgotten though, wasn't. This should only affect
EHCI and OHCI as they take the interval into account. Might fix some strange
behaviour, but most likely won't, as the interval range is rather narrow and
shouldn't be too noticeable if set incorrectly. CID 9558.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39904 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a009356a 16-Oct-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Update the comment after the timeout change in r38982.
Spotted by axeld, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38985 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 51ff3ec9 16-Oct-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Increase request timeout so that slow (read old USB 1.0Ã) devices got enough time to
startup before being able to reply initial configuration request.
This fix #6173.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38982 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 853e6be8 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

* Rename usb_p.h to usb_private.h.
* Some automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 72457edd 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Add a yet unused physical memory version of queue_bulk_v(). For full/lowspeed
devices it's uninteresting, but for EHCI it may be implemented some day.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36246 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f14fe767 23-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* Rework the USB tracing mechanism. Cleaned it up and make it more convenient to
use. It will now print out the usb_ids of the objects that generate the trace
messages. These IDs are unique compared to the device address used previously,
because device addresses are per bus while usb_ids are global. This makes
trace output from devices across multiple controllers distinguishable.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f30f14e 17-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Fix pretty severe error in the convenience functions Pipe::SetFeature(),
Pipe::ClearFeature() and Pipe::GetStatus(). These requests take the endpoint
address in the logical form, including the direction bit. This caused all those
requests to fail for all input pipes, most prominently visible in mass storage
where a mass storage reset could never be done completely and would cause many
devices to be unable to recover from errors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6236138e 08-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Lock the control pipe mutex before destroying it to ensure that a possibly
still open transfer has enough time to cleanly exit with error. Fixes a crash
when removing a device while a control transfer on the device endpoint was
open and would have timed out otherwise.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25863 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c7d757a0 29-May-2008 Michael Lotz <mmlr@mlotz.ch>

* For multi function devices it is not so unlikely to try to do multiple
concurent SendRequest() calls. Therefore it's probably a good idea to
protect that, now that the request data is not dynamically allocated anymore.
* Fix warning about not returning a result in the compatibility version of
init_mutex_etc() (which wouldn't make a difference as the Haiku version
does not return anything).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25707 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d80d1b5 22-May-2008 Michael Lotz <mmlr@mlotz.ch>

Cleanup a small leftover.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25621 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c1990557 22-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Use a lazily initialized notification sem for all SendRequest() calls.
* Also use member variables to transport the status information from the
callback instead of allocating a dedicated structure each time.
* Remove the now unused transfer_result_data struct.

This should bring down some overhead otherwise involved with sending requests
over control pipes. As this is heavily used in updating for example the hub
status (also on roothubs), this change should make the polling loop a lot
cheaper. Note that this makes SendRequest() non-thread safe, but as it is a
synchronous function (as opposed to QueueRequest) and since the underlying
architecture is not thread safe either this shouldn't be a problem (drivers
doing a SendRequest from two different threads would have failed previously
anyway). A benaphore or mutex could be employed to fix that if the need really
arises.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b6b5de07 05-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Use a more reasonable timeout of 1 second for synchronous USB requests.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24810 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a802bca 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

* Use the rescan function when compiled for Haiku
* Move waiting for the first explore to complete
* Small cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23099 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1070961 22-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Added some checks on parameters passed


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22981 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 072c28de 21-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

* Redesign the Pipe constructor to only take the parent object
* All other init is done in InitCommon() which only needs to be present in the base class
* Adding the hub port a device is attached to to the Device class
* Add hub port and hub address to the Pipe class (will be used for split transactions in EHCI)
* Update the root hubs to reflect the changes to hub creation

Sadly we need pipes that do not belong to devices (default pipe for addressing and to get initial device descriptor). Therefore we cannot resolve hub address and port from the parent device.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22972 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 55245956 17-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Store the polling interval in the InterruptPipe class to make it accessible to the controller.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22936 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13508e8b 14-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Completely redesign the USB explore process. Replaces the scary race conditions of the previous locking mechanism and simplifies handling of device changes by a more centralized approach.
Changes are now collected during explore and notifications as well as rescans are done at once. Through this a driver is also not rescanned multiple times anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d2e77702 11-Aug-2007 Michael Lotz <mmlr@mlotz.ch>

Change the way notify hooks and rescans are handeled. The rescans are now delayed to after all notify hooks are called (like in BeOS).
This also ensures that the rescans do not happen while the devices are not yet added or already removed.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21905 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ac9d1195 25-Jun-2007 Michael Lotz <mmlr@mlotz.ch>

Commiting patch by Salvatore Benedetto. This adds isochronous handling to the USB bus manager and enables inbound isochronous support in the UHCI driver. Thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21503 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3dc77d1d 06-May-2007 Michael Lotz <mmlr@mlotz.ch>

Prepare cancelling transfers from the stack side. The actual handling will happen in the HCD modules where transfer management has to be done anyway.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21043 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4771489e 28-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

Changing from a stack allocated result struct to a heap allocated one. This removes the possibility that a timed out transfer that later still triggers the callback writes into invalid stack space.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20004 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c4cce727 18-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

* Revised locking of the USB stack classes
* Implemented the Hub destructor to properly free all of its child devices
* Added FreeDevice() and FreeAddress() to the BusManager class
* Added timeout to ControlPipe::SendRequest()
* Changed how the recursive device reporting works so that it respects the support descriptors of a driver
* Enabled driver rescanning for drivers that are not currently loaded but still registered (R5 only as the devfs function is yet missing from Haiku)
* Changed the way usb_ids are handed out so that free ones are reused instead of just running out of ids
* Fixed driver registration so that each driver is only added once (and devices are reported once per driver)
* Unified debug output and fixed some warnings with debug output turned on
* Fixed some style issues and removed stray whitespaces

Overall the USB stack should now be much more reliable. It should not crash on disconnects anymore and repluging of a device should be noticed by all drivers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19860 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00f6fab9 26-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented a notification method for BusManagers so that they can be notified of pipe changes (creation, destruction, changed settings).
This is necessary in OHCI and will probably be used in EHCI also to keep one endpoint construct for each pipe open instead on creating and deleting it for each transfer.
* Pseudo implemented set_pipe_policy for isochronous pipes that makes use of the new notification system.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18945 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 17f83b21 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Switched from the old v2 callback status codes to the new v3 codes
This means that the usb_callback_func now takes a status_t instead of a uint32 status.
Also the error codes are now different. I don't see this as a real problem in binary compatibility, as the status codes were never really documented and most drivers just assumed that a nonzero status meant an error.
Source compatibility breaks for callback functions and error defines. I fixed (hopefully) all places in the tree that are currenty included in the image and affected by the change.
* Corrected error reporting in UHCI and EHCI using the new status codes.
* Fixed a memory leak in EHCI where the async advance interrupt was not triggered in time.
* Fixed another race condition in usb_raw that could cause a crash when a device is removed while a transfer is pending.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18916 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a278a1b 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixing my previous attempt at fixing cookie handling. Device addresses cannot be used, since there may be devices with the same address across different busses. A linked list of usb_driver_cookies is maintained now that relates devices and cookies.
* Fixed endpoint halt clearing. The data toggle has to be reset when we clear a stall.
* Now using up to B_PAGE_SIZE * 4 sized buffers in EHCI. They are split automatically by the host controller. This further pushes throughput.
* Optimize memory allocator settings for the above case. Enlarging it's managed space to 1MB
* Ignore the transaction error bit in EHCI. It is only of informational character as it also idicates errors that were recovered automatically. If an unrecoverable error occures, other bits will indicate this.
* Fixed some more print formats in debug output.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18915 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7145ff17 20-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented compatibility workaround for BeOS to be able to write user memory from the kernel finisher thread

This fixes crashing of the USB Mass Storage driver under R5. It is fully working there now.
I hope to be able to do this more cleanly under Haiku though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f452f9dc 14-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented most qTD and qH functions for EHCI async transfers.
* Implementing control and bulk (async) transfers. They don't work yet though.
* Corrected the legacy support handling in EHCI
* Fixed the bit mask for total bytes in qTDs and added the data toggle bit
* Changed the boolean low speed flags to usb_speed enum that allows for low, full and highspeed

Also wrote a memory allocator that takes over memory management from the stack. It is similar to a buddy allocator. This does on the one hand remove some ugly code from the stack and is on the other hand far more scalable than the previous free list approach. This scalability is needed for proper EHCI support where buffers can go up to a size of 5 pages. The allocator is not perfect and it's memory overhead is quite high compared to the managed memory (depends on the managed block sizes), but it's quik and works well so far.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8001b0c6 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

This subtle error (introduced in r18656) caused bulk pipes to stall.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8fedfdfc 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Rewrote some stack internals (again). Everything is now created using a parent object that shares the BusManager and Stack information to reduce individual constructors.
* Don't inherit Device and Interface from pipes anymore. The device has a default pipe member now.
* Since the parent of each Object is now known, we can send control messages using the default pipe of the device from all attached elements (pipes and interfaces).
* Fixed the generic {Set|Clear}Feature() and GetStatus() calls to include the endpoint address for pipe specific requests.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18710 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1bad4a4e 29-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed queue_isochronous in USB3.h to match the actual v3 API.
* Changed the usb module accordingly. Isochronous is all still left ToDo though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18700 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ffe3f107 27-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Redisigned some of the USB Stack. Unified constructors, removed redundant functions and moved some other functions around
* Implemented the EHCIRootHub
* Reworked UHCIRootHub to be more of a utility class and moved the actual work into the UHCI BusManager
* Implemented port reset in EHCI. Ports with low and fullspeed devices are now correctly handed over to the companion host controller.

Attachs and detachs as well as port resetting / enabling works now in EHCI. Only the actual data transfers are missing thereafter ;-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02ce23a1 24-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Unified and disabled TRACEing for the usb stack and uhci hcd
* Fixed warnings
* Some cleanup
* Added myself as an author to some files

No functional changes.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1e8c0b36 19-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented iovec based data handling in Transfer and UHCI
* Implemented QueueBulkV of the v3 API that uses it

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18540 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b0ec61f 19-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Added USB API Version 3. It's put into USB3.h while the v2 API resides in USB2.h. USB.h just includes USB2.h for now.
* Rewrote both headers on the way.
* The usb module now exports both, the v2 and v3 module_info.
* Changed the internals of the USB Stack to give out usb_ids instead of opaque handles to internal classes.
* Cleaned up some more of the Stack by moving members into other classes and removing unused stuff.
* Updated the usb_raw driver from v2 to v3 API.

Since both usb_hid (which still uses the v2 API) and usb_raw (which now uses the v3 API) work, I'd call it a success ;-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18539 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf9d24ed 14-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed memory leak of Transfers never getting deleted (intentionally until now).
* Reduced the Transfer class to a minimum and removed support for synchronous transfers. The only usage of this is in SendRequest(), which now provides a callback and QueueRequest()s it's request instead.
* Clarified semantics of SubmitTransfer(). It returns a status_t indicating wether the transfer was submitted successfully. This includes no information about the outcome. Therefore the UHCI RootHub now reports the status only through the callback and returns B_OK or B_ERROR for SubmitTransfer().
* Added comment to the Transfer class explaining who takes ownership of the Transfer in which cases.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18511 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49617128 14-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed data toggle handling. It must be taken after the transfer finished and from the last transmitted transfer descriptor (which in case of a short packet is not neccessarily the last descriptor of the chain)
* Moved convenience endpoint requests from ControlPipe to Pipe

With this change, bulk transfers are fairly stable now. See here for evidence: http://haiku.mlotz.ch/haiku-usb01.png ;). Those are pictures from my Canon Digital Ixus 750 downloaded with Exposure using the PTP plugin. I of course navigated Haiku with my USB Logitech iFeel mouse which works nice since some days.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18510 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b8c6a851 11-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented most of the USB module public API (using opaque handles like in R5 will change that to using IDs later)
* Fixed the UHCI root hub and the hub implementation. Interface and endpoint descriptors are part of the configuration descriptor, they cannot be requested individually.
* Added simple support for interrupt and bulk transfers to UHCI. It's enough to get my USB mouse working to a stable and usable degree.
* Cleaned up and reworked some other parts, added allocation checks and such.

Yes, my internet connection is back up :)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18496 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ba81a76 23-Jul-2006 Michael Lotz <mmlr@mlotz.ch>

Continuing work on the USB stack and UHCI driver.
* Moved the transfer descriptor management into the UHCI class
* Added locking to the driver and the queues
* Added service thread for finished transfers (to be implemented correctly)
* Cleaned up some headers and added myself as author

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18245 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b7a062b5 29-May-2006 Michael Lotz <mmlr@mlotz.ch>

* Calmed down debug output a bit
* Removed all friends in the USB stack classes (as they are not needed)
* Added max packet size to the pipe and respect it on transfers
* Use pipes with the same speed as the device

Device descriptors can now also be retrieved from full speed devices and devices with a packet size of more than 8 bytes. The devices are also correctly initialized to their default configuration.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 96da8285 28-May-2006 Michael Lotz <mmlr@mlotz.ch>

Applying style to remaining classes. No functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17624 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11bd72c2 28-May-2006 Michael Lotz <mmlr@mlotz.ch>

* Cleaned up / applied style to the Pipe class
* Introduced a Queue class that manages itself and where transfers are attached to
* Added "set feature" to the roothub and use it to enable the port of new devices

It is now possible to successfully detect new devices and send at least one transfer descriptor to them.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17615 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c81edd87 14-Mar-2005 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Update from my personal Arch tree just in time before SVN-move

Patches applied:

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--base-0
tag of Niels.Reedijk@gmail.com--haiku-2005/usb-busmanager--mainline--0.1--base-0

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-1
Start device addition procedure when a new device is connected

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-2


* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-3
Create transfers on the heap.

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-4
Transfer supports synchronous and callbacks

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-5

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-6
Give Pipes a notion of what type they are

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-7
Improve the handling of speed within pipes

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-8
Add a new member to the transfer in which the hostcontroller can store private data

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-9
Made some changes inspired by a mail from Marcus Overhagen

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-10
Fixed memory allocation model


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11741 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a2e81b5 19-Jul-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Summary: Merge in changes in busses / bus-manager loading
Keywords:

Patches applied:

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-24
Rename AllocArea to AllocateArea for consistency

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-25
Make the memory allocation routines more global and share it with the hc

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-26
Change from uint32 to addr_t to be safe on 64 bit in the future

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-27
AllocateChunk returns an area_id

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-28
Really fixing AllocateChunk now

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-29
Fix a bug where data was uninitialised when used and load debug symbols

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-30
Integrate host_controller.h

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-31
Many changes to accomodate for new bus_manager handling


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0216c64 20-Jun-2004 beveloper <beveloper@nowhere.fake>

added missing newline at end of file


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8078 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2265a339 19-Jun-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

My own "we are haiku now"-commit:
I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I -
I took the one less travelled by,
And that has made all the difference
Robert Frost (The Road Not Taken)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8070 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1a90371 06-Jun-2004 Axel Dörfler <axeld@pinc-software.de>

Added missing newline to the end of the files.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7779 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0f6609e8 28-May-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-5
Commit (in between) because of a switch of development-machines

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-6
Implement basic hub init

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-7
Implement a bit more of hub operation

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-8
Device Adress 0 is reserved for the default pipe!

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-9
Implement basic Pipe stuff

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-10
Create basic chunk allocation

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-11
Add Required util.c/util.h

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-12
Provide locking for the stack and make AllocateChunk thread-safe

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-13
Integrated util.c in stack class (cleans up a little)

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-14
Improve Pipe and give the Busmanager its default pipe

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-15
Make the Device class speed aware

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-16
Make Chunk allocation code more dynamic

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-17
Small test-commit to test if webdav is working -- ignore

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-18
Changed Packets into Transfers

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-19
Fix mistakes in host_controller.c

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-20
Advanced a little more in the Pipe stuff

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-21
Merge with mainline and add newlines at the end of files


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7668 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 334c06ae65a0cafcf647aef9f96d2b9b1f59c66e 01-Dec-2013 Jérôme Duval <jerome.duval@gmail.com>

usb: enforce wMaxPacketSize on high speed bulk endpoints.

* according to the USB 2.0 specification.


# 0153c18eedb01463b9af8123a358af88f1c3b647 20-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

That the members aren't initialized in the constructor as pointed out by
Coverity was intentional (as explained by the comment). That the fInterval
member was somehow totally forgotten though, wasn't. This should only affect
EHCI and OHCI as they take the interval into account. Might fix some strange
behaviour, but most likely won't, as the interval range is rather narrow and
shouldn't be too noticeable if set incorrectly. CID 9558.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39904 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a009356a78f3f517b9c31f59b4e3d46a2061073c 16-Oct-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Update the comment after the timeout change in r38982.
Spotted by axeld, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38985 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 51ff3ec972a8314fad1cafd7c811e6794faf27f7 16-Oct-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Increase request timeout so that slow (read old USB 1.0Ã) devices got enough time to
startup before being able to reply initial configuration request.
This fix #6173.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38982 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 853e6be8ca7117d62f497d539aa044adc2fdf573 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

* Rename usb_p.h to usb_private.h.
* Some automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 72457eddbcbb2c22e11ecbc78ae960375554db97 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Add a yet unused physical memory version of queue_bulk_v(). For full/lowspeed
devices it's uninteresting, but for EHCI it may be implemented some day.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36246 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f14fe767bf568186bbd0678e35b03c99d8a264c6 23-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* Rework the USB tracing mechanism. Cleaned it up and make it more convenient to
use. It will now print out the usb_ids of the objects that generate the trace
messages. These IDs are unique compared to the device address used previously,
because device addresses are per bus while usb_ids are global. This makes
trace output from devices across multiple controllers distinguishable.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f30f14eddead18aff27f3666390b5c63925895c 17-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Fix pretty severe error in the convenience functions Pipe::SetFeature(),
Pipe::ClearFeature() and Pipe::GetStatus(). These requests take the endpoint
address in the logical form, including the direction bit. This caused all those
requests to fail for all input pipes, most prominently visible in mass storage
where a mass storage reset could never be done completely and would cause many
devices to be unable to recover from errors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6236138e259e50c6f457d27180e435610c8e1c40 08-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Lock the control pipe mutex before destroying it to ensure that a possibly
still open transfer has enough time to cleanly exit with error. Fixes a crash
when removing a device while a control transfer on the device endpoint was
open and would have timed out otherwise.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25863 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c7d757a0746b066d2b0e7e1e317b52ae722d4176 29-May-2008 Michael Lotz <mmlr@mlotz.ch>

* For multi function devices it is not so unlikely to try to do multiple
concurent SendRequest() calls. Therefore it's probably a good idea to
protect that, now that the request data is not dynamically allocated anymore.
* Fix warning about not returning a result in the compatibility version of
init_mutex_etc() (which wouldn't make a difference as the Haiku version
does not return anything).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25707 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d80d1b5a7a62711f6c373e88457d47d12c9003e 22-May-2008 Michael Lotz <mmlr@mlotz.ch>

Cleanup a small leftover.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25621 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c1990557b889feddc35cf926cf62cd2277297027 22-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Use a lazily initialized notification sem for all SendRequest() calls.
* Also use member variables to transport the status information from the
callback instead of allocating a dedicated structure each time.
* Remove the now unused transfer_result_data struct.

This should bring down some overhead otherwise involved with sending requests
over control pipes. As this is heavily used in updating for example the hub
status (also on roothubs), this change should make the polling loop a lot
cheaper. Note that this makes SendRequest() non-thread safe, but as it is a
synchronous function (as opposed to QueueRequest) and since the underlying
architecture is not thread safe either this shouldn't be a problem (drivers
doing a SendRequest from two different threads would have failed previously
anyway). A benaphore or mutex could be employed to fix that if the need really
arises.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b6b5de0741aa4b566f93a91509f0ad49d6b360bb 05-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Use a more reasonable timeout of 1 second for synchronous USB requests.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24810 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a802bca9d1d5589598ff9051d8dcb6b2cae2cbe 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

* Use the rescan function when compiled for Haiku
* Move waiting for the first explore to complete
* Small cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23099 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1070961a35b9998ef54b518ae8e4dd94b26f751 22-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Added some checks on parameters passed


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22981 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 072c28ded529ca52c32863b4eb1b8f21f1debb71 21-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

* Redesign the Pipe constructor to only take the parent object
* All other init is done in InitCommon() which only needs to be present in the base class
* Adding the hub port a device is attached to to the Device class
* Add hub port and hub address to the Pipe class (will be used for split transactions in EHCI)
* Update the root hubs to reflect the changes to hub creation

Sadly we need pipes that do not belong to devices (default pipe for addressing and to get initial device descriptor). Therefore we cannot resolve hub address and port from the parent device.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22972 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 552459564517527d31207fb5e6ae0d3e569f2437 17-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Store the polling interval in the InterruptPipe class to make it accessible to the controller.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22936 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13508e8bd034aac27c2e3271aefa04e255520d99 14-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Completely redesign the USB explore process. Replaces the scary race conditions of the previous locking mechanism and simplifies handling of device changes by a more centralized approach.
Changes are now collected during explore and notifications as well as rescans are done at once. Through this a driver is also not rescanned multiple times anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d2e77702cb5dd62760e99aa66141abfcb2c54e80 11-Aug-2007 Michael Lotz <mmlr@mlotz.ch>

Change the way notify hooks and rescans are handeled. The rescans are now delayed to after all notify hooks are called (like in BeOS).
This also ensures that the rescans do not happen while the devices are not yet added or already removed.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21905 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ac9d119566e5c19de0279483c4847996b2f1a879 25-Jun-2007 Michael Lotz <mmlr@mlotz.ch>

Commiting patch by Salvatore Benedetto. This adds isochronous handling to the USB bus manager and enables inbound isochronous support in the UHCI driver. Thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21503 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3dc77d1dc9c33a9b7c799ab40d7be5f48d15dc6c 06-May-2007 Michael Lotz <mmlr@mlotz.ch>

Prepare cancelling transfers from the stack side. The actual handling will happen in the HCD modules where transfer management has to be done anyway.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21043 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4771489e89210b691ac43ad9912b03149b220998 28-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

Changing from a stack allocated result struct to a heap allocated one. This removes the possibility that a timed out transfer that later still triggers the callback writes into invalid stack space.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20004 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c4cce7277c297a0a5a78c69a20375182522296e1 18-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

* Revised locking of the USB stack classes
* Implemented the Hub destructor to properly free all of its child devices
* Added FreeDevice() and FreeAddress() to the BusManager class
* Added timeout to ControlPipe::SendRequest()
* Changed how the recursive device reporting works so that it respects the support descriptors of a driver
* Enabled driver rescanning for drivers that are not currently loaded but still registered (R5 only as the devfs function is yet missing from Haiku)
* Changed the way usb_ids are handed out so that free ones are reused instead of just running out of ids
* Fixed driver registration so that each driver is only added once (and devices are reported once per driver)
* Unified debug output and fixed some warnings with debug output turned on
* Fixed some style issues and removed stray whitespaces

Overall the USB stack should now be much more reliable. It should not crash on disconnects anymore and repluging of a device should be noticed by all drivers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19860 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00f6fab9315c42c68c336f31f6061ba6faa17c27 26-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented a notification method for BusManagers so that they can be notified of pipe changes (creation, destruction, changed settings).
This is necessary in OHCI and will probably be used in EHCI also to keep one endpoint construct for each pipe open instead on creating and deleting it for each transfer.
* Pseudo implemented set_pipe_policy for isochronous pipes that makes use of the new notification system.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18945 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 17f83b219d63eae4de462d6868e7d26ad6c3949e 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Switched from the old v2 callback status codes to the new v3 codes
This means that the usb_callback_func now takes a status_t instead of a uint32 status.
Also the error codes are now different. I don't see this as a real problem in binary compatibility, as the status codes were never really documented and most drivers just assumed that a nonzero status meant an error.
Source compatibility breaks for callback functions and error defines. I fixed (hopefully) all places in the tree that are currenty included in the image and affected by the change.
* Corrected error reporting in UHCI and EHCI using the new status codes.
* Fixed a memory leak in EHCI where the async advance interrupt was not triggered in time.
* Fixed another race condition in usb_raw that could cause a crash when a device is removed while a transfer is pending.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18916 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a278a1bb7c57c701210c7ded6b5b8dca82e293f 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixing my previous attempt at fixing cookie handling. Device addresses cannot be used, since there may be devices with the same address across different busses. A linked list of usb_driver_cookies is maintained now that relates devices and cookies.
* Fixed endpoint halt clearing. The data toggle has to be reset when we clear a stall.
* Now using up to B_PAGE_SIZE * 4 sized buffers in EHCI. They are split automatically by the host controller. This further pushes throughput.
* Optimize memory allocator settings for the above case. Enlarging it's managed space to 1MB
* Ignore the transaction error bit in EHCI. It is only of informational character as it also idicates errors that were recovered automatically. If an unrecoverable error occures, other bits will indicate this.
* Fixed some more print formats in debug output.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18915 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7145ff1705037d7310ea0d608484279c1dabfa64 20-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented compatibility workaround for BeOS to be able to write user memory from the kernel finisher thread

This fixes crashing of the USB Mass Storage driver under R5. It is fully working there now.
I hope to be able to do this more cleanly under Haiku though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f452f9dc783e647ece105a379564d9ce6a05de2b 14-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented most qTD and qH functions for EHCI async transfers.
* Implementing control and bulk (async) transfers. They don't work yet though.
* Corrected the legacy support handling in EHCI
* Fixed the bit mask for total bytes in qTDs and added the data toggle bit
* Changed the boolean low speed flags to usb_speed enum that allows for low, full and highspeed

Also wrote a memory allocator that takes over memory management from the stack. It is similar to a buddy allocator. This does on the one hand remove some ugly code from the stack and is on the other hand far more scalable than the previous free list approach. This scalability is needed for proper EHCI support where buffers can go up to a size of 5 pages. The allocator is not perfect and it's memory overhead is quite high compared to the managed memory (depends on the managed block sizes), but it's quik and works well so far.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8001b0c61402c8e977de173ce25a81e1a0718b5a 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

This subtle error (introduced in r18656) caused bulk pipes to stall.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8fedfdfcf8f931cd52a6e934a5b4e0aca565cf99 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Rewrote some stack internals (again). Everything is now created using a parent object that shares the BusManager and Stack information to reduce individual constructors.
* Don't inherit Device and Interface from pipes anymore. The device has a default pipe member now.
* Since the parent of each Object is now known, we can send control messages using the default pipe of the device from all attached elements (pipes and interfaces).
* Fixed the generic {Set|Clear}Feature() and GetStatus() calls to include the endpoint address for pipe specific requests.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18710 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1bad4a4ef9a3f607482ca01848b5c78a3d61c09d 29-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed queue_isochronous in USB3.h to match the actual v3 API.
* Changed the usb module accordingly. Isochronous is all still left ToDo though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18700 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ffe3f107c4ae65ec52128bb36115779fe07a01c0 27-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Redisigned some of the USB Stack. Unified constructors, removed redundant functions and moved some other functions around
* Implemented the EHCIRootHub
* Reworked UHCIRootHub to be more of a utility class and moved the actual work into the UHCI BusManager
* Implemented port reset in EHCI. Ports with low and fullspeed devices are now correctly handed over to the companion host controller.

Attachs and detachs as well as port resetting / enabling works now in EHCI. Only the actual data transfers are missing thereafter ;-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02ce23a1adaf30f7d8a63fd953bb5314ea560d55 24-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Unified and disabled TRACEing for the usb stack and uhci hcd
* Fixed warnings
* Some cleanup
* Added myself as an author to some files

No functional changes.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1e8c0b3649ff4915369402f2e005b486ef6e7dfb 19-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented iovec based data handling in Transfer and UHCI
* Implemented QueueBulkV of the v3 API that uses it

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18540 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b0ec61f972bca106675a66c37354e38efb8016d 19-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Added USB API Version 3. It's put into USB3.h while the v2 API resides in USB2.h. USB.h just includes USB2.h for now.
* Rewrote both headers on the way.
* The usb module now exports both, the v2 and v3 module_info.
* Changed the internals of the USB Stack to give out usb_ids instead of opaque handles to internal classes.
* Cleaned up some more of the Stack by moving members into other classes and removing unused stuff.
* Updated the usb_raw driver from v2 to v3 API.

Since both usb_hid (which still uses the v2 API) and usb_raw (which now uses the v3 API) work, I'd call it a success ;-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18539 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf9d24edd2bbbb8a0341da366180909a32b5b57f 14-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed memory leak of Transfers never getting deleted (intentionally until now).
* Reduced the Transfer class to a minimum and removed support for synchronous transfers. The only usage of this is in SendRequest(), which now provides a callback and QueueRequest()s it's request instead.
* Clarified semantics of SubmitTransfer(). It returns a status_t indicating wether the transfer was submitted successfully. This includes no information about the outcome. Therefore the UHCI RootHub now reports the status only through the callback and returns B_OK or B_ERROR for SubmitTransfer().
* Added comment to the Transfer class explaining who takes ownership of the Transfer in which cases.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18511 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49617128ca4b55143325c5f7b8358e0307ad047d 14-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed data toggle handling. It must be taken after the transfer finished and from the last transmitted transfer descriptor (which in case of a short packet is not neccessarily the last descriptor of the chain)
* Moved convenience endpoint requests from ControlPipe to Pipe

With this change, bulk transfers are fairly stable now. See here for evidence: http://haiku.mlotz.ch/haiku-usb01.png ;). Those are pictures from my Canon Digital Ixus 750 downloaded with Exposure using the PTP plugin. I of course navigated Haiku with my USB Logitech iFeel mouse which works nice since some days.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18510 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b8c6a85136cd56e8cf3282ca69b0d2d2832a3eee 11-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented most of the USB module public API (using opaque handles like in R5 will change that to using IDs later)
* Fixed the UHCI root hub and the hub implementation. Interface and endpoint descriptors are part of the configuration descriptor, they cannot be requested individually.
* Added simple support for interrupt and bulk transfers to UHCI. It's enough to get my USB mouse working to a stable and usable degree.
* Cleaned up and reworked some other parts, added allocation checks and such.

Yes, my internet connection is back up :)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18496 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ba81a767e9e8cd36ddd627853ae12bcf1c6b71c 23-Jul-2006 Michael Lotz <mmlr@mlotz.ch>

Continuing work on the USB stack and UHCI driver.
* Moved the transfer descriptor management into the UHCI class
* Added locking to the driver and the queues
* Added service thread for finished transfers (to be implemented correctly)
* Cleaned up some headers and added myself as author

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18245 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b7a062b5add9426990a2656b9b0846618ee4ae90 29-May-2006 Michael Lotz <mmlr@mlotz.ch>

* Calmed down debug output a bit
* Removed all friends in the USB stack classes (as they are not needed)
* Added max packet size to the pipe and respect it on transfers
* Use pipes with the same speed as the device

Device descriptors can now also be retrieved from full speed devices and devices with a packet size of more than 8 bytes. The devices are also correctly initialized to their default configuration.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 96da8285b0b36b7499e334e9ecc3da22e8e9b599 28-May-2006 Michael Lotz <mmlr@mlotz.ch>

Applying style to remaining classes. No functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17624 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11bd72c28c1b7c5756f28353739c6817303bc736 28-May-2006 Michael Lotz <mmlr@mlotz.ch>

* Cleaned up / applied style to the Pipe class
* Introduced a Queue class that manages itself and where transfers are attached to
* Added "set feature" to the roothub and use it to enable the port of new devices

It is now possible to successfully detect new devices and send at least one transfer descriptor to them.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17615 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c81edd87b5d83125e35d7930a2c05abdf4864a97 14-Mar-2005 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Update from my personal Arch tree just in time before SVN-move

Patches applied:

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--base-0
tag of Niels.Reedijk@gmail.com--haiku-2005/usb-busmanager--mainline--0.1--base-0

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-1
Start device addition procedure when a new device is connected

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-2


* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-3
Create transfers on the heap.

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-4
Transfer supports synchronous and callbacks

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-5

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-6
Give Pipes a notion of what type they are

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-7
Improve the handling of speed within pipes

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-8
Add a new member to the transfer in which the hostcontroller can store private data

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-9
Made some changes inspired by a mail from Marcus Overhagen

* Niels.Reedijk@gmail.com--nielx-2005/usb-busmanager--development--0.1--patch-10
Fixed memory allocation model


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11741 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a2e81b52cfafb4a0ec65f935ce32b69923638dd 19-Jul-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Summary: Merge in changes in busses / bus-manager loading
Keywords:

Patches applied:

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-24
Rename AllocArea to AllocateArea for consistency

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-25
Make the memory allocation routines more global and share it with the hc

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-26
Change from uint32 to addr_t to be safe on 64 bit in the future

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-27
AllocateChunk returns an area_id

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-28
Really fixing AllocateChunk now

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-29
Fix a bug where data was uninitialised when used and load debug symbols

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-30
Integrate host_controller.h

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-31
Many changes to accomodate for new bus_manager handling


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0216c645fb17fe2a64308cdb5edebeebfdd2135 20-Jun-2004 beveloper <beveloper@nowhere.fake>

added missing newline at end of file


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8078 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2265a3399b35fe0c0a11b8bd380e294a4e2e3ba5 19-Jun-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

My own "we are haiku now"-commit:
I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I -
I took the one less travelled by,
And that has made all the difference
Robert Frost (The Road Not Taken)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8070 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1a9037152d8d7d819d4f6ce107d404dbdeda9d5 06-Jun-2004 Axel Dörfler <axeld@pinc-software.de>

Added missing newline to the end of the files.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7779 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0f6609e85c6573eadcfc4b6fa0acaa847e313680 28-May-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-5
Commit (in between) because of a switch of development-machines

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-6
Implement basic hub init

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-7
Implement a bit more of hub operation

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-8
Device Adress 0 is reserved for the default pipe!

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-9
Implement basic Pipe stuff

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-10
Create basic chunk allocation

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-11
Add Required util.c/util.h

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-12
Provide locking for the stack and make AllocateChunk thread-safe

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-13
Integrated util.c in stack class (cleans up a little)

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-14
Improve Pipe and give the Busmanager its default pipe

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-15
Make the Device class speed aware

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-16
Make Chunk allocation code more dynamic

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-17
Small test-commit to test if webdav is working -- ignore

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-18
Changed Packets into Transfers

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-19
Fix mistakes in host_controller.c

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-20
Advanced a little more in the Pipe stuff

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-21
Merge with mainline and add newlines at the end of files


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7668 a95241bf-73f2-0310-859d-f6bbb57e9c96