Currently I am just trying to make a "hello world" xhci driver which only prints the contents of the event TRB generated by a NOOP TRB in the command ring, but it just doesn't work in VirtualBox, so I tried to look around for another osdever who successfully did something similar in an operating system simple enough to study it's source code, and ended up with SanderOSUSB:
https://github.com/AdeRegt/SanderOSUSB/ ... dev/xhci.c
However, when I compile and test this operating system in VirtualBox, I get this error message:
Code: Select all
[XHCI] Incompatible device!
https://github.com/AdeRegt/SanderOSUSB/ ... hci.c#L788
What causes this message to be printed is that the Serial Bus Release Number Register's value (sbrn variable) is 0x20 instead of 0x30 or 0x31. The xhci specs clearly states in chapter 5.2.3 that the value of this register must be 0x30, 0x31 or 0x32. I checked the value of this register and it's value is 0x20 in VirtualBox. If that number represent the release of the usb specification the xhci is compilant with, there shouldn't be any problem regarding the usage of the Command Ring, since it does not involve any transaction with any usb device and (I think) the usb specification is not involved here and it should not be a problem (The usb protocol does not have anything to do with how the command ring should work, right?)
So I commented out that check to see if the event ring works: https://github.com/AdeRegt/SanderOSUSB/ ... ci.c#L1027
I commented out line 1033 and added an infinite loop to stop execution between lines 1036 and 1037. When I executed the operating system again this time instead the OS got stuck in the infinite loop at line 660. When I read the event ring from my operating system I only get zeroes, and I am starting to suspect that the xhci just doesn't work properly in VirtualBox. However, if that were the case, How do current operating systems like Linux or Windows make it work? I tried to study the xhci driver of linux, but it is a mess and the kernel is a monster extremely complex and not really worth to study to learn how to make my xhci driver work because it would take me forever to understand enough to find what I am doing wrong right now.
Can anyone explain why VirtualBox's xhci device return that Serial Bus Release Number Register's value and why apparently the Event Ring doesn't work?
The SanderOSUSB's developer didn't even bother to try to check event ring functionality in QEMU, as you can see here:
https://github.com/AdeRegt/SanderOSUSB/ ... ci.c#L1027
Why does QEMU fails miserably testing the ring? Can you make it work in QEMU, or is it doomed to not work at all?
And most importantly, Could anyone please share a repository with a proof of concept operating system to demonstrate xhci functionality (preferable if it works, at least, in Qemu and VirtualBox)? What I mean by this is an operating system as simple as possible that stores or reads a byte in a USB mass storage device or detect a USB keyboard key press. I know this is too much to ask for but if someone by chance has this, it would be extremely helpful to have it.
Thanks in advance.