Fix for quirky devices which report bad residues
There's a class of devices which manage to get the dCSWDataResidue value wrong (for example, reversed endianness, or just garbage). This causes an error to be propagated up to SCSIDriver in and the initial CDB_CAPACITY to fail (only 8 bytes are expected). The error response is to fill the capacity with 0xFFFFFFFF's, which are then reported as a device of apparently 512TB in size. Take the stance that umass.c revision 1.146 in NetBSD takes, and simply ignore the device's residue; use the actual number of bytes transferred by the USB stack instead. umass.c: Compute dCSWDataResidue locally. global.h: Fix debug build, pointer type of states needs constifying. glue.c: Simplify the entry to glue_Tick; it is assumed to be entered with interrupts disabled, and all exits restore the interrupt state, so unconditionally disable - note that this is only needed for debugging when debuglib might enable interrupts for some output types, and thus allow reentrancy via RTSupport. Clean up a few comments in passing. Tested with a known bogus USB stick - now mounts successfully. Ref: Elesar ticket #78A-D76-74EC3. Version 0.27. Tagged as 'SCSISoftUSB-0_27'
Showing with 30 additions and 27 deletions