OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Aug 19, 2019 1:25 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Detecting ports on UHCI
PostPosted: Wed Feb 13, 2019 3:36 pm 
Offline

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 6
I am working on a UHCI driver.
When I boot my OS on Qemu or Bochs, it says there is a UHCI system with a device connected to the roothub.
When I boot my OS on real hardware, it says there is a UHCI system but it is not able to detect any device on the roothub.

The code I wrote:
https://github.com/AdeRegt/SanderOSUSB/tree/uhci_2

As you can see I did not put the "RUN" bit on because I have no idea how to run it and that the system is not doing anything (in case we have no devices attached) .
Does anyone have an idea of how to detect if a device is attached?

Thank you very much in advantage!!


Top
 Profile  
 
 Post subject: Re: Detecting ports on UHCI
PostPosted: Wed Feb 13, 2019 8:52 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 560
Location: USA
I'm afraid to tell you that the USB is pretty much undefined until the Run bit is set. Sorry.

You can easily point it to a "dead" schedule and set the run bit. i.e.: The frame pointer can have a single dword pointing to itself or have 1024 entries all having the 'T' bit set.

Either way, real hardware may not function as specified until the Run bit is set.

Also, emulators don't have a timing issue whereas real hardware is very strict when it comes to timing. Make sure the timing between your reset and "un"reset and after the reset sequence is correct.

My book, linked below, goes into quite a bit of detail about all of this. However, feel free to continue to post your questions here. I try to visit about once a week and help as much as I can.

Ben
- http://www.fysnet.net/the_universal_serial_bus.htm


Top
 Profile  
 
 Post subject: Re: Detecting ports on UHCI
PostPosted: Sun Feb 17, 2019 7:13 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 560
Location: USA
Just checking if adding a "dead" schedule and setting the Run bit allowed you to detect devices. If not, what is the status of your project?

Ben
- http://www.fysnet.net/osdesign_book_series.htm


Top
 Profile  
 
 Post subject: Re: Detecting ports on UHCI
PostPosted: Tue Feb 19, 2019 4:41 pm 
Offline

Joined: Tue Aug 30, 2016 1:31 pm
Posts: 6
Now the computer boots from the USB stick. the default state during boot is that it is running, but even then the bits of any device attached are switched off. I add some timer code to meet the 50ms sleep. Im afraid this does not help.

I updated the code on GitHub.

I tried the strategy to keep using the old queue to keep the system running and then wait a few seconds and then see if something is detected, but this does not seem to help. I first do a hardware reset (wait 50ms during reset), and then a port-reset(wait 50ms) and then wait two seconds before checking the registers for detections. should I send something specific to the port? should I maybe enable interrupts for UHCI?


Top
 Profile  
 
 Post subject: Re: Detecting ports on UHCI
PostPosted: Tue Feb 19, 2019 5:17 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 560
Location: USA
You power the port, then you remove power from the port.

Code:
  outportw(uhcibase+R_PORTS1,inportw(uhcibase+R_PORTS1) | 0b0000001000000000);
  outportw(uhcibase+R_PORTS2,inportw(uhcibase+R_PORTS2) | 0b0000001000000000);
 
  mssleep(5);
 
  outportw(uhcibase+R_PORTS1,(inportw(uhcibase+R_PORTS1) & 0b1111110111111111) | 0b0000000000000100);
  outportw(uhcibase+R_PORTS2,(inportw(uhcibase+R_PORTS2) & 0b1111110111111111) | 0b0000000000000100);

A port will not show a connection if there is no power....

Maybe you meant?
Code:
  outportw(uhcibase+R_PORTS1,(inportw(uhcibase+R_PORTS1) & ~0b1111110111111111) | 0b0000000000000100);
  outportw(uhcibase+R_PORTS2,(inportw(uhcibase+R_PORTS2) & ~0b1111110111111111) | 0b0000000000000100);

However, note that technically, depending on where you are in the setup, you should know exactly what bits are set, so:
Code:
  outportw(uhcibase+R_PORTS1,0b0000001000000100);
  outportw(uhcibase+R_PORTS2,0b0000001000000100);

works also. However, before you enable a port, you need to see if there is something connected, right?

Ben
- http://www.fysnet.net/the_universal_serial_bus.htm


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 9 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