tokusan wrote:I found that the problem was that I didn't access to PORTSC registers as DWORD.
All Operational Registers, QEMU or other, must be accessed via DWORD reads and writes.
All Capability Registers, on QEMU, must be DWORD accessed. However, on real hardware, they can be BYTE or WORD accessed.
tokusan wrote:Now I'm confusing because not port 1 but port 5 returns 1. QEMU says:
Code: Select all
(qemu) info usb
Device 0.1, Port 1, Speed 480 Mb/s, Product QEMU USB Mouse
Why?
Also QEMU says:
Code: Select all
[email protected]:usb_xhci_port_read port 1, off 0x0000, ret 0x000202a0
[email protected]:usb_xhci_port_read port 2, off 0x0000, ret 0x000202a0
[email protected]:usb_xhci_port_read port 3, off 0x0000, ret 0x000202a0
[email protected]:usb_xhci_port_read port 4, off 0x0000, ret 0x000202a0
[email protected]:usb_xhci_port_read port 5, off 0x0000, ret 0x00020ee1
[email protected]:usb_xhci_port_read port 6, off 0x0000, ret 0x000202a0
[email protected]:usb_xhci_port_read port 7, off 0x0000, ret 0x000202a0
[email protected]:usb_xhci_port_read port 8, off 0x0000, ret 0x000202a0
(I didn't get these outputs when I accessed via bitfields.)
In my book, read Chapter 9, "Port Routing and Control" and look at Figure 9-1.
xHCI has a register set for the USB3 port *and* a register set for the USB2 port of a single socket.
i.e.: If a socket supports both USB 2 *and* USB 3, it will have two register sets.
QEMU, by default, supports four sockets, giving eight register sets. Four for the USB 3 and four for the USB 2. The first four are the USB 3 and the second four are the USB 2.
In the figure you show above, Port 5 is the first USB 2 register set.
If your keyboard (which is a USB 2 device) is plugged into the first socket, it will use the first USB 2 register set.
You have to parse the capabilities to find out where the Register sets are located. A controller can have the register sets any way it wants.
For example, QEMU has it as (if memory serves):
USB 3 - Socket 0
USB 3 - Socket 1
USB 3 - Socket 2
USB 3 - Socket 3
USB 2 - Socket 0
USB 2 - Socket 1
USB 2 - Socket 2
USB 2 - Socket 3
However, real hardware could have it as:
USB 2 - Socket 0
USB 2 - Socket 1
USB 2 - Socket 2
USB 2 - Socket 3
USB 3 - Socket 0
USB 3 - Socket 1
USB 3 - Socket 2
USB 3 - Socket 3
Or even:
USB 3 - Socket 0
USB 2 - Socket 0
USB 3 - Socket 1
USB 2 - Socket 1
USB 3 - Socket 2
USB 2 - Socket 2
USB 3 - Socket 3
USB 2 - Socket 3
You have to parse the controllers capabilities to find out.
Ben
-
http://www.fysnet.net/the_universal_serial_bus.htm