usb drive commands
Posted: Fri May 27, 2022 1:43 pm
Hello there.
I've been reading a bunch about USB and USB specifications (especially OHCI since it's what's available on the old laptop that currently serves as my testing hardware) over the last two weeks.
If I get it right, the os should talk to the Host Controller Interface in order to talk to a specific device. HCI are typically PCI devices and their memory space can be accessed through BAR0 and they require enabling bus mastering in order for them to reply as they typically talk via user-specified memory locations. There are many HCI types depending on the USB protocol version, but they all allow the os to send packets to specific functions.
You can read or send a packet to the USB device by queuing up a transfer descriptor in a space pointed to by an endpoint descriptor that contains a pointer to (I guess) memory on the bus, without paging as it has nothing to do with the CPU, the HCI being the bus master here (so I guess it would be possible to pipe those packets to another device on the bus, but it's more a subsidiary question).
I get that most USB devices don't have internal addresses as USB drives do, USB is more like a unified transaction protocol that establishes a master/slave transmission protocol.
So my current guess is that I have to implement at least 3 drivers :
1 for my HCI (in this case OHCI)
1 that uses my HCI driver to talk to USB devices by doing all the USB bus administration/wrapping USB packets
1 for the particular device I want to talk to
I guess USB drives have a standardized way to read data from address and write data to address, as well as commands to get information from them, and this way lives on USB, which is only the way to make information transit to them. I tried looking that up on the internet but I was unable to find this, so I guess I missed something. I know for a fact that the USB SET_ADDRESS command is likely not what i'm looking for. Can someone tell me if I get things wrong and if not, where to find this information ?
I've been reading a bunch about USB and USB specifications (especially OHCI since it's what's available on the old laptop that currently serves as my testing hardware) over the last two weeks.
If I get it right, the os should talk to the Host Controller Interface in order to talk to a specific device. HCI are typically PCI devices and their memory space can be accessed through BAR0 and they require enabling bus mastering in order for them to reply as they typically talk via user-specified memory locations. There are many HCI types depending on the USB protocol version, but they all allow the os to send packets to specific functions.
You can read or send a packet to the USB device by queuing up a transfer descriptor in a space pointed to by an endpoint descriptor that contains a pointer to (I guess) memory on the bus, without paging as it has nothing to do with the CPU, the HCI being the bus master here (so I guess it would be possible to pipe those packets to another device on the bus, but it's more a subsidiary question).
I get that most USB devices don't have internal addresses as USB drives do, USB is more like a unified transaction protocol that establishes a master/slave transmission protocol.
So my current guess is that I have to implement at least 3 drivers :
1 for my HCI (in this case OHCI)
1 that uses my HCI driver to talk to USB devices by doing all the USB bus administration/wrapping USB packets
1 for the particular device I want to talk to
I guess USB drives have a standardized way to read data from address and write data to address, as well as commands to get information from them, and this way lives on USB, which is only the way to make information transit to them. I tried looking that up on the internet but I was unable to find this, so I guess I missed something. I know for a fact that the USB SET_ADDRESS command is likely not what i'm looking for. Can someone tell me if I get things wrong and if not, where to find this information ?