OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: USB xHCI device connectivity
PostPosted: Mon Oct 17, 2022 8:26 pm 
Offline
Member
Member

Joined: Fri Nov 01, 2019 1:17 am
Posts: 95
Hi,
I have a working xHCI driver, it initialises ports, setup port related data structures and I can get usb descriptors. My confusion is in device connectivity, when a new device is connected, xHCI receive an PortStatusChange event from where I can get port number, from here how can I respond to the device? How device specific drivers are get loaded here?.... What are the steps ? How matured OS like linux handles device connectivity?..

Thanks,
Manas Kamal


Top
 Profile  
 
 Post subject: Re: USB xHCI device connectivity
PostPosted: Tue Oct 18, 2022 10:35 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
Kamal123 wrote:
My confusion is in device connectivity, when a new device is connected, xHCI receive an PortStatusChange event from where I can get port number, from here how can I respond to the device?
You do what you always do when a hub tells you there is something new. If the port tells you that there is now a device attached, you enumerate the device like normal. If it tells you there is now no device attached, you find all USB devices that used to be on that port and tell their drivers that the device was lost. How you do that specifically is up to you. Since each port connects to exactly one device directly, you can just send the event to the driver of that one device, and if it is a hub, it better have a list of its subordinate devices ready to tell those drivers that the device is gone now.

Kamal123 wrote:
How device specific drivers are get loaded here?.... What are the steps ?
You enumerate the port? Like you do during boot? Only now you only enumerate the single port that talked to you, not all of them. And that means you enable a slot for the port, reset the device on there, set its address, then read out its descriptors. And then the USB class drivers must tell you if they want to deal with the device or not.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: USB xHCI device connectivity
PostPosted: Fri Oct 28, 2022 7:47 pm 
Offline
Member
Member

Joined: Fri Nov 01, 2019 1:17 am
Posts: 95
Hello, thanks for reply and heartily sorry for being late, I do enumeration of port during startup of the driver, after initialisation of command ring, event ring, interrupt setup and all necessary setup. Now I got the idea how actually device connectivity works. I create a kernel thread which is responsible for initialising device context , command ring for default endpoint and all other necessary setup, whenever a new device is plugged into a port, _port_change_status_ event causes interrupt which finally wakeups the USB thread and drops a _new_device_ message with correct TRB index, and USB thread finally processes the message by initialising the required setup..
By default,USB thread is blocked. Now I got device hot plug working :D

https://github.com/manaskamal/aurora-xeneva/tree/master/Drivers%2Fusb

Thank you,
Manas Kamal


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 53 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