25 Mar

The PREVENT ALLOW MEDIUM REMOVAL command requests the device to prevent or allow users to remove the storage media from the device. A 2-bit PREVENT field in the command is set to 00b to allow media removal or 01b to prohibit removal. The command has no data-transport phase. Support for this command is optional. Of course,

many devices have non-removable media or use flash-memory cards or other media with no mechanism to prevent removal. Flash drives that fail this command when PREVENT = 01 have improved performance. When the command fails, Windows doesn’t enable write caching. Write caching causes Windows to launch multiple threads that cause random writes, which result in slow write performance on flash media.

The REPORT LUNS command requests a list of the numbers of all logical units that are present and that match the peripheral device type returned in response to an INQUIRY command. The response can also optionally include the numbers of logical units that currently have no device present. A device should be able to respond to this command without having to access the media and even when the device isn’t ready to respond to other commands. The SBC-2, SBC-3, and SPC-3 specifications all list this command as mandatory. The command is optional in SPC-2, however.

The REQUEST SENSE command requests a structure containing sense data. The specification says that the ALLOCATION LENGTH parameter in the request should always equal 252 bytes to enable devices to return all of their sense data, including vendor-specific data. Windows hosts typically request just the first 18 bytes, however. For this reason, device vendors often use vendor-specific control requests to obtain additional sense data if needed. The REQUEST SENSE command is mandatory for SBC devices.

The command descriptor block for this command is 6 bytes. However, the Windows driver sets bCBWCBLength in the CBW to 0Ch instead of 06h. This incorrect value doesn’t affect the number of bytes that transmit on the bus because the CBW is always 31 bytes with 16 bytes reserved for the command descriptor block. Device firmware should accept the incorrect value and ignore the additional declared 6 bytes.

The MSDRequestSenseHandler function copies data from the gblSense- Data array into msd_buffer for returning to the host. The function also sets values in the CSW.

void MSDRequestSenseHandler(void)
byte i;
for (i = 0; i < sizeof(RequestSenseResponse); i++)
msd_buffer[i] = gblSenseData._byte[i];
msd_csw.dCSWDataResidue = sizeof(RequestSenseResponse);
msd_csw.bCSWStatus = 0×0; // success

Random Posts

No comments yet

Leave a Reply

You must be logged in to post a comment.