Page 1 of 1

Bochs, enable EHCI companion controller (UHCI/OHCI).

Posted: Wed Oct 09, 2024 12:48 pm
by CorruptedByCPU
Hey, @BenLunt!

Please tell me how to enable EHCI controller together with UHCI or OHCI companion controller.

This configuration as I assume should do the trick:

Code: Select all

usb_ehci: enabled=1, companion=uhci, port1=keyboard, options1="speed:low", port2=mouse, options2="speed:low"
But, I cannot find any controller with 0x0C0320xx value on PCI.

Code: Select all

[USB].0 PCI 00:01.2 - USB controller found. (UHCI - Universal Host Controller Interface)
[USB].0 PCI 00:01.2 - I/O address 0xC020
[USB].1 PCI 00:06.0 - USB controller found. (OHCI - Open Host Controller Interface)
[USB].1 PCI 00:06.0 - MMIO address 0x00000000C3000000
What surprised me, OHCI controller was found even though I didn't trigger it.

Using current (git) Bochs source code from 06.10.2024.

Re: Bochs, enable EHCI companion controller (UHCI/OHCI).

Posted: Wed Oct 09, 2024 5:17 pm
by BenLunt
CorruptedByCPU wrote: Wed Oct 09, 2024 12:48 pm This configuration as I assume should do the trick:

Code: Select all

usb_ehci: enabled=1, companion=uhci, port1=keyboard, options1="speed:low", port2=mouse, options2="speed:low"
That looks to be correct. You also need to have something like this:

Code: Select all

pci: enabled=1, chipset=i440fx, slot1=usb_ehci
If you are getting the OHCI, you might, by accident, have something like this:

Code: Select all

pci: enabled=1, chipset=i440fx, slot1=usb_ohci
without realizing it.

Anticipating that you do have the correct line added, how are you searching the devices?

The EHCI and any companion controllers will be on the same Bus/Device, with the EHCI as a Function number being larger than any companion Function number. In a common setup, the EHCI will be at Function 7, with zero or more (up to 7) companion controllers starting at Function 0.
Another common setup is to have two companion controllers at Function 0 and Function 1 respectively, and the EHCI controller at Function 2.

Though not commonly found, any controller *after* the EHCI Function number that is not an EHCI is a stand-alone full-/low-speed controller.

As a side note, you also have to check bit 7 in...off the top of my head...the Type byte (?) in the PCI Configuration to see if there are more than one Function used for this device.

Hope this helps,
Ben
- https://www.fysnet.net/osdesign_book_series.htm

Re: Bochs, enable EHCI companion controller (UHCI/OHCI).

Posted: Thu Oct 10, 2024 4:51 am
by CorruptedByCPU
Thanks for that line!

Code: Select all

pci: enabled=1, chipset=i440fx, slot1=pcivga, slot2=e1000, slot3=voodoo, slot4=usb_ehci, slot5=none
usb_ehci: enabled=1, companion=uhci, port1=keyboard, options1="speed:low", port2=mouse, options2="speed:low"
Now it seems to be found correctly:

Code: Select all

[USB].0 PCI 00:01.2 - USB controller found. (UHCI - Universal Host Controller Interface)
[USB].0 PCI 00:01.2 - I/O address 0xC020
[USB].1 PCI 00:05.0 - USB controller found. (UHCI - Universal Host Controller Interface)
[USB].1 PCI 00:05.0 - I/O address 0xC060
[USB].2 PCI 00:05.1 - USB controller found. (UHCI - Universal Host Controller Interface)
[USB].2 PCI 00:05.1 - I/O address 0xC080
[USB].3 PCI 00:05.2 - USB controller found. (UHCI - Universal Host Controller Interface)
[USB].3 PCI 00:05.2 - I/O address 0xC0A0
[USB].4 PCI 00:05.7 - USB controller found. (EHCI - Enchanced Host Controller Interface)
[USB].4 PCI 00:05.7 - MMIO address 0x00000000C3000000
%1 = ID number of found controller
%2 = Bus
%3 = Device
%4 = Function

[USB].%1 PCI %2:%3.%4

I'm still trying to understand why there is UHCI at 00:01.2 (which doesn't exist in Bochs RC file).

As a side note, you also have to check bit 7 in...off the top of my head...the Type byte (?) in the PCI Configuration to see if there are more than one Function used for this device.
Ok, will check that.

Re: Bochs, enable EHCI companion controller (UHCI/OHCI).

Posted: Fri Oct 11, 2024 9:52 am
by BenLunt
CorruptedByCPU wrote: Thu Oct 10, 2024 4:51 am I'm still trying to understand why there is UHCI at 00:01.2 (which doesn't exist in Bochs RC file).
The following line addition:

Code: Select all

chipset=i440fx
defines the mobo chipset. The Intel i440fx has a builtin UHCI controller on the mobo. Therefore, you are seeing this controller as well.

If this was a real physical machine, you would see a UHCI on the mother board as well as an PCI EHCI card plugged into one of the PCI slots, though the mother board's UHCI controller is handled (nearly) exactly as if it was a card plugged into one of the PCI slots as well.

Ben
- https://www.fysnet.net/osdesign_book_series.htm