OSDev.org
https://forum.osdev.org/

XHCI port detection
https://forum.osdev.org/viewtopic.php?f=1&t=34479
Page 1 of 1

Author:  SanderR [ Wed Sep 11, 2019 2:27 pm ]
Post subject:  XHCI port detection

Hello everyone,

I tried to detect ports on XHCI.
On virtual machine (BOCHS) it detects the ports as I expected but on real hardware it gives 0x00 as portstatus and when you go over the limit it shows 0x200.
https://github.com/AdeRegt/SanderOSUSB/ ... dev/xhci.c is the sourcecode.
What am I doing wrong?

Author:  Klakap [ Thu Sep 12, 2019 11:32 am ]
Post subject:  Re: XHCI port detection

Bochs isnt support XHCI ports. Correct me if I am wrong. Maybe some wrong about PCI progif value with detection(for xhci 0x30)?

Author:  SanderR [ Thu Sep 12, 2019 11:35 am ]
Post subject:  Re: XHCI port detection

Bochs actually do support it, with an extension.
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1, usb_xhci=1
usb_xhci: enabled=1, port1="disk:/home/example/Downloads/mikeos-4.6b3/disk_images/mikeos.flp", options1=none, port2=none, options2=none

Author:  BenLunt [ Sun Sep 15, 2019 12:46 pm ]
Post subject:  Re: XHCI port detection

Hi,

Yes, Bochs does indeed support, though minimally, xHCI. Please note though, it only support default settings, always on, no BIOS handoff, no SMI, doesn't even know what timing is, and understand only default and commonly used commands and functions. Enough to get most any operating system to recognize it and use a mouse, keyboard, and a thumb drive.

As for real hardware, this is a different story. Throughout all my research, I have found that depending on the manufacturer and style of machine the xHCI is install in, there are numerous inconsistencies when it comes to a "standard" xHCI. For example, some manufacturers wanted to be sure backward compatibility was a top priority. One machine I tested with had hardware that would be 100% compatible with EHCI until you told it to be xHCI using a vendor specific technique. I would see most problems--vendor specific, timing specific, or other specific items--with laptops. Most desktop forms of xHCI hardware would be mostly 100% compatible. When tested, my code would work on all desktop machines using an installed PCI xHCI card, or even one integrated to the Motherboard. However, this same code would fail 50% of the time when tried on laptops and the like.

So, my question for you and any others reading this is, what type of "read hardware" are you using?

Here are my suggestions:
1) Look up the motherboard/hardware specs for that specific machine and see if there are any "bits" in the PCI Configuration Space that you must set to make it 100% compatible.
2) Are there any Machine Specific Register settings you must set to make the xHCI compatible?
3) Do you have to power the card via ACPI?
4) Is the physical port powered? (A bit in one of the xHCI's port status registers)
5) Verify that you are reading from the correct physical address for the port. i.e.: as mentioned before, the Bochs' xHCI address space is a default, one space after another, address space. The physical card for your test machine may be different. If my memory serves, I have seen xHCI's reserve as little as 4k and as much as 16k address space. Does your memory manager/paging manager allow this access? Are you accessing the correct page?
6) Have you done the BIOS hand-off technique yet? If the SMI (System Management Interface) is still active, it may keep you from reading a correct value from the port.
7) Do you have interrupts enabled for the controller? The controller may require a valid interrupt to happen when a physical change has been made, i.e.: a port change status.

There are many other things to consider.

The actual hardware of the xHCI makes transfers much easier, almost ignoring the speed of the device, where as earlier hardware was more specific to the actual speed of the device. However, on the flip-side, the xHCI's setup is much more complicated than earlier hardware.

Anyway, my oppologies to everyone here for my absence. I have been busy with many other things, though I do miss the work and enjoyment of this hobby we have.

Enjoy your weekend,
Ben
- http://www.fysnet.net/osdesign_book_series.htm

Author:  nullplan [ Sun Sep 15, 2019 10:02 pm ]
Post subject:  Re: XHCI port detection

BenLunt wrote:
One machine I tested with had hardware that would be 100% compatible with EHCI until you told it to be xHCI using a vendor specific technique.
Well, that's mildly disconcerting. Was it at least reporting its Prog-IF as 0x20 while in EHCI mode?

Author:  SanderR [ Sun Oct 20, 2019 5:56 am ]
Post subject:  Re: XHCI port detection

yes i had same problems with initialising EHCI devices trough the PCI. This was however on a other device.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/