XHCI: Command/Event queue error

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

XHCI: Command/Event queue error

Post by SanderR »

Hello everyone,

I am trying to write me XHCI driver for 64 bit:
https://github.com/AdeRegt/SanderOS64/b ... ers/xhci.c

My system is able to send a NOOP request on the command ring and receive a response on the event ring.
But when I try to trigger an Enable Slot Command the system does not respond.

What am I doing wrong?
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: XHCI: Command/Event queue error

Post by BenLunt »

( Sorry, I have been away for a while. )

To me, it doesn't look like your hdd.vhd file is bootable. It has the vhd footer at the start of the image as well. Do you have a bootable image that I could test? If so, is it a 512-byte hard drive image, 2048-byte cdrom, etc., and how do you boot it? Legacy or (U)EFI.

Do you run your code through Bochs? If so, you can run in Debug mode and the xhci emulation will print a bunch of text to the debug file. If you can compile Bochs yourself, you can add debug lines to see exactly what is going on. Where the ring is, how many items are on the ring, what the Input Context is at time of Enable Slot, etc. Please note that Bochs requires Legacy boot.

Again, I apologize for not helping here on this forum lately. I have been quite busy with other things. Now that the summer is ending, I may have more time to visit.

Ben
- https://www.fysnet.net/the_universal_serial_bus.htm
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

Re: XHCI: Command/Event queue error

Post by SanderR »

Thank you for your answer.
I had brought your USB book and it really is a gem!

The system I am making right now boots with 86_64 UEFI.
I did not know that Bochs supported UEFI. I will have a look at it.

Just before I read your answer, I solved the question: my system was unable to reach the eventTRB because the loop was too narrow.
However, I am testing the code on two real hardwares.
I am looping through the PORTSC registers, checking if the CCS and PED flags are both set.
On both of me real hardware, this is working.
However, when I am reading me PLS value in PORTSC, it says it returns for most of the ports the value of 3, which means it is U3->device suspended.
I am not sure why it is not in a U0 state. On me real hardware there is just one port that turns into a U0 state.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: XHCI: Command/Event queue error

Post by BenLunt »

SanderR wrote:The system I am making right now boots with 86_64 UEFI.
I did not know that Bochs supported UEFI. I will have a look at it.
Please note that Bochs does not support UEFI. Sorry if I misled you on that. I use Bochs to test my code. It is a simple task to add a BXDEBUG() line almost anywhere. Also, I have it so that if the guest sends a specific Vendor command, Bochs will output a specific report. It is quite simple to debug my code using Bochs.

However, it does require a Legacy Boot. If you are UEFI only, then Bochs would even boot it, unfortunately. I have actually put a little work into making Bochs UEFI compatible, but unfortunately, it is so (Legacy) BIOS dependent, it would take a considerable amount of work to make it UEFI compatible, so I dropped the cause.
SanderR wrote:However, when I am reading me PLS value in PORTSC, it says it returns for most of the ports the value of 3, which means it is U3->device suspended.
I am not sure why it is not in a U0 state. On me real hardware there is just one port that turns into a U0 state.
If you only have one physical port (called a socket), then only one (USB3 protocol) register set should return U0. The remaining should be undefined, possibly returning U3. Or did I misunderstand what you where asking?

On a different note, I am glad to see the progress you have made. I can remember the earlier questions you sent me. I miss this hobby we have and am actually, little by little, re-writing my whole system. I have dropped all Legacy support and now boot UEFI only, directly to the GUI, supporting only hardware that is no more than 20 years old, not counting UHCI and OHCI :-)

Enjoy,
Ben
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: XHCI: Command/Event queue error

Post by Octocontrabass »

BenLunt wrote:Please note that Bochs does not support UEFI.
Yes it does! You need to change some settings, the defaults don't work with OVMF.

You could also try QEMU's event tracing. I haven't tried tracing XHCI, but it worked very well for tracing AHCI when I tried it.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: XHCI: Command/Event queue error

Post by BenLunt »

Octocontrabass wrote:
BenLunt wrote:Please note that Bochs does not support UEFI.
Yes it does! You need to change some settings, the defaults don't work with OVMF.
I was unaware of that. I even missed Stanislav saying 'Hi'. Guess I should have continued to watch that thread after posting in it.

I haven't tried UEFI with Bochs since before that post and never saw anything to convince me otherwise, so I assumed so. I should know what happens when I assume.

Thanks for the catch. I am interested in seeing if I can get it to work.

Thanks,
Ben

Update: I can confirm. With a few modifications to your OVMF.bxrc file to accommodate my work, Bochs booted my UEFI enabled FYSOS image. Thank you Octocontrabass for the reply.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: XHCI: Command/Event queue error

Post by Gigasoft »

Interesting, it sort of works but is it supposed to run like molasses? Any chance of getting network booting to work?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: XHCI: Command/Event queue error

Post by Octocontrabass »

Gigasoft wrote:Interesting, it sort of works but is it supposed to run like molasses?
You may be able to adjust some settings in your bochsrc to speed it up, but it will always be slower than QEMU.
Gigasoft wrote:Any chance of getting network booting to work?
I think it's possible with ne2k or e1000. You might need to provide a separate ROM containing iPXE using the "bootrom" parameter.
Post Reply