Hey guys, so I have been writing an UHCI Driver, and it works. I just have one question that the manuals and documentation I have doesn't exactly explain, and I was wondering if someone here knew. So in a USB Packet or TD as some call it, there's a Device address field. According to documentation any device unconfigured will respond to Address 0. Cool right? Well I have a UHCI Controller on my computer, and I plugged in two USB drives into it and ran my Os. I requested the Device Descriptor once for every device plugged into the two root ports "2 devices" and I got the first drivers descriptor the first time, and the second one the other time. My question is, how do I assign a device that was just plugged in an Device Address and know it when to the one connected to that port? Or does that really matter and I should just assign it the address before getting the descriptor and then mark that address as used and then get the descriptor?
Thanks guys.
Matt
UHCI Simple question help?
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: UHCI Simple question help?
The USB enumeration process is documented in the USB Standard (iirc as a state machine).
Basic process is:
1. A hub detects a device is connected to a port and tells the USB stac (this could be the root hub or a previously enumerated child hub)
2. The USB stack tells the hub to do a port enable and reset, bringing the device into a usable state (just without an address, so it responds to 0)
3. The stack then allocates an address and sends a SET_ADDRESS command to device 0 on that bus.
4. The device now has its address configured, and can be queried uniquely via that.
5. Repeat from step 1 (make sure that you don't have two devices on the same bus listening for address 0 at the same, otherwise things get confusing).
Basic process is:
1. A hub detects a device is connected to a port and tells the USB stac (this could be the root hub or a previously enumerated child hub)
2. The USB stack tells the hub to do a port enable and reset, bringing the device into a usable state (just without an address, so it responds to 0)
3. The stack then allocates an address and sends a SET_ADDRESS command to device 0 on that bus.
4. The device now has its address configured, and can be queried uniquely via that.
5. Repeat from step 1 (make sure that you don't have two devices on the same bus listening for address 0 at the same, otherwise things get confusing).
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: UHCI Simple question help?
Yes, this is important. It is especially important to note that this also applies to USB hubs, which means that the RESET process of USB ports needs a per-function mutex if these tasks are handled by different threads.thepowersgang wrote: (make sure that you don't have two devices on the same bus listening for address 0 at the same, otherwise things get confusing).
Re: UHCI Simple question help?
Thanks guys! I got it to work.
- Matt
- Matt