History log of /haiku/src/add-ons/kernel/busses/usb/ohci.cpp
Revision Date Author Comments
# 629f071b 27-Feb-2024 X512 <danger_mail@list.ru>

pci: extend MSI interrupt vector number to 32 bits

Also increase MSI message data size to 32 bits according to PCIe spec.

Remove 0xff check for MSI interrupts because it is potentially valid
interrupt vector number. Reject 0xff only for legacy pin interrupts.

- MSI-X supports up to 2048 interrupts per device that do not fit to
`uint8`.

- Non-x86 systems may use separate interrupt vector ranges for
hard-wired interrupts and MSI interrupts so `uint8` is not enough to
represent all of them.

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


# be3ce6d7 31-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

USB: Make "buffer error" reporting consistent.

This error means that the controller failed to read or write data
to/from system memory fast enough. As a result, we should report it
as READ_ERROR/WRITE_ERROR, rather than something that sounds like
an error with the device itself.

Then, make BABBLE reporting consistent: this is a data overrun/underrun
of the device itself, not the buffers passed to the controller.
This then leaves B_DEV_FIFO_OVERRUN/UNDERRUN unused, and thus usable
for reporting ring overrun/underrun on isochronous transfers.

The API documentation already described DATA_OVERRUN/UNDERRUN basically
like they were babble errors, while FIFO_OVERRUN/UNDERRUN are
currently described as "internal errors" at present. No driver actually
checked for these.


# d2f65e76 29-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

OHCI: Remove unused variable following previous commit.


# 8c458fc4 29-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

USB: Initialize packet descriptors inside the stack.

Allows deletion of generic code from bus drivers.


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

USB: Support physical-vector bulk requests.

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

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

All bus drivers tested and confirmed to still be working.

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


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

USB: Use generic_io_vec in Transfer.

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

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


# 3b91d73b 16-Dec-2022 X512 <danger_mail@list.ru>

bus & drivers: drop PCI_x86

Change-Id: I494deaf24a4793a5e0fe9fa46ecdce32f65e616a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6226
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 215b685f 11-Dec-2022 X512 <danger_mail@list.ru>

kernel: Drop non-standard GNU inline assignment syntax

* We needed this previously due to our gcc2 compiled kernel.
* Now that our kernel is always latest gcc, we can move to the
c++20 syntax for inline assignment.
* Improves compatibility with clang, less GNU-specific stuff

Change-Id: Ib7272a0a52554a31e9a0e788fd3f031db9049795
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5898
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# d2875e7b 16-Nov-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: fix references on the module B_PCI_X86_MODULE_NAME

the dependency is optional, only the device modules depend on it.
should fix #18075

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


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


# 6652606f 05-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: remove debug leftover

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


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


# ffc83aa2 28-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB bus drivers: Add missing iterator increments.

Should fix boot hang regressions introduced in hrev55455
in the fix for #17275.


# ae61e1b7 27-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB bus drivers: Return error when combining other transfers with a fragmented one.

The drivers do not support this properly at present, they would
run the other transfers interspersed with fragments from the fragemented one,
which is obviously the wrong thing to do.

No USB device drivers seem to do this at present (it would cause data
corruption if they had.)

Fixes #17275.


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

USB: Rename Transfer::VectorLength to Transfer::FragmentLength.

It did not return the length of the vectors, but only the current
fragment's worth of vectors. It also modified the fFragmented flag,
which really should have been set in SetVectors in the first place.

As everything seemed to call IsFragmented after VectorLength,
this is not a behavioral change.


# e8b2085d 18-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Print the PCI ID of the device with an invalid IRQ.


# 6be54385 13-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Handle getting/putting the PCI modules properly.

Previously it was possible that we put() them twice, leading to
assert-failure panics as their ref-counts would go below 0.
Now we get() them once for every bus object that we create, as
the destructors put() them.

Should fix the panic in #15004.


# 67b05100 12-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Don't reject devices with "invalid" IRQs immediately.

We may be able to allocate an MSI for them. This was done for XHCI
already in hrev52742.

Probably fixes #15004.


# 5c6d92d7 12-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Move ::AddTo to be above the class constructors.

It is called before them (and is responsible for calling them),
so having it in the middle of the file does not make a lot of sense.

Already done for XHCI. Only one functional change -- removing the
set_dprintf_enabled call. Drivers probably shouldn't spuriously
re-enable that if it was specifically disabled.


# a182f193 19-Feb-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Properly assign IDs to USB Bus Managers (HCI drivers).

Previously they would just get -1, as the BusManager class
would request their ID before they had been added to the Stack.
Now we add them to the stack inside ::Start(), rather than letting
the individual drivers do that just after ::Start(), and then assign
the ID there directly.


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


# 05a859eb 14-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

usb: map registers or allocate area for the kernel only.


# 3218cf3b 23-Apr-2016 Alexander von Gluck IV <kallisti5@unixzen.com>

ohci: Fix x86_64 usb tracing


# 291e40c3 04-Aug-2013 Siarzhuk Zharski <zharik@gmx.li>

USB OHCI: Fix finalizing of STALL-ed control request transfers

In case control transfer is finished with STALL answer from device only
the setup TD is retired into the Done Queue but other TDs (data and
status) are left in the ED queue. HC set the endpoint halted - so we
process such endpoint regardless of it's non-empty queue.

PS: cleanup some trailing spaces.


# cf58476c 25-May-2013 Siarzhuk Zharski <zharik@gmx.li>

USB OHCI: Support for isochronous transfers

Finishing and refactoring the draft, initially implemented during April-May 2012

NOTE: startingFrameNumber returned to device contains the number of the
next free frame right after the last packed of submitted data. For more
details please Look into corresponding [haiku-development] discussion
started at 03 Jul 2013.

Partially fixes #1045.


# b3dbb4d2 30-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

OHCI USB: disable MSI on destruction

* also remove interrupt handler and put the PCI x86 module.


# 3b98be3c 04-Oct-2012 Jürgen Wall <fakeEmail@fakesite.fake>

USB OHCI: Fix ownership handover from SMM to OS.

* Disabling all interrupts prior to ownership handover from SMM to OS
can prevent propper OHCI and PS/2 functionality as described in
#8987 and #8984. In that case SMM does not respond to the ownership
change request. On the other hand not disabling the interrupts can
lead to interrupt storms (discussed in #8085) since no interrupt
handler is installed at that moment. As suggested by mmlr this patch
attempts to address both issues by keeping the ownership change
request interrupt enabled.

* Removed an unnecessary reset upon non-responding SMM for now,
since we reset a few lines later anyway and added TODOs respectively.
That should safe a bit boot time.

Signed-off-by: Michael Lotz <mmlr@mlotz.ch>


# a4bca811 15-Aug-2012 Michael Lotz <mmlr@mlotz.ch>

Add MSI support to OHCI.

It looks like VirtualBox assumes MSIs when emulating a 64bit system so
this gets OHCI working there. Shouldn't harm if it's used anywhere else
either.


# 2b883e19 06-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fix compilation of OHCI on x86.

Fixes were needed to go with the USB stack changes. Haven't tested it
yet because I don't have a a machine with OHCI, but I doubt there
will be any problems.


# c4650933 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Disable interrupts in OHCI before doing BIOS handover. Shouldn't matter much
but maybe it helps on some chipsets to avoid interrupt storms during handover.
* Remove comments that aren't true anymore.


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


# d7411ad2 07-Apr-2011 Jérôme Duval <korli@users.berlios.de>

added traces for unimplemented isochronous transfers for ehci and ohci


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


# 1393394b 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

We need to guarantee that when cancel returns that the callback won't be called
anymore. It could happen that the transfer was already in the process of being
finished, so wasn't in the list of pending transfers anymore. Cancel would then
return even though the callback wasn't called yet. This could lead to a callback
being called after a driver was already unloaded (even after it cleaned up the
pipes it used).


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


# 1dd6c50c 14-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

When submitting transfers there is a race condition between adding the pending
transfer to the transfer list and scheduling the transfer descriptors on the
controller by switching the endpoint tail. Since we only check that the endpoint
head is equal to the endpoint tail to conclude that there are no active
transfers, we need to ensure that we don't accidently do that check before the
transfer descriptors are scheduled. Otherwise we could happen to processed a not
yet started transfer and finishing it before an actual transfer has taken place.
This would then lead to 0 byte transfers and toggle mismatches. To fix this we
now protect the transfer addition and tail switching as well as the check in the
finisher with a per-endpoint mutex. Note that we allocate the lock on the heap
and only store the pointer in the endpoint structure as this one is allocated
from the precious physical memory pool. Could fix #4067.
Also switched the Jamfile to UsePrivateKernelHeaders (for the MutexLocker) and
removed BeOS compatibility.


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


# 12f58463 25-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Fix subtle but important error in transfer length calculation. That calculation
does calculate the remaining bytes, not the transferred ones, so obviously that
number has to be subtracted from the expected buffer size! Albeit severe, this
wasn't hit that often, because this calculation will only be used when the
transferred size doesn't match the handed in buffer size exactly. So things like
HID or mass storage, that mostly know the exact transfer size weren't affected.
But it could very well explain #4101 where the size isn't previously know.


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


# 9dbe55eb 20-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Fix typo.


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


# c265fd23 20-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

We cannot use the condition codes to determine if a transfer descriptor is
processed. The controller may initialize it to any value when starting to
process the descriptor. If a controller did that it was possible that we thought
a transfer was already done even if it actually just started. Transfers would
then return that weren't processed, returning uninitialized buffers.
Instead of relying on the condition codes we now check that the head and tail
pointers are the same. This guarantees that all transfer descriptors of the
endpoint at hand are completed.
Reverted r32534 again as this one fixes the problem for real. The same things
that were mentioned there could happen here essentially, so in the worst case
the device or controller could stall because of freeing in-use structures.
Fixes #4067.


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


# 840cdc9e 20-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

When adding a transfer, the current tail descriptor of the endpoint will be
reused and overwritten by the first descriptor of the new transfer and the first
descriptor will become the new tail. We anticipate this situation in
_AddPendingTransfer() and set the first_descriptor of the transfer data to the
tail already. Since the tail was pretty much cleared to zero, this introduced
a race condition. After adding the pending transfer it can already be found
in the finisher thread. If this happened before actually switching the tail
and first descriptor it would find a descriptor with a condition of 0, meaning
"No Error" and would process the transfer incorrectly. Depending on the count
of descriptors and the timing of the switch taking place this could have
resulted in aborted transfers with actual length 0 or with the correct actual
length but invalid data. In the very worst case it could have freed things still
in use by the controller, resulting in all sorts of device errors. Sadly it
doesn't fix #4067.


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


# 5f92e39f 19-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

That's actually not how it works. OHCI does the dirty work of splitting up the
transfer descriptors into individual packets. The descriptors are more a
logical thing. As such we do not generate one descriptor per packet but one
for each block of two pages at max. Therefore we only set the initial toggle bit
to the one we stored on the first descriptor and let OHCI use the carry bit for
subsequet descriptors. That error would only be visible on transfers above two
pages in size though.


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


# b0a2e9e7 19-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Even though the specs say the toggle carry field contains the value of the last
retired descriptor, it actually contains the value that is to be used next.
Confirmed that by cross-referencing FreeBSD.


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


# abe8e8a2 18-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

A try at actual data toggle handling. Since we do not properly ensure that the
toggle carry stays valid, we better make sure we set it correctly. Additionally
even if the toggle carry wasn't clobbered, there are conditions the toggle is
reset without the controller being able to notice (as in clearing a halt state).
Since I don't have any OHCI hardware this is untested, but should fix bug #4067
if correct.


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


# 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


# 2fc7e292 19-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

When calculating the actual length for requests, we don't want to include the
8 byte request header. It was included in the case of outgoing request
transfers before. In fact we always just want the length of the data phase,
which for non-requests just happens to be the whole transfer.

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


# 1751250a 12-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Remove disabling and clearing interrupts again as it doesn't turn out to be a problem.

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


# 97403a77 10-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

* Fix the check after waiting for owner change to happen and don't reset if the
handover indeed worked. Doesn't really matter though, as we reset anyway,
just not twice in the success case.
* Disable all interrupts and clear any pending active interrupts just after
taking over the controller. This might fix bug #2361.
* Also trace output when the ownership change is successful.
* Don't disable interrupts during reset.

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


# 4ca87670 08-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

When canceling transfers, do not call the callbacks with the lock held. This
prevents deadlocks in cases where a new transfer is scheduled from within the
cancel callback. This is an edge case, as generally you don't want to schedule
anything when explicitly canceling transfers, but there are a valid use cases
when you cancel because of a timeout and then have to reset the device for
example. Note that this hides bug #2353, where the cancel case is probably
not handled correctly.

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


# 1c8de858 01-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added optional spinlock contention measurement feature. Enabled when
B_DEBUG_SPINLOCK_CONTENTION is defined to 1. It typedefs spinlock to a
structure (thus breaking BeOS binary compatibility), containing a
counter which is incremented whenever a thread has to wait for the
spinlock.
* Added macros for spinlock initialization and access and changed
code using spinlocks accordingly. This breaks compilation for BeOS --
the macros should be defined in the respective compatibility wrappers.
* Added generic syscall to get the spinlock counters for the thread and
the team spinlocks.


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


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

Unconditionally report initialization success for OHCI too.

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


# 307fe93f 20-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Disable the root hub change interrupt when it gets triggered. As the change
status stays on until the port is reset, this causes the interrupt to be
constantly retriggered on some controllers.
* Added TODO that we need to reenable it once we want to take advantage of
status change notifications instead of polling. It should be reenabled when
clearing roothub status changes in ClearPortFeature().

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


# 9cc4091e 20-May-2008 Michael Lotz <mmlr@mlotz.ch>

Enable interrupts only after installing the interrupt handler.

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


# 5b03912b 19-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Correct removal of failed transfers by applying the address mask. As the head
pointer also contains the toggle carry and the halt bit (which was obviously
always set as the endpoint had an error) the address comparison failed and
the head was dead in the water with all further transfers timing out until
a subsequet cancel cleaned the mess up again.
* Add the OHCI host controller driver to the image as it should now be fully
functional except for isochronous transfers.

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


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

* Implement removal of failed transfers. The head pointer will be moved past
the failed transfer if the transfer in question is found to be the offending
one. Probably not quite enough and still untested.

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


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

* Build the interrupt tree the same (imperfect) way as in EHCI to conserve
on resources but still satisfy the scheduling policy. This works well, but
effectifly limits the bandwidth available as the interrupts aren't spread
across different frames.
* Implement finding the interrupt endpoint head for a certain interval.
* Deactivate endpoints that are going away until removing them is implemented.
* Allow short packets for all data phases.
* Disable tracing by default.

There you go, interrupt transfers should work as well. Should enable mice,
keyboards, hubs and other devices that use interrupt pipes. Note that it's
still easily possible that a single failed request will hang an endpoint and
prevent a device from working.

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


# 016ce5dd 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Handle the data == first and last == first case as this can occure for
single td bulk transfers.
* Implement SubmitTransfer() for bulk transfers (interrupts will use the exact
same code path, but as their endpoints aren't yet setup, interrupt transfers
won't work).
* Handle the cancel case when finishing transfers. The descriptors of the
canceled transfers cannot be accessed by the controller so they can be freed.

Bulk transfers should work now, so devices only using control and bulk transfers
should too (anything using usb_disk for example). Note though that a transfer
error will cause the whole thing to fail miserably as the error case is not
yet handled correctly (failed descriptors aren't removed from the endpoint).
Therefore I suggest not testing with the memory stick with that important
presentation you haven't stored anywhere else...

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


# 408a8ff3 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Completely rework how transfer finishing is implemented. It is now using
pretty much the same strategy as UHCI. This does not leverage the done queue
the hardware provides us, but as it saves a lot of other overhead and allows
the structures to be smaller I think it is overall worth it.
* Removed now unnecessary stuff from the transfer descriptor struct.
* Directly acknowledge the done head interrupt as we do not use it either.
* Activate control endpoints by removing the skip bit when a transfer is scheduled.
* Correct the way the first descriptor is determined (the current tail becomes
the first descriptor while the current first descriptor becomes the tail).
* Remove the head_logical_descriptor field from the endpoint structure, as this
would simply get out of sync with the first td with no real way of updating.
* Stub out RemoveTransferFromEndpoint() as this needs reworking.
* Correct CreateDescriptorChain() signature and implement the method.
* Add ReadDescriptorChain() and ReadActualLength() to process finished transfers.
* Prepare for actual data transfers by renaming/regrouping transfer types.
* Fully clear out the new tail when switching (for the sake of it)
* Add some helpers and definitions to the hardware header.
* Add debugging facilities.

With all this transfers can now actually be scheduled and they are processed
when done. This brings control transfers to a usable state so setting the
device address and reading out/setting the configuration works. That means you
can now view your device using usb_dev_info, but since any other transfer type
besides control transfers isn't implemented yet the device will most probably
not yet do anything useful.

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


# 87fe2972 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

Correctly clear an endpoint on cancel. Adjusted some comments/output.

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


# 0439bcbb 17-May-2008 Michael Lotz <mmlr@mlotz.ch>

Use a dedicated endpoint lock for endpoint manipulation. Fixes the guaranteed
deadlock with the BusManager on setup of the default pipes (for addressing).

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


# a9d7e87d 17-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Implement "tail switching" so that a new transfer descriptor chain can be
appended to an endpoint descriptor without locking/disabling the endpoint.
* Correct the direction of the data phase of a control transfer.
* Some minor cleanup.

Control requests without data phase (set address for example) might actually
work now, but this is still untested.

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


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

* Complete the roothub get/set/clear port feature functions
* Reorder to match the usual order of the states/commands
* Fix some debug output and make it more informative

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


# 812dd254 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

Acknowledge OHCI interrupts.

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


# 20bbb1bf 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Make the operational register memory a uint8 * instead of a uint32 * so the
driver has at least a chance of working (it previously always used wrong
offsets for register access).
* Remove the hash approach for now (I'm going to explore a few other ways of
doing that first).
* Reorder some stuff and check for errors in some more places.
* More cleanup (mostly whitespace again).

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


# fd1e6f2b 16-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Getting familiar with the existing code
* Cleanup (whitespace, nameing, code style)
* Move around methods so they match the header order
* Fix some obvious stuff
* Initialize all members
* Sync roothub code (this will be reworked to a common roothub)
* Only minor functional changes (to the worse for now)

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


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

Fix building usb busses with tracing on.


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


# de1ecdaf 25-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Added necessary dummy descriptor to every endpoint created
* Implemented _RemoveTransferFromEndpoint
* Reworked _AppendChainDescriptorsToEndpoint as now every endpoint has (must have) a dummy descriptor



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


# 555d13dc 25-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented private method _AppendChainDescriptorsToEndpoint in order to avoid code duplication (lock needs to be added)
* Fixed _SubmitControlRequest in order to use _AppendChainDescriptorsToEndpoint


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


# 5f061e0b 24-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* More work on the finisher thread
* Reworked SubmitTrasfer method
* Implemented CancelQueuedTransfers
* Minor clean up


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


# ea0331c6 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Removed cast: not needed anymore since Interval() has been moved to the base class (Pipe)


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


# f2e973d4 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented _AddPendingTransfer
* renamed trasfer_data memeber top to first_descriptor
* added data_descriptor member to transfer_data (useful for control transfer)



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


# 27d7771a 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Renamed fFinishTransfer to fLastTransfer (I don't even know why I called it
so in the first place)
* Renamed local variable descriptor to current in the finisher thread
* Using next_done_descriptor instead of next_logical_descriptor, as the latest
is used to keep track of all descriptors that belongs to the transfer
* Added _UnlinkTransfer private method
* Implemented _FreeDescriptorChain
* Moved endpoint pointer from the ohci_general_td structur to the transfer_data_s
structure, ad the ohci_general_td has already a transfer_data_s pointer which can
be used to the endpoint pointer reducing ridundancy.


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


# acf9124f 17-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Added definition for the hash related methods (not implemented)
* Continue working in the _FinishTransfer thread
* added next_done_descriptor in ohci_[general|isochronous]_td structure in order to handle
collisions.
* added next_logical_descriptor to ohci_isochronous_td structure



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


# d98bdb30 06-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Started working on the finisher thread
* Added some TRACE calls in the _InterruptHandler


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


# e78f31eb 27-Dec-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Partially implemented interrupt handler routine


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


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

* Fixed init part of the controller


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


# 01489ae0 20-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Remove SubmitAsyncTransfer and SubmitPeriodicTransfer
* Added _SubmitControlRequest (almost implemented), _LinkDescriptors, _WriteDescriptorChain (basically copied from EHCI, and UHCI)
* Renamed ohci_general_descriptor to ohci_general_td, and ohci_isochronous_descriptor to ohci_isochronous_td
* Finished _CreateGeneralDescriptor and _FreeGeneralDescriptor
* Added buffer_size member to ohci_general_td instead and removed last_logical_byte_address as it looked unnecessary
* minor clean up


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


# 4ff17443 17-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented _InsertEndpointForPipe
* usual clean up


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


# eaa35fb2 17-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Replaced snooze with spin (Thanks Axel)
* Fixing TRACE messages
* minor clean up


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


# e1abd4c8 16-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Moved disable_interrupt right before resetting the controller
* Reworked on NotifyPipeChange
* Added _RemoveEndpointForPipe (not implemented)



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


# 3f652d19 15-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Completed SubmitTransfer
* Added SubmitAsyncTransfer and SubmitPeriodicTransfer (not implemented)
* Removed unecessary spinlock
* Wrapped some lines to follow coding guidelines



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


# ca73cdd6 14-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Renamed some variables
* Reworking the interrupts endpoints tree parts
* Added spin_locker, semaphore, finisher thread and interrupt handler (not implemented)
* Made fInterruptEndpoints allocation dynamic instead of static
* Fixed Start method (it should be correct now)




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


# e3677c6d 10-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* ups :)


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


# a097d8c8 10-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Placed underscore to private methods like ReadReg and WriteReg
* Rewrote _AllocateEndpoint
* More work in the constructor


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


# dfd1357a 20-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Rewrote part of the constructor: most of the code is ported from FreeBSD
* Usual clean up


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


# f82eb041 14-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* License changed: I've successfully contacted Jan-Rixt Van Hoye, and he gave me his bless :)
* Usual clean up


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


# 1b442f19 13-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Revert Copyright


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


# 46a41c43 12-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Clean up (removing unneeded comment)
* Renaming, fixing coding guidelines
* Re-writing AddTo method
* Removing ohci_software.h file (its content has been moved to ohci.h) but it will probably be deleted in the future.


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


# cd6fd30f 25-May-2007 François Revol <revol@free.fr>

More tracing in ohci. Hmm, existing isn't totally consistent (prefix, ...). Oh well.


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


# f891e74e 22-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

Fixed wrong usage of object types in OHCI. The types are bitmasks, not values.

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


# 04394283 02-Oct-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Implemented endpoint creation for Pipes.

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


# e26f3a11 25-Sep-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Now the ports are powered on and seem to work...


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


# 2159acc7 25-Sep-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Implemented most of the roothub.

There remains only one issue: reading the Port registers seem to return a bogus value (0). I need to find out what's causing it.



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


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

* Implemented usable thread synchronisation for UHCI and EHCI.
* Cleaned interrupt handlers for both busses, too.
* Fixed memory leak of the queue head stray descriptors in EHCI.
* Fixed warnings about assigning NULL to the module flags field.

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


# 915367e3 31-Aug-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Wrote the initialisation routine of the host controller
* Started cleaning up the style (WIP)
* I'll slowly phase out ohci_software.h, since it is BSD legacy
* Cleanup other BSD inspired naming. I like full names.


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


# 2761c5ae 30-Aug-2006 Jérôme Duval <korli@users.berlios.de>

replaced with PCI.h definitions, added PCI_usb_ehci


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


# 34314b98 28-Aug-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

First commit to show that work on the ohci bus has restarted.
It doesn't do anything yet, but it allocates the io registers properly and
now the values that are returned when reading it make sense.

More to come...


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


# 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


# 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


# 4097611c 26-Sep-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

Fixed the bugs I introduced earlier. original code was ok.


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


# 2239adfc 23-Sep-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

properly mask off bits


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


# b2141301 23-Sep-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

it's not allowed to spin 250ms


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


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

Quick merge of my development branch with mainline (for SVN switch).
The OHCI stuff was done by Jixt (thanks)./installusb
All is still very much work in progress

Patches applied:

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

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-1
Set the PORT_STATUS_LOW_SPEED flag correctly (using the register bitflag for low speed devices, instead of the proper lowspeed flag)

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-2
Clean up transfers when they're done

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-3


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-4


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


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-6


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-7
Remove obsolete ehci.c

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-8


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-9
Completed memory allocation + initialization

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-10
First attempt at performing control transfers - failed miserably

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-11
Trying to read a 16bit value into a 8bit integer, stupid

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-12
nicer way of getting the base io address

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-13
Take over control from BIOS

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-14
Revert change for disabling USB BIOS support


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


# 291e40c3092eec114393f5463d481375736af6d3 04-Aug-2013 Siarzhuk Zharski <zharik@gmx.li>

USB OHCI: Fix finalizing of STALL-ed control request transfers

In case control transfer is finished with STALL answer from device only
the setup TD is retired into the Done Queue but other TDs (data and
status) are left in the ED queue. HC set the endpoint halted - so we
process such endpoint regardless of it's non-empty queue.

PS: cleanup some trailing spaces.


# cf58476cccdd470c401dd06dec94dc1939e4f3fc 25-May-2013 Siarzhuk Zharski <zharik@gmx.li>

USB OHCI: Support for isochronous transfers

Finishing and refactoring the draft, initially implemented during April-May 2012

NOTE: startingFrameNumber returned to device contains the number of the
next free frame right after the last packed of submitted data. For more
details please Look into corresponding [haiku-development] discussion
started at 03 Jul 2013.

Partially fixes #1045.


# b3dbb4d23b2c740eeabb928ae18eee3486246849 30-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

OHCI USB: disable MSI on destruction

* also remove interrupt handler and put the PCI x86 module.


# 3b98be3cc44741c04fefddc14d7b34a7735468a2 04-Oct-2012 Jürgen Wall <fakeEmail@fakesite.fake>

USB OHCI: Fix ownership handover from SMM to OS.

* Disabling all interrupts prior to ownership handover from SMM to OS
can prevent propper OHCI and PS/2 functionality as described in
#8987 and #8984. In that case SMM does not respond to the ownership
change request. On the other hand not disabling the interrupts can
lead to interrupt storms (discussed in #8085) since no interrupt
handler is installed at that moment. As suggested by mmlr this patch
attempts to address both issues by keeping the ownership change
request interrupt enabled.

* Removed an unnecessary reset upon non-responding SMM for now,
since we reset a few lines later anyway and added TODOs respectively.
That should safe a bit boot time.

Signed-off-by: Michael Lotz <mmlr@mlotz.ch>


# a4bca8119323c016607b25c3d1dcec2f0d4b0010 15-Aug-2012 Michael Lotz <mmlr@mlotz.ch>

Add MSI support to OHCI.

It looks like VirtualBox assumes MSIs when emulating a 64bit system so
this gets OHCI working there. Shouldn't harm if it's used anywhere else
either.


# 2b883e1977b1c420935c80b6fb9eb0067f112301 06-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fix compilation of OHCI on x86.

Fixes were needed to go with the USB stack changes. Haven't tested it
yet because I don't have a a machine with OHCI, but I doubt there
will be any problems.


# c46509339b8e4ba1e3edb9b0216be7cc1dcc9e76 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Disable interrupts in OHCI before doing BIOS handover. Shouldn't matter much
but maybe it helps on some chipsets to avoid interrupt storms during handover.
* Remove comments that aren't true anymore.


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


# d7411ad2ec16e5fd1b8eefa975119cf3045f5fbd 07-Apr-2011 Jérôme Duval <korli@users.berlios.de>

added traces for unimplemented isochronous transfers for ehci and ohci


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


# 1393394ba6adde434020a48e5d9b7b22822150b0 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

We need to guarantee that when cancel returns that the callback won't be called
anymore. It could happen that the transfer was already in the process of being
finished, so wasn't in the list of pending transfers anymore. Cancel would then
return even though the callback wasn't called yet. This could lead to a callback
being called after a driver was already unloaded (even after it cleaned up the
pipes it used).


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


# 1dd6c50cb3cdbcfe254d9b60f04bbfad100e6848 14-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

When submitting transfers there is a race condition between adding the pending
transfer to the transfer list and scheduling the transfer descriptors on the
controller by switching the endpoint tail. Since we only check that the endpoint
head is equal to the endpoint tail to conclude that there are no active
transfers, we need to ensure that we don't accidently do that check before the
transfer descriptors are scheduled. Otherwise we could happen to processed a not
yet started transfer and finishing it before an actual transfer has taken place.
This would then lead to 0 byte transfers and toggle mismatches. To fix this we
now protect the transfer addition and tail switching as well as the check in the
finisher with a per-endpoint mutex. Note that we allocate the lock on the heap
and only store the pointer in the endpoint structure as this one is allocated
from the precious physical memory pool. Could fix #4067.
Also switched the Jamfile to UsePrivateKernelHeaders (for the MutexLocker) and
removed BeOS compatibility.


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


# 12f584636c4d5a419ce50a9fc8fa700249be7895 25-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Fix subtle but important error in transfer length calculation. That calculation
does calculate the remaining bytes, not the transferred ones, so obviously that
number has to be subtracted from the expected buffer size! Albeit severe, this
wasn't hit that often, because this calculation will only be used when the
transferred size doesn't match the handed in buffer size exactly. So things like
HID or mass storage, that mostly know the exact transfer size weren't affected.
But it could very well explain #4101 where the size isn't previously know.


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


# 9dbe55ebcc6109652443b35458ffca3706b83cdd 20-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Fix typo.


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


# c265fd23cd11450d8810fa1afc648a46bd06cd2c 20-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

We cannot use the condition codes to determine if a transfer descriptor is
processed. The controller may initialize it to any value when starting to
process the descriptor. If a controller did that it was possible that we thought
a transfer was already done even if it actually just started. Transfers would
then return that weren't processed, returning uninitialized buffers.
Instead of relying on the condition codes we now check that the head and tail
pointers are the same. This guarantees that all transfer descriptors of the
endpoint at hand are completed.
Reverted r32534 again as this one fixes the problem for real. The same things
that were mentioned there could happen here essentially, so in the worst case
the device or controller could stall because of freeing in-use structures.
Fixes #4067.


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


# 840cdc9efcf81ce93b1ee48884416e11b8ae748b 20-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

When adding a transfer, the current tail descriptor of the endpoint will be
reused and overwritten by the first descriptor of the new transfer and the first
descriptor will become the new tail. We anticipate this situation in
_AddPendingTransfer() and set the first_descriptor of the transfer data to the
tail already. Since the tail was pretty much cleared to zero, this introduced
a race condition. After adding the pending transfer it can already be found
in the finisher thread. If this happened before actually switching the tail
and first descriptor it would find a descriptor with a condition of 0, meaning
"No Error" and would process the transfer incorrectly. Depending on the count
of descriptors and the timing of the switch taking place this could have
resulted in aborted transfers with actual length 0 or with the correct actual
length but invalid data. In the very worst case it could have freed things still
in use by the controller, resulting in all sorts of device errors. Sadly it
doesn't fix #4067.


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


# 5f92e39f7b50cd57fffbdde384133052c749f7bd 19-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

That's actually not how it works. OHCI does the dirty work of splitting up the
transfer descriptors into individual packets. The descriptors are more a
logical thing. As such we do not generate one descriptor per packet but one
for each block of two pages at max. Therefore we only set the initial toggle bit
to the one we stored on the first descriptor and let OHCI use the carry bit for
subsequet descriptors. That error would only be visible on transfers above two
pages in size though.


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


# b0a2e9e7aa53b4c1b73d71dd8a9454263825e62b 19-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Even though the specs say the toggle carry field contains the value of the last
retired descriptor, it actually contains the value that is to be used next.
Confirmed that by cross-referencing FreeBSD.


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


# abe8e8a2c2ebef2a46252a5f1bf904b4cc18ce3c 18-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

A try at actual data toggle handling. Since we do not properly ensure that the
toggle carry stays valid, we better make sure we set it correctly. Additionally
even if the toggle carry wasn't clobbered, there are conditions the toggle is
reset without the controller being able to notice (as in clearing a halt state).
Since I don't have any OHCI hardware this is untested, but should fix bug #4067
if correct.


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


# 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


# 2fc7e292e5c277938b10d50f99e8fd531fe2e8ed 19-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

When calculating the actual length for requests, we don't want to include the
8 byte request header. It was included in the case of outgoing request
transfers before. In fact we always just want the length of the data phase,
which for non-requests just happens to be the whole transfer.

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


# 1751250abf5964fdd9d0b570f5625fbdfd2ff14f 12-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Remove disabling and clearing interrupts again as it doesn't turn out to be a problem.

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


# 97403a77f1d46f1cf7cb3b339388e5cf0ca31b97 10-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

* Fix the check after waiting for owner change to happen and don't reset if the
handover indeed worked. Doesn't really matter though, as we reset anyway,
just not twice in the success case.
* Disable all interrupts and clear any pending active interrupts just after
taking over the controller. This might fix bug #2361.
* Also trace output when the ownership change is successful.
* Don't disable interrupts during reset.

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


# 4ca876701dbe6b2676f81902186fabe67b8ad956 08-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

When canceling transfers, do not call the callbacks with the lock held. This
prevents deadlocks in cases where a new transfer is scheduled from within the
cancel callback. This is an edge case, as generally you don't want to schedule
anything when explicitly canceling transfers, but there are a valid use cases
when you cancel because of a timeout and then have to reset the device for
example. Note that this hides bug #2353, where the cancel case is probably
not handled correctly.

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


# 1c8de8581b66c14ea94bccd7ddcea99291955796 01-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added optional spinlock contention measurement feature. Enabled when
B_DEBUG_SPINLOCK_CONTENTION is defined to 1. It typedefs spinlock to a
structure (thus breaking BeOS binary compatibility), containing a
counter which is incremented whenever a thread has to wait for the
spinlock.
* Added macros for spinlock initialization and access and changed
code using spinlocks accordingly. This breaks compilation for BeOS --
the macros should be defined in the respective compatibility wrappers.
* Added generic syscall to get the spinlock counters for the thread and
the team spinlocks.


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


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

Unconditionally report initialization success for OHCI too.

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


# 307fe93f85a2a18a77fda7afacd17f26c8612fdc 20-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Disable the root hub change interrupt when it gets triggered. As the change
status stays on until the port is reset, this causes the interrupt to be
constantly retriggered on some controllers.
* Added TODO that we need to reenable it once we want to take advantage of
status change notifications instead of polling. It should be reenabled when
clearing roothub status changes in ClearPortFeature().

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


# 9cc4091e353f453b9ee0c2feb7ebe7d3c79defcd 20-May-2008 Michael Lotz <mmlr@mlotz.ch>

Enable interrupts only after installing the interrupt handler.

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


# 5b03912b5f9783e9652ba9925f44e901af8e24e6 19-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Correct removal of failed transfers by applying the address mask. As the head
pointer also contains the toggle carry and the halt bit (which was obviously
always set as the endpoint had an error) the address comparison failed and
the head was dead in the water with all further transfers timing out until
a subsequet cancel cleaned the mess up again.
* Add the OHCI host controller driver to the image as it should now be fully
functional except for isochronous transfers.

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


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

* Implement removal of failed transfers. The head pointer will be moved past
the failed transfer if the transfer in question is found to be the offending
one. Probably not quite enough and still untested.

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


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

* Build the interrupt tree the same (imperfect) way as in EHCI to conserve
on resources but still satisfy the scheduling policy. This works well, but
effectifly limits the bandwidth available as the interrupts aren't spread
across different frames.
* Implement finding the interrupt endpoint head for a certain interval.
* Deactivate endpoints that are going away until removing them is implemented.
* Allow short packets for all data phases.
* Disable tracing by default.

There you go, interrupt transfers should work as well. Should enable mice,
keyboards, hubs and other devices that use interrupt pipes. Note that it's
still easily possible that a single failed request will hang an endpoint and
prevent a device from working.

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


# 016ce5dd542c3ef0731dc3d7f3b7ab29603b04e8 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Handle the data == first and last == first case as this can occure for
single td bulk transfers.
* Implement SubmitTransfer() for bulk transfers (interrupts will use the exact
same code path, but as their endpoints aren't yet setup, interrupt transfers
won't work).
* Handle the cancel case when finishing transfers. The descriptors of the
canceled transfers cannot be accessed by the controller so they can be freed.

Bulk transfers should work now, so devices only using control and bulk transfers
should too (anything using usb_disk for example). Note though that a transfer
error will cause the whole thing to fail miserably as the error case is not
yet handled correctly (failed descriptors aren't removed from the endpoint).
Therefore I suggest not testing with the memory stick with that important
presentation you haven't stored anywhere else...

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


# 408a8ff36a2514df0dcdc2cefe0daa7ad0972f41 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Completely rework how transfer finishing is implemented. It is now using
pretty much the same strategy as UHCI. This does not leverage the done queue
the hardware provides us, but as it saves a lot of other overhead and allows
the structures to be smaller I think it is overall worth it.
* Removed now unnecessary stuff from the transfer descriptor struct.
* Directly acknowledge the done head interrupt as we do not use it either.
* Activate control endpoints by removing the skip bit when a transfer is scheduled.
* Correct the way the first descriptor is determined (the current tail becomes
the first descriptor while the current first descriptor becomes the tail).
* Remove the head_logical_descriptor field from the endpoint structure, as this
would simply get out of sync with the first td with no real way of updating.
* Stub out RemoveTransferFromEndpoint() as this needs reworking.
* Correct CreateDescriptorChain() signature and implement the method.
* Add ReadDescriptorChain() and ReadActualLength() to process finished transfers.
* Prepare for actual data transfers by renaming/regrouping transfer types.
* Fully clear out the new tail when switching (for the sake of it)
* Add some helpers and definitions to the hardware header.
* Add debugging facilities.

With all this transfers can now actually be scheduled and they are processed
when done. This brings control transfers to a usable state so setting the
device address and reading out/setting the configuration works. That means you
can now view your device using usb_dev_info, but since any other transfer type
besides control transfers isn't implemented yet the device will most probably
not yet do anything useful.

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


# 87fe2972ec8bb06789554dfe18a38b876e7c09f1 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

Correctly clear an endpoint on cancel. Adjusted some comments/output.

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


# 0439bcbbbbec2fe70401e02bb962b3f013b166b6 17-May-2008 Michael Lotz <mmlr@mlotz.ch>

Use a dedicated endpoint lock for endpoint manipulation. Fixes the guaranteed
deadlock with the BusManager on setup of the default pipes (for addressing).

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


# a9d7e87d40decf63c52a13f553955b0865f45a48 17-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Implement "tail switching" so that a new transfer descriptor chain can be
appended to an endpoint descriptor without locking/disabling the endpoint.
* Correct the direction of the data phase of a control transfer.
* Some minor cleanup.

Control requests without data phase (set address for example) might actually
work now, but this is still untested.

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


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

* Complete the roothub get/set/clear port feature functions
* Reorder to match the usual order of the states/commands
* Fix some debug output and make it more informative

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


# 812dd254dcde4a920bc5e814ad89ad90e8dfd17c 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

Acknowledge OHCI interrupts.

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


# 20bbb1bf28b5ccd3fcda07e27f0dd24c62fbe71d 18-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Make the operational register memory a uint8 * instead of a uint32 * so the
driver has at least a chance of working (it previously always used wrong
offsets for register access).
* Remove the hash approach for now (I'm going to explore a few other ways of
doing that first).
* Reorder some stuff and check for errors in some more places.
* More cleanup (mostly whitespace again).

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


# fd1e6f2b375d31347be55e2b1924618f9055711f 16-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Getting familiar with the existing code
* Cleanup (whitespace, nameing, code style)
* Move around methods so they match the header order
* Fix some obvious stuff
* Initialize all members
* Sync roothub code (this will be reworked to a common roothub)
* Only minor functional changes (to the worse for now)

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


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

Fix building usb busses with tracing on.


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


# de1ecdaf63d5d81422df2c056af595b508e9eaaf 25-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Added necessary dummy descriptor to every endpoint created
* Implemented _RemoveTransferFromEndpoint
* Reworked _AppendChainDescriptorsToEndpoint as now every endpoint has (must have) a dummy descriptor



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


# 555d13dc9fde786e8f12f5be29d67ef22009ae25 25-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented private method _AppendChainDescriptorsToEndpoint in order to avoid code duplication (lock needs to be added)
* Fixed _SubmitControlRequest in order to use _AppendChainDescriptorsToEndpoint


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


# 5f061e0b6b5e64775404c84b3a814f7b5e0d4f5d 24-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* More work on the finisher thread
* Reworked SubmitTrasfer method
* Implemented CancelQueuedTransfers
* Minor clean up


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


# ea0331c6f9e40796b888e6205f1478939d9911dd 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Removed cast: not needed anymore since Interval() has been moved to the base class (Pipe)


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


# f2e973d406d4bb29d79159a854dc376fab0c1310 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented _AddPendingTransfer
* renamed trasfer_data memeber top to first_descriptor
* added data_descriptor member to transfer_data (useful for control transfer)



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


# 27d7771a1ec1b6cd2ce5635cfc1f6f9a377bb153 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Renamed fFinishTransfer to fLastTransfer (I don't even know why I called it
so in the first place)
* Renamed local variable descriptor to current in the finisher thread
* Using next_done_descriptor instead of next_logical_descriptor, as the latest
is used to keep track of all descriptors that belongs to the transfer
* Added _UnlinkTransfer private method
* Implemented _FreeDescriptorChain
* Moved endpoint pointer from the ohci_general_td structur to the transfer_data_s
structure, ad the ohci_general_td has already a transfer_data_s pointer which can
be used to the endpoint pointer reducing ridundancy.


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


# acf9124f1b49d095c7ea2a198f78a2105b49c027 17-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Added definition for the hash related methods (not implemented)
* Continue working in the _FinishTransfer thread
* added next_done_descriptor in ohci_[general|isochronous]_td structure in order to handle
collisions.
* added next_logical_descriptor to ohci_isochronous_td structure



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


# d98bdb30bcb05395231e26e7940dbb304a2c9b91 06-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Started working on the finisher thread
* Added some TRACE calls in the _InterruptHandler


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


# e78f31ebbed1b8ff8db3a0af6dee8e42c5b5361d 27-Dec-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Partially implemented interrupt handler routine


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


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

* Fixed init part of the controller


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


# 01489ae0603b930a2c14352c24138ca12c33a2d8 20-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Remove SubmitAsyncTransfer and SubmitPeriodicTransfer
* Added _SubmitControlRequest (almost implemented), _LinkDescriptors, _WriteDescriptorChain (basically copied from EHCI, and UHCI)
* Renamed ohci_general_descriptor to ohci_general_td, and ohci_isochronous_descriptor to ohci_isochronous_td
* Finished _CreateGeneralDescriptor and _FreeGeneralDescriptor
* Added buffer_size member to ohci_general_td instead and removed last_logical_byte_address as it looked unnecessary
* minor clean up


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


# 4ff174438e3938700c661ca1bf6b400e9138a1db 17-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented _InsertEndpointForPipe
* usual clean up


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


# eaa35fb2d194dec0f63d231e4d6e32c6dc66026e 17-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Replaced snooze with spin (Thanks Axel)
* Fixing TRACE messages
* minor clean up


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


# e1abd4c8ce26c6b95bb53cd60d564cdd28300317 16-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Moved disable_interrupt right before resetting the controller
* Reworked on NotifyPipeChange
* Added _RemoveEndpointForPipe (not implemented)



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


# 3f652d19a6f8da6944bd6c8d9f9e6b797ab240b3 15-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Completed SubmitTransfer
* Added SubmitAsyncTransfer and SubmitPeriodicTransfer (not implemented)
* Removed unecessary spinlock
* Wrapped some lines to follow coding guidelines



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


# ca73cdd62fbfb79e407aba0b4372ac76a6be09dc 14-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Renamed some variables
* Reworking the interrupts endpoints tree parts
* Added spin_locker, semaphore, finisher thread and interrupt handler (not implemented)
* Made fInterruptEndpoints allocation dynamic instead of static
* Fixed Start method (it should be correct now)




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


# e3677c6d3c5fc8b9e83f56be784b8957d02cae5e 10-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* ups :)


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


# a097d8c8ee03896405548330ffc639c6ad7db897 10-Nov-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Placed underscore to private methods like ReadReg and WriteReg
* Rewrote _AllocateEndpoint
* More work in the constructor


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


# dfd1357ad21f447892ab9a25a7b21dbc7333b1cf 20-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Rewrote part of the constructor: most of the code is ported from FreeBSD
* Usual clean up


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


# f82eb0415aab313596ee8de85004c1eed22fb3dc 14-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* License changed: I've successfully contacted Jan-Rixt Van Hoye, and he gave me his bless :)
* Usual clean up


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


# 1b442f19197e315955fc4948a1e9109501abac79 13-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Revert Copyright


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


# 46a41c432c78ffede0165f705000468672bbd681 12-Oct-2007 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Clean up (removing unneeded comment)
* Renaming, fixing coding guidelines
* Re-writing AddTo method
* Removing ohci_software.h file (its content has been moved to ohci.h) but it will probably be deleted in the future.


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


# cd6fd30f63983ec5ad23de5af15fcda68dcef07b 25-May-2007 François Revol <revol@free.fr>

More tracing in ohci. Hmm, existing isn't totally consistent (prefix, ...). Oh well.


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


# f891e74eeedcfc3e05f9d488b26180ae990901b8 22-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

Fixed wrong usage of object types in OHCI. The types are bitmasks, not values.

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


# 04394283560c099f04d3816286635ec6f436b709 02-Oct-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Implemented endpoint creation for Pipes.

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


# e26f3a113ffe311ba2f95e371dfc9646e4533898 25-Sep-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Now the ports are powered on and seem to work...


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


# 2159acc7d9492bb23888c5f4a8664d49ff91f371 25-Sep-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Implemented most of the roothub.

There remains only one issue: reading the Port registers seem to return a bogus value (0). I need to find out what's causing it.



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


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

* Implemented usable thread synchronisation for UHCI and EHCI.
* Cleaned interrupt handlers for both busses, too.
* Fixed memory leak of the queue head stray descriptors in EHCI.
* Fixed warnings about assigning NULL to the module flags field.

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


# 915367e31aea39fe40ae3239dc7fcc738aebf039 31-Aug-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Wrote the initialisation routine of the host controller
* Started cleaning up the style (WIP)
* I'll slowly phase out ohci_software.h, since it is BSD legacy
* Cleanup other BSD inspired naming. I like full names.


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


# 2761c5ae558dccbeb2f9f088ca1011824c823612 30-Aug-2006 Jérôme Duval <korli@users.berlios.de>

replaced with PCI.h definitions, added PCI_usb_ehci


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


# 34314b980333eb800f399d2970743f9b88d0bbf8 28-Aug-2006 Niels Sascha Reedijk <niels.reedijk@gmail.com>

First commit to show that work on the ohci bus has restarted.
It doesn't do anything yet, but it allocates the io registers properly and
now the values that are returned when reading it make sense.

More to come...


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


# 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


# 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


# 4097611c9fff4cf60e79caf2c1d531f3a383828e 26-Sep-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

Fixed the bugs I introduced earlier. original code was ok.


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


# 2239adfca3281c130810330b56527cfe18b7afbb 23-Sep-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

properly mask off bits


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


# b21413013bac141e5d97e922716bf6efbfafa401 23-Sep-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

it's not allowed to spin 250ms


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


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

Quick merge of my development branch with mainline (for SVN switch).
The OHCI stuff was done by Jixt (thanks)./installusb
All is still very much work in progress

Patches applied:

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

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-1
Set the PORT_STATUS_LOW_SPEED flag correctly (using the register bitflag for low speed devices, instead of the proper lowspeed flag)

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-2
Clean up transfers when they're done

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-3


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-4


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


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-6


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-7
Remove obsolete ehci.c

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-8


* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-9
Completed memory allocation + initialization

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-10
First attempt at performing control transfers - failed miserably

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-11
Trying to read a 16bit value into a 8bit integer, stupid

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-12
nicer way of getting the base io address

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-13
Take over control from BIOS

* Niels.Reedijk@gmail.com--nielx-2005/usb-busses--development--0.1--patch-14
Revert change for disabling USB BIOS support


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