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

USB: Support physical-vector bulk requests.

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

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

All bus drivers tested and confirmed to still be working.

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


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


# 76ddb69a 13-Dec-2022 Jérôme Duval <jerome.duval@gmail.com>

usb_raw: abort transfers cleanly on kill, fix use-after-free

* aborted transfers will release the notify semaphore when the cancel is notified.
* the allocated buffer would be freed on return, while the usb stack eventually copied
data in the buffer in our back, leading to KDL crashes, because the freed buffer would
be right reallocated for some kernel team structures.
* regression introduced by hrev55806, the transfers didn't need to be cancelled before.

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


# e6ce95c5 10-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: register device nodes for hubs and devices

the device identifier is the USBID. no actual interface to be used by drivers.

Change-Id: I9fd1fdab0d02f1b82380c619b39bc3a12a9e2333
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5736
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: X512 <danger_mail@list.ru>
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>


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

usb: add an interface for usb controllers using the new driver API

Change-Id: I25f481c8a7c3e4aafa3080640ce156b9232eaf73
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5707
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>


# dd249016 17-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Check and set the Device object state appropriately.

The Device object gets an ID before it begins initializing, and
loses its ID after it fully finishes tearing down, so simply
verifying the Device object is non-NULL is not enough to verify
that we can use it. We need to call InitCheck() every time.

In Device itself, we should also unset fInitOK when beginning
teardown, so that anyone who still has a handle can no longer
use this Device object while teardown occurs (which, depending
on the number of pipes, pending transfers, etc. may take some
time.)

Fixes #14949 and almost certainly any other USB-related KDLs
in these codepaths.


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


# e31cac6e 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Implement usb_clear_stall kernel debugger command.

It constructs a clear feature request for the endpoint halt selector
and sends the request using debug transfers. Clearing a stall condition
can be done safely and has one nice side effect: it reinitializes the
data toggle to a known state. This command can therefore be used when
a pipe is possibly used from userland as well and the data toggle may
therefore be out of sync.


# 159aa93b 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Generalize logic for debug transfers used within KDL.

Pull debug transfer methods into the base BusManager class and
implement them for UHCI and EHCI. This makes it possible to have a
single debugger command installed by the USB stack instead of HCI
specific ones.


# 21c0d313 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Remove check for UHCI in get_usb_pipe_for_id kdl command.

The bus managers check that the pipe belongs to them in their
respective debugger commands.


# 578558b4 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


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


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

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


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


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

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


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


# 00918d55 19-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Check if we support debug transfers before returning a pipe for debugging. We
only support UHCI for now. In case transfers aren't possible we therefore don't
make PS/2 keyboards unusable in KDL.


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


# db9ff5bf 12-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Fix wrong preprocessor line.


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


# eb01fb72 08-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

* Add the kernel debugger extensions only for the haiku target.
* Acknowledge non-enabled interrupts in UHCI as done in EHCI as well.


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


# 7e1490e0 28-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

Introduce some extensions to the USB v3 module API that allow for device
enumeration (getting roothubs, enumerating child devices and detecting device
topology) and hub port management (resetting and disabling ports). These were
laying around for quite some time.

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


# eb6a1cbc 28-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

Fix previous commit. We obviously want the global stack variable to be set, we
just don't need the shared area.

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


# 48ab20fa 28-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Don't use the multiple modules workaround under Haiku. This code is only
needed on plain R5 and actually wouldn't work if the module would ever get
unloaded (or reloaded afterwards).
* Added comment explaining that above the concerning code.

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


# 017d539c 10-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

A few more things to get the USB stack working under BeOS again. We now have
KDEBUG on by default which causes benaphores to always use their semaphore.
Therefore when initing the benaphore with the inline compatibility function
and then using it using the lock.h provided inline would always cause a
deadlock and a hanging system under BeOS. Also we now (re-)define the
B_KERNEL_{READ|WRITE}_AREA defines for non Haiku targets to 0 apparently which
would probably also cause the stack to misbehave. Therefore they are now
just redefined (again) to plain B_{READ|WRITE}_AREA in BeOSCompatibility.h.
Change the inclusion order in some places so things work as expected.

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


# facc0035 09-Apr-2008 François Revol <revol@free.fr>

Fix building usb bus manager with TRACE on.


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


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

* Added SetAltInterface method which allows to set an alternate interface for the device
* Added InitEndpoint and ClearEndpoint to avoid code duplication
* Usual clean up


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


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

With plain R5 kernels, the usb module image is apparently loaded twice (once for each exported module), while for BONE kernels and up the module is only loaded once.
So the mechanism with the global variable did not work for R5 what caused two USB stacks and host controller drivers to be active concurrently which resulted in completely unpredictable results.
This kind-of-inelegant fix was all I could come up with, if someone has a better idea please send it this way.

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


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

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

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

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


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

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

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


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

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

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


# 6b0ee874 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

Accidently forgot to remove debug output define again.

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


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

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

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


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

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

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


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

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

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

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


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

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

No functional changes.

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


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

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

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


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

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

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

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


# 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


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

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

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

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


# 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


# 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


# 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


# 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


# e31cac6e5afe902f17dd76e174966515dfb7babb 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Implement usb_clear_stall kernel debugger command.

It constructs a clear feature request for the endpoint halt selector
and sends the request using debug transfers. Clearing a stall condition
can be done safely and has one nice side effect: it reinitializes the
data toggle to a known state. This command can therefore be used when
a pipe is possibly used from userland as well and the data toggle may
therefore be out of sync.


# 159aa93b31cb5d926ef4939a16419e7d02979b1c 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Generalize logic for debug transfers used within KDL.

Pull debug transfer methods into the base BusManager class and
implement them for UHCI and EHCI. This makes it possible to have a
single debugger command installed by the USB stack instead of HCI
specific ones.


# 21c0d3131d4c2b1022cd5014651bea5292a93aa0 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Remove check for UHCI in get_usb_pipe_for_id kdl command.

The bus managers check that the pipe belongs to them in their
respective debugger commands.


# 578558b439867f563d44d168a29223f76d6bb23e 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


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


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

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


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


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

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


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


# 00918d55dde50400c16e9d94889dfe258e137439 19-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Check if we support debug transfers before returning a pipe for debugging. We
only support UHCI for now. In case transfers aren't possible we therefore don't
make PS/2 keyboards unusable in KDL.


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


# db9ff5bfb836f12b09c15ef427ca744101b2ba39 12-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Fix wrong preprocessor line.


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


# eb01fb72f6d90bf6a083941ace087bdd6803a516 08-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

* Add the kernel debugger extensions only for the haiku target.
* Acknowledge non-enabled interrupts in UHCI as done in EHCI as well.


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


# 7e1490e0ad111a858589c95cc80bdde85424e530 28-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

Introduce some extensions to the USB v3 module API that allow for device
enumeration (getting roothubs, enumerating child devices and detecting device
topology) and hub port management (resetting and disabling ports). These were
laying around for quite some time.

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


# eb6a1cbc4c32d54dd1981eb186dbcd6f51d37487 28-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

Fix previous commit. We obviously want the global stack variable to be set, we
just don't need the shared area.

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


# 48ab20fa34d2e487377735440c107c911dbb8192 28-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Don't use the multiple modules workaround under Haiku. This code is only
needed on plain R5 and actually wouldn't work if the module would ever get
unloaded (or reloaded afterwards).
* Added comment explaining that above the concerning code.

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


# 017d539c2a68107b0f1575ae7c2f0fdd4ab294f1 10-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

A few more things to get the USB stack working under BeOS again. We now have
KDEBUG on by default which causes benaphores to always use their semaphore.
Therefore when initing the benaphore with the inline compatibility function
and then using it using the lock.h provided inline would always cause a
deadlock and a hanging system under BeOS. Also we now (re-)define the
B_KERNEL_{READ|WRITE}_AREA defines for non Haiku targets to 0 apparently which
would probably also cause the stack to misbehave. Therefore they are now
just redefined (again) to plain B_{READ|WRITE}_AREA in BeOSCompatibility.h.
Change the inclusion order in some places so things work as expected.

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


# facc00359bfd6774173743f6f2cb275ceef795cc 09-Apr-2008 François Revol <revol@free.fr>

Fix building usb bus manager with TRACE on.


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


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

* Added SetAltInterface method which allows to set an alternate interface for the device
* Added InitEndpoint and ClearEndpoint to avoid code duplication
* Usual clean up


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


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

With plain R5 kernels, the usb module image is apparently loaded twice (once for each exported module), while for BONE kernels and up the module is only loaded once.
So the mechanism with the global variable did not work for R5 what caused two USB stacks and host controller drivers to be active concurrently which resulted in completely unpredictable results.
This kind-of-inelegant fix was all I could come up with, if someone has a better idea please send it this way.

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


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

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

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

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


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

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

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


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

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

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


# 6b0ee87455c5355f6b498e511668638ed11e5e56 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

Accidently forgot to remove debug output define again.

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


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

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

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


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

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

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


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

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

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

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


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

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

No functional changes.

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


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

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

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


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

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

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

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


# 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


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

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

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

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


# 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


# 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


# 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


# 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