Each of the commands below is documented in the Multimedia Commands (MMC) specification.
READ FORMAT CAPACITIES
The READ FORMAT CAPACITIES command requests a structure containing one or more descriptors that specify a number of blocks and a block length that the media can be formatted for.
The device returns the structure in the data-transport phase. If the media is currently formatted, the first descriptor in the structure contains the values in use. If the media is unformatted, the first descriptor in the structure contains the values that will result in the maximum storage capacity. One or more alternate descriptors with different values can follow. This command is optional for SBC devices.
Devices with CD or DVD media use the READ TOC/PMA/ATIP command to provide data from a table of contents (TOC), data from the program memory area (PMA), and absolute time in Pre-Grove (ATIP) data. The format of the response varies with the response type. The ATIP data contains information required by CD burners. The ATIP format is defined in “orange books” that Philips Electronics provides to companies with whom Philips has a CD-information or license agreement. SBC devices aren’t likely to need this command and aren’t required to support it.
Handling Commands and Events
On receiving a command, firmware must decode the command and prepare an appropriate response.
The SCSI command codes can have assigned friendly names:
#define INQUIRY 0×12
#define READ_FORMAT_CAPACITY 0×23
#define READ_CAPACITY 0×25
#define READ_10 0×28
#define WRITE_10 0×2a
#define REQUEST_SENSE 0×03
#define MODE_SENSE 0×1a
#define TEST_UNIT_READY 0×00
#define VERIFY 0×2f
#define STOP_START 0×1b
The MSDCommandHandler function decodes a received command code
and branches to one of the functions in this chapter to respond to the command.
If the command isn’t supported, the code sets the sense data and
fields in bCSWStatus.
// Use for all unsupported commands.
// Reset the data pointer to the beginning of the buffer.
The UNIT ATTENTION Condition
When something changes that the host needs to know about before accessing the media, the device should generate a UNIT ATTENTION condition. Changes that require the UNIT ATTENTION condition include inserting removable media, a change in INQUIRY data, and a reset of the device or a logical unit.
A device in the UNIT ATTENTION condition should fail all commands except INQUIRY, REPORT LUNS, and REQUEST SENSE. On receiving a command other than these, a device should return 01h (command failed) in the bCSWStatus field of the CSW. The host then sends a REQUEST SENSE command to obtain status information.
In preparing a response to the REQUEST SENSE command, the device sets the SENSE KEY field to 06h (UNIT ATTENTION) and sets the ASC and ASCQ fields of the sense data to describe the reason for the condition. After returning the sense data, the device is no longer in the UNIT ATTENTION condition.