History log of /haiku/src/add-ons/kernel/bus_managers/usb/Hub.cpp
Revision Date Author Comments
# 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>


# f62329b3 08-Feb-2020 Augustin Cavalier <waddlesplash@gmail.com>

USB: Explore ports when something is connected without a status change.

It seems that many controllers do not report status changes following
the hand-off from the BIOS, so we were never probing those ports
and reporting the devices attached to them.

The BSDs do something similar (although it seems to only do this
on the first explore, not always.)

This fixes booting off of USB3 ports from most Intel controllers,
as well as a variety of others with similar behavior.

Fixes #15000.


# aefe4850 14-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Rework the device speed detection code.

This is more in line with how OpenBSD and FreeBSD do this detection;
and should provide at least some support for USB 3.0+ hubs.

Potentially helps with #15001.

Change-Id: I313400b790b52fbca490c9fc8b721bedb97a64f9


# 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.


# 642ac9c9 10-Oct-2018 Peter Kosyh <p.kosyh@gmail.com>

xhci: GetPortStatus, ClearPortFeature (PS_PLC, PS_WRC) fix

Fixes #13768.

Change-Id: Ia783e62a15917a2c8f7b3169ee5204a8d8d6f5ef
Reviewed-on: https://review.haiku-os.org/622
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Alexander von Gluck IV <kallisti5@unixzen.com>


# d8548e00 07-Nov-2015 Jonathan Schleifer <js@webkeks.org>

Fix some more type mismatches with std::{min,max}


# 192f01c6 11-Jul-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

XHCI USB: Some more fixes.

* Fix device speed identification.
* Fix Max Packet Size for Full-Speed devices.
* Fix IRQ rate.
* Update slot context for LS/FS devices connected to non-root HS hub.
* Fix typo.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# 17aa359b 28-Jun-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

XHCI USB: Fixes.

* Add support for hubs in AllocateDevice().
* Prevent page fault in FinishTransfers().
* Set fCapabilityLength
* Correct in BIOS ownership code
* Fix context errors in _InsertEndpointForPipe().
* Update constants according to latest Specification (v1.1)
* Fix SMI code (reference
http://lkml.iu.edu/hypermail/linux/kernel/1204.2/02460.html).
* Fix Memory/Device-Slot leaks.
* Fix area allocation for TRBs.
* Fix for Intel Lynx Point and Panther Point chipsets. Also move init
of xhci before ehci, to switch USB 2.0 ports before the ehci module
discovers them.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# c5e233d3 09-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

usb: hub port reset is also done when the port status reset bit is zero.

* encountered on QEmu 1.6.50 with nec-usb-xhci and usb-storage devices.


# 827c7224 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Implement debounce sequence according to USB 2.0 specs.

This replaces waiting a fixed time of 300ms for the device power to
stabilize. In the ideal case this reduces the boot time by 200ms per
connected device (including internal hubs).

This is very similar to what Linux implements and we use the same time
values. An interval of 25ms is used to check for connection state
changes, the stable time is at least 100ms as per the USB specs and the
whole process times out after 1.5 seconds.


# d8b4cfc9 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# 319a3798 22-Dec-2011 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on XHCI bus driver.

* USB Core:
Hub: pass more correct speed, port and address for USB3 devices.
Transfer: doesn't care for bandwidth computation for super speed.
BusManager: Make AllocateDevice() and FreeDevice() virtual, XHCI needs to setup
a slot and an address for the device.
Add USB_SPEED_WIRELESS usb_speed definition.
Add USB2.0 erratum definition and some USB3 definitions
* XHCI:
Find outs which port supports SuperSpeed or not.
Override AllocateDevice() to configure slot and address for a connected device.
Override FreeDevice() to free ressources associated to a slot.
Add context struct definitions.


# 0e76cf0b 31-Mar-2011 Jérôme Duval <korli@users.berlios.de>

added some hub ports information to listusb


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41157 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


# 696914f9 13-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

If device allocation fails, retry the attach process, i.e. reset and initialize
the device again. Makes Axel's USB stick work and might also help with other
(broken) devices.


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


# 3ce26345 30-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed the semantics of [v]snprintf(): If the buffer is not large enough,
the function shall nevertheless return the length of the string that would
be written, if the buffer were large enough.
Added a touch of C++ while doing that. :-)
* Fixed the instances in boot loader, kernel, and kernel modules where the
wrong semantics were expected. The majority of uses actually.


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


# 5d143111 05-May-2009 Michael Lotz <mmlr@mlotz.ch>

When doing removal notifications for USB devices, report the hub after the
children. Otherwise a driver that builds up a device hierarchy could run into
trouble when the parent hub is removed before its child devices. Not that there
were any drivers that do so, but it just seems more correct.


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


# f81f8ddb 05-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Fix search+replace error introduced with reworking debug output. This should
fix full/lowspeed devices behind high-speed hubs again.


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


# 621e8eeb 25-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Fix usage of wrong port change values. The request numbers were compared with
the bitmap instead of the masks. Spotted by Mika Lindqvist (after 100 reboots),
thanks for tracking down such hard to spot errors!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29029 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


# a5243128 21-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Fix off-by-one error in port number which caused full- or lowspeed devices
behind highspeed hubs with multiple transaction translators not to work.
* The parent hub isn't necessarily the one providing the transaction translator
for a full- or lowspeed device. Therefore we need to inherit the hub/port
addresses to lower devices unless we are a highspeed hub that might be the
actual provider of the transaction translator. This logic error caused full-
and lowspeed devices not to work if they were behind a fullspeed hub that
itself was behind a highspeed hub.

This fixes bugs #1889 and #2501.

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


# 508dd5f9 21-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Output some more debug output in case of port reset failure.

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


# 519fbf77 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Make the maximum port count a define and set it to 16. OHCI officially
supports up to 15 ports and QEMUs OHCI emulation uses a port count of 10
for example.
* Update the hub code to remove the hardcoded 8 port limits.
* Some other code to enumerate the USB structure I had laying around
(available internally only, might be added as a public API some time).

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


# b04afa24 04-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Another tiny cut in stack load time: do not delay after setting the current
configuration of a root hub
* Cut down on number of retries to set the initial device address

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


# a93bd0c4 01-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Cutting down on unnecessary per-controller delays when starting up the USB
stack. The root hubs do not really need a powerup delay and as they are not
used until all initialization is done, this gives plenty of time to stabilize
the power. Therefore remove the powerup delay for root hubs and reduce the
stabilization time to zero. Also remove the define for the first explore delay
as it is not used.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24727 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


# 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


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

* Moved around some initialization to avoid problems when deleting incompletely created objects
* Also move waiting for the first explore to run through out of the constructor to reduce delays
* Remove the old device when a new one is connected to the same port - this could happen when you very quickly un- and replug a device

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21042 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


# a8be7d1e 06-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

* Added some more debug output to the hub code
* Report and clear yet unhandled port changes in hubs
* Fixed the way devices that vanish on port reset are handled
* Added a status field to the memory allocator and check it creating it

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19732 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


# 90b9fb4f 23-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed notify cookie handling. There is not one cookie per device, but one per device/driver combination
* Fixed SetFeature/ClearFeature/GetStatus for interfaces by adding the respective interface number
* Added driver rescanning mechanism (taken from bin/rescan)

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


# 12cf623f 16-Sep-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

unified callback parameter definition of size_t and uint32, now uses size_t


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


# dff0c634 15-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented transfer finishing in EHCI
* Implemented actual length calculation in EHCI
* Implemented bulk transfers in EHCI
* Implemented queue freeing in EHCI
* Added extended buffer pointers to the EHCI structs, necessary when the controller supports 64bit
* Fixed debug output and removed warnings due to wrong print format

Control and bulk transfers are now working nicely for EHCI. This means that I can now get pictures from my camera with USB 2.0 speed. Note though that many things still are unimplemented (isochronous transfers, split transactions, interrupt transfers, queue chaches per pipe, ...). But it's certainly a nice step forward :-).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18855 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


# 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


# 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


# 64f3c065 16-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

Implemented a usb_ioctl to retrive the logical device name (like 0/0, 0/1/0 or 1/hub) that will be used by usb_raw to publish the according devfs entries.

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


# d83f3c1a 13-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed setting configurations (need to use the configuration_value instead of the index of course)
* Fixed reported power status of the UHCI Root Hub
* Added preservation of the SOF_MODIFY register when doing a global reset of the UHC
* Read out the actual length for outgoing transfers too
* Made actual length handling for transfers a bit safer and correct in respect to NULL packets
* Use short packet detect to handle short packets
* First step at implementing the hub interrupt

Since the devices are now configured correctly, some bulk transfers actually work. Also my hub now reports its status correctly.

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


# f1020a6c 12-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Changed the Stack lock to a benaphore
* Removed some debug output from UHCI
* Added some debug output to the usb module instead ;)
* Rewrote the way new devices are attached and ports are handled (now more similar to FreeBSD)
* Corrected handling of port resets so that they should work on hubs too
* Cleaned up some headers

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18499 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


# 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


# 7ce4cf08 30-May-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Summary: Merged with development branch (nielx)

Patches applied:

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-22
Update/add licence header


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7689 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


# 8b485af8 13-Apr-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Summary: Continued work on hub initialisation
Keywords:

Patches applied:

* 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


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


# a8e39155 30-Dec-2003 Niels Sascha Reedijk <niels.reedijk@gmail.com>

*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-1
Implement basic Busmanager loader modules
*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-2
Continue shaping up some things
*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-3
Continued device initialisation
*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-4
Finalised the device initialisation


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


# 192f01c669102651bdc81273811079e90e0a29e5 11-Jul-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

XHCI USB: Some more fixes.

* Fix device speed identification.
* Fix Max Packet Size for Full-Speed devices.
* Fix IRQ rate.
* Update slot context for LS/FS devices connected to non-root HS hub.
* Fix typo.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# 17aa359b5df69f658b4b33e29546c9fb2f0cfce3 28-Jun-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

XHCI USB: Fixes.

* Add support for hubs in AllocateDevice().
* Prevent page fault in FinishTransfers().
* Set fCapabilityLength
* Correct in BIOS ownership code
* Fix context errors in _InsertEndpointForPipe().
* Update constants according to latest Specification (v1.1)
* Fix SMI code (reference
http://lkml.iu.edu/hypermail/linux/kernel/1204.2/02460.html).
* Fix Memory/Device-Slot leaks.
* Fix area allocation for TRBs.
* Fix for Intel Lynx Point and Panther Point chipsets. Also move init
of xhci before ehci, to switch USB 2.0 ports before the ehci module
discovers them.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# c5e233d3883bb82e80f21e1011cfdd47e8e398ab 09-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

usb: hub port reset is also done when the port status reset bit is zero.

* encountered on QEmu 1.6.50 with nec-usb-xhci and usb-storage devices.


# 827c7224a0aa44530aa8dfe11ec12c0e58bcb054 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Implement debounce sequence according to USB 2.0 specs.

This replaces waiting a fixed time of 300ms for the device power to
stabilize. In the ideal case this reduces the boot time by 200ms per
connected device (including internal hubs).

This is very similar to what Linux implements and we use the same time
values. An interval of 25ms is used to check for connection state
changes, the stable time is at least 100ms as per the USB specs and the
whole process times out after 1.5 seconds.


# d8b4cfc9829119291e68cfe0152c239fd8850b3d 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# 319a3798bc05579e8be813c2524bc89864bae489 22-Dec-2011 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on XHCI bus driver.

* USB Core:
Hub: pass more correct speed, port and address for USB3 devices.
Transfer: doesn't care for bandwidth computation for super speed.
BusManager: Make AllocateDevice() and FreeDevice() virtual, XHCI needs to setup
a slot and an address for the device.
Add USB_SPEED_WIRELESS usb_speed definition.
Add USB2.0 erratum definition and some USB3 definitions
* XHCI:
Find outs which port supports SuperSpeed or not.
Override AllocateDevice() to configure slot and address for a connected device.
Override FreeDevice() to free ressources associated to a slot.
Add context struct definitions.


# 0e76cf0b69324e071618d5a7105d1084d2a27550 31-Mar-2011 Jérôme Duval <korli@users.berlios.de>

added some hub ports information to listusb


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41157 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


# 696914f9077abd1ed503e25d4205735568c6a717 13-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

If device allocation fails, retry the attach process, i.e. reset and initialize
the device again. Makes Axel's USB stick work and might also help with other
(broken) devices.


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


# 3ce26345338e484601eb0a6598414d22cb73c9cc 30-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed the semantics of [v]snprintf(): If the buffer is not large enough,
the function shall nevertheless return the length of the string that would
be written, if the buffer were large enough.
Added a touch of C++ while doing that. :-)
* Fixed the instances in boot loader, kernel, and kernel modules where the
wrong semantics were expected. The majority of uses actually.


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


# 5d14311137a0216cb09d0965a3c5165e6dd17702 05-May-2009 Michael Lotz <mmlr@mlotz.ch>

When doing removal notifications for USB devices, report the hub after the
children. Otherwise a driver that builds up a device hierarchy could run into
trouble when the parent hub is removed before its child devices. Not that there
were any drivers that do so, but it just seems more correct.


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


# f81f8ddb90480e1a4529cdb780ab295596346ac9 05-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Fix search+replace error introduced with reworking debug output. This should
fix full/lowspeed devices behind high-speed hubs again.


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


# 621e8eeb9ef5cfc4ebe2985f627cf47de48315f6 25-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Fix usage of wrong port change values. The request numbers were compared with
the bitmap instead of the masks. Spotted by Mika Lindqvist (after 100 reboots),
thanks for tracking down such hard to spot errors!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29029 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


# a5243128424aab5d6f5cfebe965de0b1334fcee5 21-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Fix off-by-one error in port number which caused full- or lowspeed devices
behind highspeed hubs with multiple transaction translators not to work.
* The parent hub isn't necessarily the one providing the transaction translator
for a full- or lowspeed device. Therefore we need to inherit the hub/port
addresses to lower devices unless we are a highspeed hub that might be the
actual provider of the transaction translator. This logic error caused full-
and lowspeed devices not to work if they were behind a fullspeed hub that
itself was behind a highspeed hub.

This fixes bugs #1889 and #2501.

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


# 508dd5f91db9f11d5522b1050558c1a0ecc42726 21-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Output some more debug output in case of port reset failure.

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


# 519fbf77d397b5b604e7423f5c7fc8f9fdf37d35 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Make the maximum port count a define and set it to 16. OHCI officially
supports up to 15 ports and QEMUs OHCI emulation uses a port count of 10
for example.
* Update the hub code to remove the hardcoded 8 port limits.
* Some other code to enumerate the USB structure I had laying around
(available internally only, might be added as a public API some time).

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


# b04afa2413da6a05a6f2c424abe6cf6444180cd2 04-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Another tiny cut in stack load time: do not delay after setting the current
configuration of a root hub
* Cut down on number of retries to set the initial device address

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


# a93bd0c45232acd3e2038807255ab0427ecc1bca 01-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Cutting down on unnecessary per-controller delays when starting up the USB
stack. The root hubs do not really need a powerup delay and as they are not
used until all initialization is done, this gives plenty of time to stabilize
the power. Therefore remove the powerup delay for root hubs and reduce the
stabilization time to zero. Also remove the define for the first explore delay
as it is not used.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24727 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


# 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


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

* Moved around some initialization to avoid problems when deleting incompletely created objects
* Also move waiting for the first explore to run through out of the constructor to reduce delays
* Remove the old device when a new one is connected to the same port - this could happen when you very quickly un- and replug a device

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21042 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


# a8be7d1ea3297974cb80d1dfd700510375704c67 06-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

* Added some more debug output to the hub code
* Report and clear yet unhandled port changes in hubs
* Fixed the way devices that vanish on port reset are handled
* Added a status field to the memory allocator and check it creating it

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19732 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


# 90b9fb4fbc1a11c47080ee8e9194d32de6ed735c 23-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed notify cookie handling. There is not one cookie per device, but one per device/driver combination
* Fixed SetFeature/ClearFeature/GetStatus for interfaces by adding the respective interface number
* Added driver rescanning mechanism (taken from bin/rescan)

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


# 12cf623f5c41fb7a68a11f82d3bac2dcf9772694 16-Sep-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

unified callback parameter definition of size_t and uint32, now uses size_t


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


# dff0c634db8e3d8210c08419fa2795a355352714 15-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented transfer finishing in EHCI
* Implemented actual length calculation in EHCI
* Implemented bulk transfers in EHCI
* Implemented queue freeing in EHCI
* Added extended buffer pointers to the EHCI structs, necessary when the controller supports 64bit
* Fixed debug output and removed warnings due to wrong print format

Control and bulk transfers are now working nicely for EHCI. This means that I can now get pictures from my camera with USB 2.0 speed. Note though that many things still are unimplemented (isochronous transfers, split transactions, interrupt transfers, queue chaches per pipe, ...). But it's certainly a nice step forward :-).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18855 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


# 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


# 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


# 64f3c0650321a0951e337baccaf6db98baa5489c 16-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

Implemented a usb_ioctl to retrive the logical device name (like 0/0, 0/1/0 or 1/hub) that will be used by usb_raw to publish the according devfs entries.

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


# d83f3c1a45d231f5ec4e3c1127d5f44a9b54fb00 13-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed setting configurations (need to use the configuration_value instead of the index of course)
* Fixed reported power status of the UHCI Root Hub
* Added preservation of the SOF_MODIFY register when doing a global reset of the UHC
* Read out the actual length for outgoing transfers too
* Made actual length handling for transfers a bit safer and correct in respect to NULL packets
* Use short packet detect to handle short packets
* First step at implementing the hub interrupt

Since the devices are now configured correctly, some bulk transfers actually work. Also my hub now reports its status correctly.

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


# f1020a6c4914d769f910ae85158a8fb9c9c060f7 12-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Changed the Stack lock to a benaphore
* Removed some debug output from UHCI
* Added some debug output to the usb module instead ;)
* Rewrote the way new devices are attached and ports are handled (now more similar to FreeBSD)
* Corrected handling of port resets so that they should work on hubs too
* Cleaned up some headers

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18499 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


# 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


# 7ce4cf086694f494b20d3e2f1c7eda103aa5af63 30-May-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Summary: Merged with development branch (nielx)

Patches applied:

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-22
Update/add licence header


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7689 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


# 8b485af8749e8e3385cf0607eca2baa530ed5eef 13-Apr-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Summary: Continued work on hub initialisation
Keywords:

Patches applied:

* 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


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


# a8e39155919845b80f7a27ffbc279dc6e019a0a0 30-Dec-2003 Niels Sascha Reedijk <niels.reedijk@gmail.com>

*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-1
Implement basic Busmanager loader modules
*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-2
Continue shaping up some things
*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-3
Continued device initialisation
*
n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-4
Finalised the device initialisation


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