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

XHCI: Command/Event queue error
https://forum.osdev.org/viewtopic.php?f=1&t=56481
Page 1 of 1

Author:  SanderR [ Sun Sep 11, 2022 3:27 pm ]
Post subject:  XHCI: Command/Event queue error

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?

Author:  BenLunt [ Wed Sep 14, 2022 2:29 pm ]
Post subject:  Re: XHCI: Command/Event queue error

( 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

Author:  SanderR [ Thu Sep 15, 2022 11:12 am ]
Post subject:  Re: XHCI: Command/Event queue error

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.

Author:  BenLunt [ Thu Sep 15, 2022 4:56 pm ]
Post subject:  Re: XHCI: Command/Event queue error

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

Author:  Octocontrabass [ Thu Sep 15, 2022 6:02 pm ]
Post subject:  Re: XHCI: Command/Event queue error

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.

Author:  BenLunt [ Fri Sep 16, 2022 3:47 pm ]
Post subject:  Re: XHCI: Command/Event queue error

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.

Author:  Gigasoft [ Fri Sep 16, 2022 8:06 pm ]
Post subject:  Re: XHCI: Command/Event queue error

Interesting, it sort of works but is it supposed to run like molasses? Any chance of getting network booting to work?

Author:  Octocontrabass [ Sat Sep 17, 2022 3:44 pm ]
Post subject:  Re: XHCI: Command/Event queue error

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.

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