OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:26 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: XHCI: Command/Event queue error
PostPosted: Sun Sep 11, 2022 3:27 pm 
Offline
Member
Member

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 69
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?


Top
 Profile  
 
 Post subject: Re: XHCI: Command/Event queue error
PostPosted: Wed Sep 14, 2022 2:29 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
( 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


Top
 Profile  
 
 Post subject: Re: XHCI: Command/Event queue error
PostPosted: Thu Sep 15, 2022 11:12 am 
Offline
Member
Member

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 69
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.


Top
 Profile  
 
 Post subject: Re: XHCI: Command/Event queue error
PostPosted: Thu Sep 15, 2022 4:56 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
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


Top
 Profile  
 
 Post subject: Re: XHCI: Command/Event queue error
PostPosted: Thu Sep 15, 2022 6:02 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: XHCI: Command/Event queue error
PostPosted: Fri Sep 16, 2022 3:47 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
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.


Top
 Profile  
 
 Post subject: Re: XHCI: Command/Event queue error
PostPosted: Fri Sep 16, 2022 8:06 pm 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 852
Interesting, it sort of works but is it supposed to run like molasses? Any chance of getting network booting to work?


Top
 Profile  
 
 Post subject: Re: XHCI: Command/Event queue error
PostPosted: Sat Sep 17, 2022 3:44 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 42 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group