[haiku-gsoc] Re: Issues in the USB Stack

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Tue, 5 Aug 2014 23:48:30 +0200

Hi Akshay!

2014-08-05 17:08 GMT+02:00 Akshay Jaggi <akshay1994.leo@xxxxxxxxx>:
> There are three issues I would like to discuss.
>
> Firstly, I propose making public the usb_raw.h header. We can make ioctls to
> usb file descriptors from userland but we need this header, and this is not
> present in the include headers. This is used by USBKit, and also by the
> Libusb port I have been working on.

I think we don't really want too many users of such an API, which is
the reason it stayed private until now. This lets us modify it when we
need without too much thinking. Is having a copy of the header in
Libusb OK?

> Secondly, there is no way to get the device address assigned to a USB
> device, in userland. To add, every bus manager (EHCI, UHCI, ..) supports
> upto 127 unique devices, each of which is given an address from 1 to 127
> during device initialisation[1]. This is to uniquely identify every device
> connected to a host-controller/bus-manager. Libusb also requires this device
> address, so maybe we can add an ioctl to usb_raw, for getting this address
> in userland.

The USB stack doesn't use the device address, and is only there to be
used by bus drivers.
Not sure why this is required by libusb, it's only informative, right?

>
> Thirdly, we have no way to get the complete configuration descriptor for any
> usb device. B_USB_RAW_COMMAND_GET_DESCRIPTOR truncates the descriptor to
> bLength field of the descriptor, while the total length for a configuration
> descriptor is defined in wTotalLength [2][3].

This IOCTL only handles usb_generic_descriptor. You should probably
use B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR instead, and patch
it to use "total_length":
* if the provided buffer is exactly the size of
usb_configuration_descriptor, then just copy that length and return
OK.
* if the provided buffer is bigger but too small, then copy that
length and return B_BUFFER_OVERFLOW.
The USBKit can eventually be extended later.

Bye,
Jérôme

Other related posts: