Commit graph

27 commits

Author SHA1 Message Date
cinap_lenrek be0a80faf3 nusb/disk: use setalt(), print argv0 in prints instead of "disk:" 2022-02-23 18:38:28 +00:00
cinap_lenrek 065d601916 nusb: Fix handling of interface altsetting.
The altsetting was handled only for a single endpoint
(per interface number), but has to be handled for each
endpoint (per interface *AND* altsetting number).

A multi function device (like a disk) can have
multiple interfaces, all with the same interface number
but varying altsetting numbers and each of these
interfaces would list distict endpoint configurations.

Multiple interfaces can even share some endpoints (they
use the same endpoint addresses), but
we still have to duplicate them for each
interface+altsetting number (as they'r part of
actually distict interfaces with distict endpoint
configurations).

It is also important to *NOT* make endpoints bi-directional
(dir == Eboth) when only one direction is used in a
interface/altsetting and the other direction in another.
This was the case for nusb/disk with some seagate drive
where endpoints where shared between the UAS and
usb storage class interface (but with distict altsettings).

The duplicate endpoints (as in using the same endpoint address)
are chained together by a next pointer and the head
is stored in Usbdev.ep[addr], where addr is the endpoint
address. These Ep structures will have distinct endpoint
numbers Ep.id (when they have conflicting types), but all
will share the endpoint address (lower 4 bits of the
endpoint number).

The consequence is that all of the endpoints configuration
(attributes, interval) is now stored in the Ep struct and
no more Altc struct is present.

A pointer to the Ep struct has to be passed to openep()
for it to configure the endpoint.

For the Iface struct, we will now create multiple of them:
one for each interface *AND* altsetting nunber,
chained together on a next pointer and the head being
stored in conf->iface[ifaceid].

--
cinap
2022-02-21 19:50:16 +00:00
cinap_lenrek 1b619dea42 nusb/disk: revert previous attempts and just not issue capacity command when theres no media present 2018-12-24 19:06:01 +01:00
Ori Bernstein ee9b29550f Make the check work.
Embarrassing.
2018-12-23 23:10:42 -08:00
cinap_lenrek c80f22f74a nusb/disk: implement 64 bit lba read/write commands (16 byte commands)
untested.
2018-12-24 05:10:43 +01:00
cinap_lenrek 2aec1f8a09 nusb/disk: fix typo "(" 2018-12-24 05:05:41 +01:00
Ori Bernstein bb151fa789 Don't unnecessarily unstall devices.
Some SD card readers are slow to unstall. We try to unstall them
in a loop if there's no SD card in there, but they're not stalled.
They're happily reporting that there's no SD card in them by giving
back the appropriate error code.

Skipping the unstall speeds up the retry loop, cutting the time spent
attaching the USB device at boot from multiple minutes to nearly instant.
2018-12-23 19:44:58 -08:00
mischief 2d221e61e3 nusb/disk: also drive usb attached scsi devices 2018-10-15 04:14:59 -07:00
cinap_lenrek a2e8246ffc nusb: add missing header dependencies to mkfiles 2018-02-18 02:06:55 +01:00
cinap_lenrek 153793714e nusb/disk: add a 100ms sleep after ums reset, remove unused note handler, cleanup
my pretec usb stick sometimes hangs on the first inquiry request,
waiting for the inquiry response forever. adding a 100ms delay after
the reset command seems to fix it.

getting rid of unused "ding()" note handler and simplify umsrequest()
incomplete read handling.
2017-08-11 01:00:09 +02:00
cinap_lenrek 56ac6ea29e nusb/*: cleanup 2017-07-31 15:29:08 +02:00
cinap_lenrek 772afbe98c format pointer subtraction results with %zd instead of %ld (for long -> intptr on amd64) 2016-01-07 04:44:13 +01:00
cinap_lenrek 3ceedfd1e1 nusb/disk: adding identical partition is a no-op 2015-05-30 22:24:55 +02:00
cinap_lenrek 336e605a11 support for huawei e220 g3 modem, cleanup nusb/serial 2014-07-05 23:19:13 +02:00
cinap_lenrek 4275c49e72 nusb: implement aijus stable uniqueue device names
instead of naming devices by ther dynamically assigned device address,
we hash device uniqueue fields from the device descriptor and produce
a 5 digit hex string that will identify the device across machines.

when there is a collision (less than 1% chance with 100 devices),
usbd will append the device address to the name to make it uniqueue
for this machine.

the hname is passed to drivers in the devid argument, which now has
the form addr:hname, where the colon and hname can be omited (for backwards
compatibility).

when the new behaviour isnt desired, nousbhname= environment variable
can be defined giving the old behaviour.
2014-06-28 18:09:43 +02:00
cinap_lenrek 4a9f900726 mkfiles: do not rely on path containing the . element
when executing generated binaries and helper scripts,
always execute them as ./name instead of relying that
path contsins the dot.
2013-10-26 20:22:01 +02:00
cinap_lenrek 965bb2d248 nusb/disk: handle blocking usb access with srv released
usb is bound after /dev, so a hanging usb device will hang
access to /dev. we avoid this by releasing the srv, which
allows the fs to still handle reads and walks of the
directories.

ios are serialized by a qlock in the Umsc structure.
2013-10-16 12:26:56 +02:00
cinap_lenrek 9f25f9504a nusb/disk: add small delay after unit start command (for thinkpad sdcard reader)
diskparts fails on thinkpad x200 sdcard reader if we dont
give the unit some time to startup. the device took about
100ms to become ready so status poll loop with a long
timeout would be overkill.
2013-03-10 04:06:42 +01:00
cinap_lenrek af3dad5490 nusb/disk: allow 12 and 16 byte raw scsi commands (from erik quanstro) 2013-02-13 10:03:53 +01:00
cinap_lenrek 8c81499659 scsi: do only 36 byte inquiry
some devices freeze up with inqiry allocation length
other than 36 bytes. as we do not really care about
the vendor specific part of the inquiry, lets only do
36 byte inquiry for now.
2013-01-03 20:46:25 +01:00
cinap_lenrek 424f8a9520 nusb: debug flags 2012-03-01 18:56:54 +01:00
cinap_lenrek f2b6ec3140 correcting unicode superscripts for 1 2 and 3 2012-02-23 16:58:53 +01:00
cinap_lenrek a4d2297e96 nusb/disk: small clenups 2011-08-19 05:20:42 +02:00
cinap_lenrek b43de8eb1f nusb: fix usage inconsitency, shr names 2011-08-01 02:36:02 +02:00
aiju 6aed9711b4 devshr: changed #σc to contain directories
nusb: detaching
2011-07-30 14:30:27 +02:00
aiju e3cc408215 nusb/disk: adaption to lib9p 2011-07-28 14:20:00 +02:00
aiju 05d09f086f nusb: improved 2011-07-27 20:07:30 +02:00