Commit Graph

16 Commits

Author SHA1 Message Date
Martin Whitaker
66b1389348 Revert workaround for issue #6 and issue #71 (commit 3a10701).
The early USB handoff is a better fix for those issues.
2022-10-07 09:33:23 +01:00
martinwhitaker
407fb811c2
Take ownership of all USB controllers before probing for devices. (#167)
When two controllers are attached to a physical port (e.g. in the
case of EHCI and its companion controllers, problems can occur if
the BIOS still has control of one controller when we try to use the
other one. So perform a first pass to scan the PCI bus and take
ownership of and reset all the controllers we find, and perform a
second pass to initialise the controllers and probe for attached
devices.

As we don't support hot plugging, split the second pass into two,
with the first probing the EHCI controllers and handing over any
low and full speed devices to the companion controllers, and the
second probing the remaining controller types.
2022-10-07 09:32:09 +01:00
Martin Whitaker
f265d1f1c5 Fix EHCI and XHCI drivers to handle USB1 hubs (issue #156) 2022-09-08 18:09:43 +01:00
a1346054
9660eead4e
Simple maintenance improvements (#145)
* Fix typos

* Add missing final newline

* Trim trailing whitespace
2022-08-15 17:51:48 +02:00
Lionel Debroux
408fdb8db6 Switch to an array of heaps in the heap manager, and heap IDs in the allocation functions. 2022-07-25 12:53:21 +02:00
martinwhitaker
e6e0f0c8e7
USB improvements (#116)
* Add new heap manager.

* Convert OHCI driver to use new heap manager.

* Convert UHCI driver to use new heap manager.

* Convert EHCI driver to use new heap manager.

* Convert XHCI driver to use new heap manager.

* Convert SMP to use new heap manager.

* Add a "usbinit" boot option to handle various buggy USB devices.

This replaces the "keyboard=buggy-usb" option, and adds a second
workaround to handle the problem seen in issue #107.
2022-07-16 13:34:08 +02:00
Martin Whitaker
3a107018e5 Reset EHCI controller after port scan if no keyboards are found.
Low and full speed USB devices that are attached directly to an EHCI port
have to be handled by a companion controller (either UHCI or OHCI). We hand
over ports when we detect a low or full speed device is attached by setting
the Port Owner bit in the Port Status and Control register. However some AMD
companion controllers fail to detect the device after this has been done.
Resetting the EHCI controller works around this quirk.

This fixes issue #6 and issue #71.
2022-05-21 20:22:03 +01:00
Martin Whitaker
260c113bb2 Detect and ignore the HID keyboard "phantom condition" (excessive roll-over). 2022-05-01 22:40:42 +01:00
Martin Whitaker
f7d31df412 ehci: update the data toggle bit when reenabling an interrupt transfer.
Previously every second transfer was dropped. We didn't notice, because
they were normally key release events, which we ignored anyway. However
the new keyboard report handler needs to see the release events.
2022-05-01 18:27:13 +01:00
Martin Whitaker
97d6c7140d Improved USB keyboard report handling.
A USB keyboard may return key codes in any of the 6 key code array
positions (issue #48). So we have to compare the latest report to
the previous one to detect new key presses and handle rollover. As
the same change is needed for all HCI types, factor out the common
code into the base driver.
2022-05-01 16:44:46 +01:00
Lionel Debroux
e0d42db07c Optimize the code by declaring several functions static in system/ehci.c.
`size memtest_shared` indicates that this saves 200- (x86) / 200+ (x86_64) bytes, but alignment hides the gain.
2022-03-30 11:54:56 +02:00
Martin Whitaker
0873e3b60a Include string.h, not memory.h, when using memcpy and memset.
memory.h is an anachronism, and not present on all systems.
2022-03-11 18:07:01 +00:00
Martin Whitaker
b609c4dd81 Make detection of EHCI asynchronous transfer complete more robust.
Using Interrupt On Completion is not robust, because the interrupt flag
is also set if a short transfer is detected. So we need to poll the
Active flag in the transfer descriptors.
2022-03-06 18:20:53 +00:00
Martin Whitaker
f109a5814b Implement EHCI handover to companion controllers.
Low/full speed USB devices attached directly to the root hub must be
rerouted to a companion controller. We can't rely on the BIOS to do
this for us. This requires us to initialise the EHCI device before
initialising any of its companions.

This also allows us to support keyboards attached via a high speed
hub on a system with EHCI plus companions.
2022-02-20 20:21:16 +00:00
Martin Whitaker
01365ab2e7 A few more code tweaks and comment typo fixes in the EHCI driver. 2022-01-28 19:55:31 +00:00
Martin Whitaker
563c8a1ee7 Add support for EHCI USB controller. 2022-01-23 17:38:50 +00:00