Common¶
This module contains common commands, that other device classes can support.
- squishy.scsi.commands.common.TestUnitReady = <SCSICommand opcode:00 group:0 fields: 2>¶
 Test Unit Ready
This command provides the means to check if the logical unit is ready.
It does not trigger an internal self test on the target.
If the logical unit would accept an appropriate medium-access command without returning a
CHECK CONDITIONstatus this command shall return aGOODstatus.
- squishy.scsi.commands.common.RequestSense = <SCSICommand opcode:03 group:0 fields: 3>¶
 Request Sense
This command requests that the target transfers Sense Data to the initiator.
The sense data shall be valid for a
CHECK CONDITIONstatus returned on the prior command. It will also be preserved by the target for the initiator until it is retrieved by theREQUEST SENSEcommand, or until the receipt of any other command for the same LUN from the initiator that issues the command resulting in theCHECK CONDITIONstatus.Sense data shall be cleared upon receipt of any subsequent command to the LUN from the initiator receiving the
CHECK CONDITIONstatus. In the case of a single initiator the target must assume that theREQUEST SENSEScommand is from the same initiator.The
AllocLenfield specifies the number of bytes that the initiator has allocated for the returned sense data. An allocation length of zero indicates that four bytes of sense data will be transferred. Any other value indicates the maximum number of bytes to be transferred. The target must terminate theDATA INphase whenAllocLenbytes have been sent to the initiator or when all sense data has been exhausted, whichever is less.The
REQUEST SENSEcommand shall return theCHECK CONDITIONstatus only to report fatal errors for the command. for example:The target receives a non-zero reserved bit in the command descriptor block.
An unrecovered parity error occurs on the data bus.
A target malfunction prevents the return of sense data.
If any non-fatal error occurs during the execution of the
REQUEST SENSEcommand then the target shall return the sense data with aGOODstatus. On fatal errors sense data may be invalid.A target may implement the non-extended, the extended, or both sense data formats.
Note
Targets that implement both sense data formats may select the non-extended sense data format in response to an allocation length of zero, other methods of selection are also feasible.
The format of the sense data is determined by the error class. Error classes
0through6use the non-extended sense data, error class7uses the extended sense data.The non-extended sense data is depicted below:
Non-extended Sense Data
Byte
7
6
5
4
3
2
1
0
0AddrValid
Error Class
Error Code
1Vendor Unique
LBA (MSB)
2LBA
3LBA (LSB)
The
AddrValidflag indicates that the LBA field contains valid information related to the error code.The error class specified the class of errors, classes
0through6are all vender unique, the error code for the class is also vendor unique.For extended sense data, the error class is fixed to
7, but extended sense data will only be returned if the error code is0. Error code15specifies a vendor unique data format for the extended sense data. Error codes1tough14are reserved.The extended sense data format is depicted below:
Extended Sense Data
Byte
7
6
5
4
3
2
1
0
0Valid
1
1
1
0
0
0
0
1Segment Number
2File Mark
EOM
ILI
Res
Sense Key
3Information Byte
4Information Byte
5Information Byte
6Information Byte (LSB)
7Additional Sense Length (
n)8to
n+7Additional Sense Bytes
If
Validis not set, then the data inInformation Byteis undefined, otherwise it is defined as follows:The unsigned LBA associated with the sense key, for type 0, type 4 and type 5 devices.
The difference of the requested length minus the actual length in bytes or blocks. As determined by the command, for type 1, type 2, and type 3 devices.
The difference of the requested number of blocks minus the actual number of blocks copied or compared for the current segment descriptor of a
Copy,Compare, orCopyAndVerifycommand.
The
Segment Numberfield contains the number of the current segment descriptor if the extended sens is in response to aCopy,Compare, orCopyAndVerifycommand. Up to256segments are supported.The
File Markflag indicates that the current command has read a file mark, and is only used on sequential-access devices.The
EOMor End of Medium flag indicates that an end-of-medium condition (EOT, BOT, Out of paper, etc) exists on a sequential access or printer device. For sequential access devices, this flag indicates that the unit is at or past the early-warning EOT if the direction was forward or that the command could not be completed due to a BOT being encountered if the direction was reverse. Direct access devices must not use this flag, instead they must report attempts to access beyond EOM as anILLEGAL REQUESTsense key.The
ILIor Incorrect Length Indicator flag indicates that the requested logical block length did not match the logical block length of the data on the medium.The value of the
Sense Keyfield is described as follows:Todo
Move this to an enum in command.py
Sense Key
Description
0x0No Sense. Indicates that there is no specific sense key information to be reported for the designated logical unit. This would be the case for a successful command or a command that received a
CHECK CONDITIONstatus due to one of theFile Mark,EOM, orILIflags being set.0x1Recovered Error. Indicates that the last command completed successfully with some recovery action performed by the target. Details may be determined by examining the additional sense bytes and information bytes.
0x2Not Ready. Indicates that the logical unit addressed cannot be accessed. Operator intervention may be required to correct this.
0x3Medium Error. Indicates that the command terminated with a non-recovered error condition that was likely caused by a flaw in the medium.
0x4Hardware Error. Indicates that the target detected a non-recoverable hardware failure while performing the command or during a self-test.
0x5Illegal Request. Indicates that there was an illegal parameter in the command descriptor block or in the additional parameters supplied as data for some commands. If the target detects an invalid parameter in the command descriptor block then it must terminate the command without altering the medium. If the target detects an invalid parameter in the additional parameters supplied as data, then it may alter the medium
0x6Unit Attention. Indicates that the removable medium may have been changed or the target has been reset.
0x7Data Protect. Indicates that a command that reads or writes the medium was attempted on a block that is protected, and the op was not done.
0x8Blank Check. Indicates that a WORM device or a sequential-access device encountered a blank block while reading, or a WORM device encountered a non-blank block while writing.
0x9Vendor Unique. This sense key is available for reporting vendor unique conditions.
0xACopy Aborted. Indicates a
Copy,Compare, orCopyAndVerifycommand was aborted due to an error condition on the source device, destination device, or both.0xBAborted Command. Indicates that the target aborted the command. The initiator may be able to recover by trying the command again.
0xCEqual. Indicates tha a
SearchDatacommand has satisfied an equal comparison.0xDVolume Overflow. Indicates that a buffered peripheral device has reached the end-of-medium and data remains in the buffer that has not been written to the medium. A
RecoverBufferedDatacommand(s) may be issued to read the unwritten data from the buffer0xEMiscompare. Indicates that the source data did not match teh data read from the medium.
0xFReserved
The
Additional Sense Lengthspecifies how many additional bytes of sense data are to follow. If the allocation length of the command descriptor block is too small to transfer all of the additional data, theAdditional Sense Lengthis NOT adjusted to reflect the truncation.The
Additional Sense Bytescontains data that is command-specific, peripheral-device-specific, or both the further define the nature of theCHECK CONDITIONstatus. TheCopy,Compare,CopyAndVerify, andSearchDatacommands define a standard purpose for some of the bytes. Unless described in said commands, all additional sense bytes are vendor unique.
- squishy.scsi.commands.common.Inquiry = <SCSICommand opcode:12 group:0 fields: 3>¶
 Inquiry
This command requests that information regarding parameters of the target and its attached peripheral devices be sent to the initiator.
The
AllocLenfield specifies the number of bytes that the initiator has allocated for the returnedINQUIRYdata. AnAllocLenof zero indicates that noINQUIRYdata shall be transferred to the Initiator, and shall not be considered an error. Any other value indicates the maximum number of bytes that shall be transferred. The target must terminate theDATA INphase whenAllocLenbytes have been transferred or when all availableINQUIRYdata as been exhausted, which ever is less.The
INQUIRYcommand must return aCHECK CONDITIONstatus only when the target can not return the requestedINQUIRYdata.Note
It is recommended that the
INQUIRYdata be returned even though the peripheral device may not be ready for other commands.If an
INQUIRYcommand is received from an initiator with a pending unit attention condition, the target shall perform theINQUIRYcommand and shall not clear the unit attention condition.The data returned from the
INQUIRYcommand is described below:INQUIRYDataByte
7
6
5
4
3
2
1
0
0Peripheral Device Type
1RMB
Device-Type Qualifier
2ISO Ver
ECMA Ver
ANSI Ver
3Reserved
4Additional Length
5ton+4Vendor Unique
The
Peripheral Device Typeis one of the values insquishy.scsi.device.PeripheralDeviceTypeThe
RMBflag indicates that the medium is removable or not.The
Device-Type Qualifieriss a seven-bit user specified value. This value may be set with any means on the target or peripheral device. SCSI devices that do not support this feature must set it to all zeros (i.e. ``0b0000000``). This feature allows each user to assign a unique value to each specific type of peripheral device that is supported on the system being used. These values may then be used by the self-configuring software to determine what specific peripheral device is at each LUN.The
ISO Ver, andECMA Verfields describe to which version of the respective specifications the device compiles to. A zero value in theISO Verand/orECMA Verfields indicates that the target does not claim compliance to ISO or ECMA Versions of SCSI.Note
It is possible to claim compliance to more than one standard.
The
ANSI Verfield indicates the implemented version of the ANSI SCSI standard with the following values:Value
Description
0x0Version is unspecified
0x1Complies with
X3.313:19860x2to0x7Reserved
The
Additional Lengthfield specifies the length in bytes of the vendor unique parameters. If theAllocLeniss tool small to transfer all of the vendor unique data, the additional length is NOT adjusted to reflect the truncation.
- squishy.scsi.commands.common.Copy = <SCSICommand opcode:18 group:0 fields: 3>¶
 Copy
This command provides a means to copy data from one logical unit to itself or another. The logical units may reside on the same SCSI device or different SCSI devices.
Note
Some SCSI devices that implement this command may not support copying to or from another SCSI device, or copies where both logical units reside on another SCSI device.
The
ParamLenfield specifies the length in bytes of the parameters that are to be sent during theDATA OUTphase of the command. AParamLenof zero indicates that no data will be transferred, and must not be considered an error.The
COPYparameter list is structured as follows:COPYParameter ListByte
7
6
5
4
3
2
1
0
0Function Code
Priority
1Vendor Unique
2Reserved
3Reserved
NSegment descriptors…
The
Function Codefield defines the specific format for the segment descriptors, they are as follows:The
Priorityfield establishes the relative priority of theCOPYcommand to other commands being executed by the same target. All other commands are assumed to have a priority of1, with0being the highest priority, the larger the value the lower the priority of the command.The segment descriptor formats are designated by the
Function CodeDevice Type
Function Code
Segment Descriptor
Direction
Source
Dest
0x000x010x00Segment 1
Direct to Sequential
0x000x020x000x000x030x000x040x010x000x040x020x000x040x030x000x050x010x000x050x020x000x050x030x000x010x000x01Segment 1
Sequential to Direct
0x010x040x010x030x000x010x030x040x010x000x000x02Segment 2
Direct to Direct
0x000x040x020x040x000x020x040x040x020x050x000x020x050x040x020x010x010x03Segment 3
Sequential to Sequential
0x010x020x030x010x030x030x030x010x030x030x020x030x030x030x03The
Device Typeis defined by the values in thesquishy.scsi.device.PeripheralDeviceTypeenum.The
COPYfunction codes are as follows:Code
Description
0x00Direct to Sequential
0x01Sequential to Direct
0x02Direct to Direct
0x03Sequential to Sequential
0x04-0x0FReserved
0x10-0x1FVendor Unique
Note
There are two general categories of unusual condition that may occur during the execution of a
COPYcommand. THe first one is any unusual condition that are detected by the SCSI target that receives the command and is managing its execution. Examples of such conditions are parity errors, invalid parameters, invalid segment descriptors, and situations where the target is unable to continue operating. In the case of such a condition the target will:Terminate the
COPYcommand withCHECK CONDITIONas its status.Return sense data in the extended format. Where the valid bit is set to 1, and the segment descriptor that is currently being processed at the time the condition is detected. The sense key must contain the difference between the number of blocks from the segment descriptor vs the number of blocks that were successfully copied.
The segment descriptor format for copies between direct and sequential access devices are specified below. The descriptor may be repeated up to 256 times within the parameter list as long as it falls within the parameter list length specified in the command descriptor block.
Segment Descriptor for functions
0x00and0x01Byte
7
6
5
4
3
2
1
0
0Source Address
Reserved
Source LUN
1Destination Address
Reserved
Destination LUN
2Sequential-Access Device Block-Length (MSB)
3Sequential-Access Device Block-Length (LSB)
4Direct-Access Device Number of Blocks (MSB)
5Direct-Access Device Number of Blocks
6Direct-Access Device Number of Blocks
7Direct-Access Device Number of Blocks (LSB)
8Direct-Access Device LBA (MSB)
9Direct-Access Device LBA
10Direct-Access Device LBA
11Direct-Access Device LBA (LSB)
The
Source AddressandDestination Addressfields specify the SCSI Device number, and theSource LUNandDestination LUNspecify the logical units for theCOPYcommand.Warning
Some SCSI devices don’t support “third-party”
COPYcommands, in which the device which is initiating theCOPYcommand is neither the source nor destination of the copy.Some SCSI devices also only support
COPYwithin itself and not to an external SCSI device.If an unsupported
COPYis requested then the operation is terminated with aCHECK CONDITIONstatus and the sense key is set toILLEGAL REQUEST.The
Sequential-Access Device Block-Lengthfield specifies the block length to be used on the sequential-access logical unit during this segment of theCOPYcommand.Segment Descriptor for functions
0x02Byte
7
6
5
4
3
2
1
0
0Source Address
Reserved
Source LUN
1Destination Address
Reserved
Destination LUN
2Reserved
3Reserved
4Source Number of Blocks (MSB)
5Source Number of Blocks
6Source Number of Blocks
7Source Number of Blocks (LSB)
8Source LBA (MSB)
9Source LBA
10Source LBA
11Source LBA (LSB)
12Destination LBA (MSB)
13Destination LBA
14Destination LBA
15Destination LBA (LSB)
Segment Descriptor for functions
0x03Byte
7
6
5
4
3
2
1
0
0Source Address
Reserved
Source LUN
1Destination Address
Reserved
Destination LUN
2Reserved
3Reserved
4Source Block Length (MSB)
5Source Block Length (LSB)
6Destination Block Length (MSB)
7Destination Block Length (LSB)
8Source Number Of Blocks (MSB)
9Source Number Of Blocks
10Source Number Of Blocks
11Source Number Of Blocks (LSB)
- squishy.scsi.commands.common.ReceiveDiagnosticResults = <SCSICommand opcode:1C group:0 fields: 3>¶
 Receive Diagnostic Results
Todo
Document this
- squishy.scsi.commands.common.SendDiagnostic = <SCSICommand opcode:1D group:0 fields: 7>¶
 Send Diagnostic
Todo
Document this
- squishy.scsi.commands.common.Compare = <SCSICommand opcode:19 group:1 fields: 4>¶
 Compare
Todo
Document this
- squishy.scsi.commands.common.CopyAndVerify = <SCSICommand opcode:1A group:1 fields: 6>¶
 Copy and Verify
Todo
Document this