Multimedia Commands

25 Mar

Multimedia Commands
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.

READ TOC/PMA/ATIP
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.

Decoding Commands
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.
byte *ptrNextData;
void MSDCommandHandler(void)
{
switch(gblCBW.CBWCB[0]) {
case INQUIRY:
MSDInquiryHandler();
break;
case READ_CAPACITY:
MSDReadCapacityHandler();
break;
case READ_10:
MSDReadHandler();
break;
case WRITE_10:
MSDWriteHandler();
break;
case REQUEST_SENSE:
MSDRequestSenseHandler();
break;
case MODE_SENSE:
MSDModeSenseHandler();
break;
case TEST_UNIT_READY:
MSDTestUnitReadyHandler();
break;
case VERIFY:
MSDVerifyHandler();
break;
case STOP_START:
MSDStopStartHandler();
break;
default:
// Use for all unsupported commands.
ResetSenseData();
gblSenseData.SenseKey=S_ILLEGAL_REQUEST;
gblSenseData.ASC=ASC_INVALID_COMMAND_OPCODE;
gblSenseData.ASCQ=ASCQ_INVALID_COMMAND_OPCODE;
msd_csw.bCSWStatus=0×01;
msd_csw.dCSWDataResidue=0×00;
break;
}
// Reset the data pointer to the beginning of the buffer.
ptrNextData=(byte*)&msd_buffer[0];
}

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.

Random Posts

No comments yet

Leave a Reply

You must be logged in to post a comment.