History log of /haiku/src/add-ons/kernel/bus_managers/usb/Stack.cpp
Revision Date Author Comments
# 0450e7b8 31-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Acquire the device manager lock before Explore.

We must do this to prevent lock order inversion: when busses are
initialized, they are started by the (locked) device manager, and
then acquire the explore lock. We must do the same in Explore itself,
for when called by the explore thread, we would otherwise first acquire
the explore lock, then (when publishing new nodes) acquire the device lock.

Should fix #18421 and #18393.


# bd904169 31-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Do not wait for first explore in Stack constructor.

Following various refactors, at the point the Stack object is created,
there are no bus managers yet, so exploring will find nothing.


# 7c18d58f 27-May-2023 Jérôme Duval <jerome.duval@gmail.com>

usb: explore on BusManager::Start()

registering new devices requires the device_manager lock. The explore thread would wait
that the initial device scan is over to register devices.

Change-Id: I46529ab0926f349023f06ada3411979c0950dfcf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6475
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 3f7abfc9 03-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: trigger the explore thread when a bus is added

this helps to find the boot disk, otherwise it can happen that the usb disk driver
misses a bus to explore.

Change-Id: I6983b42cf66f946b4ba9763ec09b6e4a848f2e9a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5712
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 547ddb90 01-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

uhci: switch to the new driver API

Change-Id: Ifc95a32066d0089d3fd41e489604d58815c074af
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5711
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 0ed2fb8d 01-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

ohci: switch to the new driver API

Change-Id: I065743b5ced8b75f9576b62421525824698a2245
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5710
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 15ebede2 01-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

ehci: switch to the new driver API

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


# 3d0c08ef 28-Sep-2022 Jérôme Duval <jerome.duval@gmail.com>

xhci: switch to the new driver API

keep the stack loaded when no bus is found

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


# 956f4507 22-May-2022 Trung Nguyen <trungnt282910@gmail.com>

kernel/vm: Remove default kernel read/write flags

`fix_protection` will not apply `B_KERNEL_READ_AREA` and
`B_KERNEL_WRITE_AREA` by default.

Kernel drivers that directly call `create_area` or `create_area_etc`
and do not pass any protection flags have been updated to
apply `B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA` instead.

Bug: #17751
Change-Id: I43e7ee6b5396e0309cdcff750e28262942c6d01c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5330
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>


# ad56cbbb 16-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Add asserts under KDEBUG that IDs being put have no remaining children.

Change-Id: I100828d2724d65ab0841e1262c7db7e144b56aab
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4441


# 16414ce4 04-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Add assert that GetObjectNoLock is only called from the debugger.


# 549e9a3c 04-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Adjust comment about stack drivers for clarity.

No code changes.


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


# 21c87a5d 09-Sep-2018 Jérôme Duval <jerome.duval@gmail.com>

drivers: remove some non-haiku support code.

Change-Id: Ic55bb4832adabeb807f763c87ad938e74fb3a97d
Reviewed-on: https://review.haiku-os.org/520
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@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>


# 0e3e70a0 24-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

USB Stack: enable xHCI module lookup.

* also increase PhysicalMemoryAllocator max to 128KB instead of 16KB.
This translates in a 8MB-sized USB Stack Allocator area.
* tested OK on a Fresco Logic FL1009 USB 3.0 Host Controller but KO on a
Nec Corporation uPD720200 USB 3.0 Host Controller.
* tested a synched copy to a BFS partition on a Lacie USB3 disk takes about
8 seconds for 350MB versus 11 seconds on eHCI.


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

Poll more frequently for the first explore.

This reduces needless waiting for the special case of the polled and
synchronous first explore.


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


# 1579900f 20-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Fix uninitialized fAllocator member. In the error case the destructor could
crash trying to delete the not created allocator. CID 9562.


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


# 9fb2d737 23-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced B_32_BIT_MEMORY by B_32_BIT_FULL_LOCK and B_32_BIT_CONTIGUOUS, so
the constraint can be expressed more precisely. ATM B_32_BIT_FULL_LOCK is
implemented as B_32_BIT_CONTIGUOUS when B_HAIKU_PHYSICAL_BITS > 32, though.


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


# 64cf56f5 21-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Force allocation of physical memory < 4 GB until the related TODOs are fixed.


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


# 64d79eff 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


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


# 38fc536e 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Some more constness.


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


# 6eba0636 22-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Added simplified possibility to schedule UHCI transfers from within KDL.
* Added debugger commands to resolve usb_ids to pipes.
* Adjusted the physical memory allocator to be usable in a slimmed down mode
when running inside the kernel debugger.
* Implemented USB keyboard support for KDL through a kernel debugger add-on.
* Added kgetc() and made use of it where previously individual methods were used
to ensure that reading characters always goes through the kernel debugger
add-ons and the other methods.

This has some preconditions to meet though:
1) The keyboard must be in the boot protocol (currently the case but needs to
be revisited once we have a full usb_hid).
2) The keyboard must be attached to a UHCI root port (i.e. not use EHCI or OHCI,
also not through hubs unless those are USB 1.1).
3) the usb_hid driver has to be opened for this to work. This means that for the
time between initializing USB and when usb_hid is opened by the input_server
there is no keyboard support.

Also note that this has no way of detecting hot-plug, meaning that you can't
re-attach your USB keyboard from the hub to the root port once in KDL.

On the bright side of things, since this is a non-destructive mechanism it is
possible to enter and leave KDL without loosing the USB state.

Tested OK in QEMU, not tested on real hardware yet, will see in a few minutes.


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


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

Tiny cleanup.

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


# 8395deba 12-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* CID 7: The fObjectArray that holds the usb_id to object association was never
freed.
* Also the allocation of said array was not checked.


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


# 2f2ba71f 22-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* The USB bus manager was leaking unused bus modules.


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


# b0884f0c 07-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a ton of wrong usages of B_CONTIGUOUS + B_FULL_LOCK.
* The use of B_{READ|WRITE}_AREA throughout the drivers is surely alarming.
Defining these flags means that *every user* application can access these
buffers read/write, it becomes visible in userspace like any other memory
(just shared among all apps). I would like to ask each driver maintainer
to see if that is really wished here. If you only need one app to be able
to access it, cloning the area would be more appropriate.
* I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of times. This
is almost completely useless for most usages, as it tries to align the
virtual to a multiple of the size of the area. It just makes the allocation
more likely to fail. Please only use where appropriate, and please review
your code.
* Minor cleanup.


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


# 2b07b8e0 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


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


# 349a9cfc 12-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Use a list of host controller modules instead of using open_module_list() and
read_next_module_name(). This is ugly and less flexible but it allows us to
explicitly force an initialization order. As detailed by the added comment
there seem to be controllers/BIOSes that require the EHCI controller to be
initialized after the companion host controller or else they refuse to publish
any high speed devices. This was the case for bug #1236 and my laptop when
legacy emulation is enabled and any device was plugged in at boot. This change
fixed the problem for me and hopefully closes bug #1236 too.

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


# 8024db25 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Change just host_controller_info to usb_host_controller_info for the sake of
clearity as suggested by Philippe Houdoin once and brought to my attention by
Slavatore. As this definition is completely private to the USB stack it would
not have caused any conflicts though.

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


# 7846435e 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Use a more generous snooze time when waiting for the initial explore to complete.

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


# 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


# 727b80e3 19-Apr-2007 Waldemar Kornewald <wkornewald@nowhere.fake>

Fixed a memory leak.


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


# 4e9efbcf 29-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Moved and unified the explore threads from the BusManager to the Stack
Now there is only one explore thread instead of one per BusManager.

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


# 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


# 9e857d24 25-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Adding skeleton EHCI driver. Some parts filled from the specs and the UHCI driver.
* Corrected some errors I found while reading UHCI.

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


# 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


# 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


# 5430d867 27-May-2006 Michael Lotz <mmlr@mlotz.ch>

The buffersize variable was not reset after the loop which caused the UHCI bus driver not to be found. Changed debug output a bit.

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


# 67c3d9eb 11-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed building of the UHCI and OHCI modules [reported by AndyBe].


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


# bb6583ad 31-May-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Patches applied:

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-23
Revert to older chunk allocation mechanism: this one works


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


# 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


# 1501c2bf 12-Aug-2003 Niels Sascha Reedijk <niels.reedijk@gmail.com>

This is just an outline of the USB stack: what it is going to look like. It is definately not
ready for testing. Also the documentation is far from complete (it's in it's early phases).
Unfortunately I don't have enough experience in hardware programming to prototype
it first, so I'll be testing the things that I design in the document.


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


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


# 0e3e70a00cff83bca83e6f411a1e77756b9575ac 24-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

USB Stack: enable xHCI module lookup.

* also increase PhysicalMemoryAllocator max to 128KB instead of 16KB.
This translates in a 8MB-sized USB Stack Allocator area.
* tested OK on a Fresco Logic FL1009 USB 3.0 Host Controller but KO on a
Nec Corporation uPD720200 USB 3.0 Host Controller.
* tested a synched copy to a BFS partition on a Lacie USB3 disk takes about
8 seconds for 350MB versus 11 seconds on eHCI.


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

Poll more frequently for the first explore.

This reduces needless waiting for the special case of the polled and
synchronous first explore.


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


# 1579900f55340f686bcac47c223740d5bde655cd 20-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Fix uninitialized fAllocator member. In the error case the destructor could
crash trying to delete the not created allocator. CID 9562.


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


# 9fb2d73772382ea2ccfb62e912f9bfb9c39ac26d 23-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced B_32_BIT_MEMORY by B_32_BIT_FULL_LOCK and B_32_BIT_CONTIGUOUS, so
the constraint can be expressed more precisely. ATM B_32_BIT_FULL_LOCK is
implemented as B_32_BIT_CONTIGUOUS when B_HAIKU_PHYSICAL_BITS > 32, though.


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


# 64cf56f5cd6a85321651e58ac0bf8d15f8007cf8 21-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Force allocation of physical memory < 4 GB until the related TODOs are fixed.


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


# 64d79eff7290437d24b1a420537c3ed5c144ab96 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


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


# 38fc536e0525ec97d60d4bdd29dbe68e4b17ec13 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Some more constness.


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


# 6eba063647cc4ff5aa863e1b5dc5093c22a3acb0 22-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Added simplified possibility to schedule UHCI transfers from within KDL.
* Added debugger commands to resolve usb_ids to pipes.
* Adjusted the physical memory allocator to be usable in a slimmed down mode
when running inside the kernel debugger.
* Implemented USB keyboard support for KDL through a kernel debugger add-on.
* Added kgetc() and made use of it where previously individual methods were used
to ensure that reading characters always goes through the kernel debugger
add-ons and the other methods.

This has some preconditions to meet though:
1) The keyboard must be in the boot protocol (currently the case but needs to
be revisited once we have a full usb_hid).
2) The keyboard must be attached to a UHCI root port (i.e. not use EHCI or OHCI,
also not through hubs unless those are USB 1.1).
3) the usb_hid driver has to be opened for this to work. This means that for the
time between initializing USB and when usb_hid is opened by the input_server
there is no keyboard support.

Also note that this has no way of detecting hot-plug, meaning that you can't
re-attach your USB keyboard from the hub to the root port once in KDL.

On the bright side of things, since this is a non-destructive mechanism it is
possible to enter and leave KDL without loosing the USB state.

Tested OK in QEMU, not tested on real hardware yet, will see in a few minutes.


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


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

Tiny cleanup.

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


# 8395debafafa8f72671e74d97812a43e420e11c9 12-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* CID 7: The fObjectArray that holds the usb_id to object association was never
freed.
* Also the allocation of said array was not checked.


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


# 2f2ba71fab4d315ff15b304f3d51e743eda4c828 22-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* The USB bus manager was leaking unused bus modules.


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


# b0884f0cb812cdaf8035e6028f69dcf0d7721953 07-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a ton of wrong usages of B_CONTIGUOUS + B_FULL_LOCK.
* The use of B_{READ|WRITE}_AREA throughout the drivers is surely alarming.
Defining these flags means that *every user* application can access these
buffers read/write, it becomes visible in userspace like any other memory
(just shared among all apps). I would like to ask each driver maintainer
to see if that is really wished here. If you only need one app to be able
to access it, cloning the area would be more appropriate.
* I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of times. This
is almost completely useless for most usages, as it tries to align the
virtual to a multiple of the size of the area. It just makes the allocation
more likely to fail. Please only use where appropriate, and please review
your code.
* Minor cleanup.


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


# 2b07b8e0f1a7f1e76f31db24a21a42cbb01d7b9c 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


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


# 349a9cfc0f167b7290b22def46f7ef353cf1d036 12-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Use a list of host controller modules instead of using open_module_list() and
read_next_module_name(). This is ugly and less flexible but it allows us to
explicitly force an initialization order. As detailed by the added comment
there seem to be controllers/BIOSes that require the EHCI controller to be
initialized after the companion host controller or else they refuse to publish
any high speed devices. This was the case for bug #1236 and my laptop when
legacy emulation is enabled and any device was plugged in at boot. This change
fixed the problem for me and hopefully closes bug #1236 too.

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


# 8024db25a8b9a380d73fd0198f4203f514f4b5dd 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Change just host_controller_info to usb_host_controller_info for the sake of
clearity as suggested by Philippe Houdoin once and brought to my attention by
Slavatore. As this definition is completely private to the USB stack it would
not have caused any conflicts though.

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


# 7846435ed2accda198ac92db03f34aafde1b8089 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Use a more generous snooze time when waiting for the initial explore to complete.

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


# 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


# 727b80e38e903258589bc1b77dd84a68052d519a 19-Apr-2007 Waldemar Kornewald <wkornewald@nowhere.fake>

Fixed a memory leak.


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


# 4e9efbcf24a0d5b72efbbaec53e2ebe5d7d5d1a9 29-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Moved and unified the explore threads from the BusManager to the Stack
Now there is only one explore thread instead of one per BusManager.

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


# 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


# 9e857d24ca41743874f6b3c08bb0c35f53df5763 25-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Adding skeleton EHCI driver. Some parts filled from the specs and the UHCI driver.
* Corrected some errors I found while reading UHCI.

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


# 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


# 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


# 5430d867b4ca74c0bd1fe2b55da9a00328bf6b76 27-May-2006 Michael Lotz <mmlr@mlotz.ch>

The buffersize variable was not reset after the loop which caused the UHCI bus driver not to be found. Changed debug output a bit.

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


# 67c3d9ebe54b5344d58f06011314440f214528bd 11-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed building of the UHCI and OHCI modules [reported by AndyBe].


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


# bb6583ad28a0964796a884da74047ae19f9acaf1 31-May-2004 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Patches applied:

* n.reedijk@planet.nl--nielx-2003/usb-busmanager--development--0.1--patch-23
Revert to older chunk allocation mechanism: this one works


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


# 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


# 1501c2bf3ec93a4548eba2168d29c0bb68d31589 12-Aug-2003 Niels Sascha Reedijk <niels.reedijk@gmail.com>

This is just an outline of the USB stack: what it is going to look like. It is definately not
ready for testing. Also the documentation is far from complete (it's in it's early phases).
Unfortunately I don't have enough experience in hardware programming to prototype
it first, so I'll be testing the things that I design in the document.


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