00001 /* ---------------------------------------------------------------------------- */ 00002 /* Atmel Microcontroller Software Support */ 00003 /* SAM Software Package License */ 00004 /* ---------------------------------------------------------------------------- */ 00005 /* Copyright (c) 2015, Atmel Corporation */ 00006 /* */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without */ 00010 /* modification, are permitted provided that the following condition is met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, */ 00013 /* this list of conditions and the disclaimer below. */ 00014 /* */ 00015 /* Atmel's name may not be used to endorse or promote products derived from */ 00016 /* this software without specific prior written permission. */ 00017 /* */ 00018 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ 00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ 00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ 00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ 00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ 00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00028 /* ---------------------------------------------------------------------------- */ 00029 00030 /** \file 00031 * \section Purpose 00032 * 00033 * SCSI definitions. 00034 * 00035 * \section Usage 00036 * 00037 * -# After command block received, Access and decode the SCSI command block 00038 * with SBCCommand structure. 00039 */ 00040 00041 #ifndef SBC_H 00042 #define SBC_H 00043 00044 /** \addtogroup usbd_msd 00045 *@{ 00046 */ 00047 00048 /*------------------------------------------------------------------------------ 00049 * Definitions 00050 *------------------------------------------------------------------------------*/ 00051 00052 /** \addtogroup usbd_sbc_operation_codes SBC Operation Codes 00053 * @{ 00054 * This page lists operation codes of commands described in the SBC-3 00055 * standard. 00056 * 00057 * \note That most commands are actually defined in other standards, 00058 * like SPC-4. Optional commands are not included here. 00059 * 00060 * \see sbc3r07.pdf - Section 5.1 - Table 12 00061 * \see spc4r06.pdf 00062 * \see SBCCommand 00063 * 00064 * \section Codes 00065 * - SBC_INQUIRY 00066 * - SBC_READ_10 00067 * - SBC_READ_CAPACITY_10 00068 * - SBC_REQUEST_SENSE 00069 * - SBC_TEST_UNIT_READY 00070 * - SBC_WRITE_10 00071 * 00072 * \section Optional Codes but required by Windows 00073 * - SBC_PREVENT_ALLOW_MEDIUM_REMOVAL 00074 * - SBC_MODE_SENSE_6 00075 * - SBC_VERIFY_10 00076 * - SBC_READ_FORMAT_CAPACITIES 00077 */ 00078 00079 /** Request information regarding parameters of the target and Logical Unit. */ 00080 #define SBC_INQUIRY 0x12 00081 /** Request the transfer data to the host. */ 00082 #define SBC_READ_10 0x28 00083 /** Request capacities of the currently installed medium. */ 00084 #define SBC_READ_CAPACITY_10 0x25 00085 /** Request that the device server transfer sense data. */ 00086 #define SBC_REQUEST_SENSE 0x03 00087 /** Check if the LUN is ready */ 00088 #define SBC_TEST_UNIT_READY 0x00 00089 /** Request that the device write the data transferred by the host. */ 00090 #define SBC_WRITE_10 0x2A 00091 00092 /** Request that the target enable or disable the removal of the medium in */ 00093 /** the Logical Unit. */ 00094 #define SBC_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E 00095 /** Report parameters. */ 00096 #define SBC_MODE_SENSE_6 0x1A 00097 /** Request that the %device verify the data on the medium. */ 00098 #define SBC_VERIFY_10 0x2F 00099 /** Request a list of the possible capacities that can be formatted on medium */ 00100 #define SBC_READ_FORMAT_CAPACITIES 0x23 00101 /** @}*/ 00102 00103 /** \addtogroup usbd_sbc_periph_quali SBC Periph. Qualifiers 00104 * @{ 00105 * This page lists the peripheral qualifier values specified in the INQUIRY 00106 * data 00107 * \see spc4r06.pdf - Section 6.4.2 - Table 83 00108 * \see SBCInquiryData 00109 * 00110 * \section Qualifiers 00111 * - SBC_PERIPHERAL_DEVICE_CONNECTED 00112 * - SBC_PERIPHERAL_DEVICE_NOT_CONNECTED 00113 * - SBC_PERIPHERAL_DEVICE_NOT_SUPPORTED 00114 */ 00115 00116 #define SBC_PERIPHERAL_DEVICE_CONNECTED 0x00 00117 #define SBC_PERIPHERAL_DEVICE_NOT_CONNECTED 0x01 00118 #define SBC_PERIPHERAL_DEVICE_NOT_SUPPORTED 0x03 00119 /** @}*/ 00120 00121 /** \addtogroup usbd_sbc_periph_types SBC Periph. Types 00122 * @{ 00123 * This page lists peripheral device types specified in the INQUIRY data 00124 * \see spc4r06.pdf - Section 6.4.2 - Table 84 00125 * \see SBCInquiryData 00126 * 00127 * \section Types 00128 * - SBC_DIRECT_ACCESS_BLOCK_DEVICE 00129 * - SBC_SEQUENTIAL_ACCESS_DEVICE 00130 * - SBC_PRINTER_DEVICE 00131 * - SBC_PROCESSOR_DEVICE 00132 * - SBC_WRITE_ONCE_DEVICE 00133 * - SBC_CD_DVD_DEVICE 00134 * - SBC_SCANNER_DEVICE 00135 * - SBC_OPTICAL_MEMORY_DEVICE 00136 * - SBC_MEDIA_CHANGER_DEVICE 00137 * - SBC_COMMUNICATION_DEVICE 00138 * - SBC_STORAGE_ARRAY_CONTROLLER_DEVICE 00139 * - SBC_ENCLOSURE_SERVICES_DEVICE 00140 * - SBC_SIMPLIFIED_DIRECT_ACCESS_DEVICE 00141 * - SBC_OPTICAL_CARD_READER_WRITER_DEVICE 00142 * - SBC_BRIDGE_CONTROLLER_COMMANDS 00143 * - SBC_OBJECT_BASED_STORAGE_DEVICE 00144 */ 00145 00146 #define SBC_DIRECT_ACCESS_BLOCK_DEVICE 0x00 00147 #define SBC_SEQUENTIAL_ACCESS_DEVICE 0x01 00148 #define SBC_PRINTER_DEVICE 0x02 00149 #define SBC_PROCESSOR_DEVICE 0x03 00150 #define SBC_WRITE_ONCE_DEVICE 0x04 00151 #define SBC_CD_DVD_DEVICE 0x05 00152 #define SBC_SCANNER_DEVICE 0x06 00153 #define SBC_OPTICAL_MEMORY_DEVICE 0x07 00154 #define SBC_MEDIA_CHANGER_DEVICE 0x08 00155 #define SBC_COMMUNICATION_DEVICE 0x09 00156 #define SBC_STORAGE_ARRAY_CONTROLLER_DEVICE 0x0C 00157 #define SBC_ENCLOSURE_SERVICES_DEVICE 0x0D 00158 #define SBC_SIMPLIFIED_DIRECT_ACCESS_DEVICE 0x0E 00159 #define SBC_OPTICAL_CARD_READER_WRITER_DEVICE 0x0F 00160 #define SBC_BRIDGE_CONTROLLER_COMMANDS 0x10 00161 #define SBC_OBJECT_BASED_STORAGE_DEVICE 0x11 00162 /** @}*/ 00163 00164 /*------------------------------------------------------------------------------ */ 00165 /** \brief Version value for the SBC-3 specification */ 00166 /** \see spc4r06.pdf - Section 6.4.2 - Table 85 */ 00167 #define SBC_SPC_VERSION_4 0x06 00168 /*------------------------------------------------------------------------------ */ 00169 00170 /*------------------------------------------------------------------------------ */ 00171 /** \brief Values for the TPGS field returned in INQUIRY data */ 00172 /** \see spc4r06.pdf - Section 6.4.2 - Table 86 */ 00173 #define SBC_TPGS_NONE 0x0 00174 #define SBC_TPGS_ASYMMETRIC 0x1 00175 #define SBC_TPGS_SYMMETRIC 0x2 00176 #define SBC_TPGS_BOTH 0x3 00177 /*------------------------------------------------------------------------------ */ 00178 00179 /*------------------------------------------------------------------------------ */ 00180 /** \brief Version descriptor value for the SBC-3 specification */ 00181 /** \see spc4r06.pdf - Section 6.4.2 - Table 87 */ 00182 #define SBC_VERSION_DESCRIPTOR_SBC_3 0x04C0 00183 /*------------------------------------------------------------------------------ */ 00184 00185 /** \addtogroup usbd_sbc_secse_codes SBC Sense Response Codes 00186 * @{ 00187 * This page lists sense data response codes returned in REQUEST SENSE data 00188 * \see spc4r06.pdf - Section 4.5.1 - Table 12 00189 * 00190 * \section Codes 00191 * - SBC_SENSE_DATA_FIXED_CURRENT 00192 * - SBC_SENSE_DATA_FIXED_DEFERRED 00193 * - SBC_SENSE_DATA_DESCRIPTOR_CURRENT 00194 * - SBC_SENSE_DATA_DESCRIPTOR_DEFERRED 00195 */ 00196 00197 #define SBC_SENSE_DATA_FIXED_CURRENT 0x70 00198 #define SBC_SENSE_DATA_FIXED_DEFERRED 0x71 00199 #define SBC_SENSE_DATA_DESCRIPTOR_CURRENT 0x72 00200 #define SBC_SENSE_DATA_DESCRIPTOR_DEFERRED 0x73 00201 #define SBC_SENSE_RESPONSE_CODE_MASK 0x7F 00202 /** @}*/ 00203 00204 /** \addtogroup usbd_sbc_sense_keys SBC Sense Keys 00205 * @{ 00206 * This page lists sense key values returned in the REQUEST SENSE data 00207 * \see spc4r06.pdf - Section 4.5.6 - Table 27 00208 * 00209 * \section Keys 00210 * - SBC_SENSE_KEY_NO_SENSE 00211 * - SBC_SENSE_KEY_RECOVERED_ERROR 00212 * - SBC_SENSE_KEY_NOT_READY 00213 * - SBC_SENSE_KEY_MEDIUM_ERROR 00214 * - SBC_SENSE_KEY_HARDWARE_ERROR 00215 * - SBC_SENSE_KEY_ILLEGAL_REQUEST 00216 * - SBC_SENSE_KEY_UNIT_ATTENTION 00217 * - SBC_SENSE_KEY_DATA_PROTECT 00218 * - SBC_SENSE_KEY_BLANK_CHECK 00219 * - SBC_SENSE_KEY_VENDOR_SPECIFIC 00220 * - SBC_SENSE_KEY_COPY_ABORTED 00221 * - SBC_SENSE_KEY_ABORTED_COMMAND 00222 * - SBC_SENSE_KEY_VOLUME_OVERFLOW 00223 * - SBC_SENSE_KEY_MISCOMPARE 00224 */ 00225 00226 /** No specific sense key. Successful command. */ 00227 #define SBC_SENSE_KEY_NO_SENSE 0x00 00228 /** Command completed successfully with some recovery action by the %device. */ 00229 #define SBC_SENSE_KEY_RECOVERED_ERROR 0x01 00230 /** The device can not be accessed. */ 00231 #define SBC_SENSE_KEY_NOT_READY 0x02 00232 /** Command terminated with a error condition that was probably caused by a */ 00233 /** flaw in the medium or an error in the recorded data. */ 00234 #define SBC_SENSE_KEY_MEDIUM_ERROR 0x03 00235 /** Hardware failure while performing the command or during a self test. */ 00236 #define SBC_SENSE_KEY_HARDWARE_ERROR 0x04 00237 /** Illegal parameter found in the command or additional parameters. */ 00238 #define SBC_SENSE_KEY_ILLEGAL_REQUEST 0x05 00239 /** Removable medium may have been changed or the %device has been reset. */ 00240 #define SBC_SENSE_KEY_UNIT_ATTENTION 0x06 00241 /** Write on a block that is protected. */ 00242 #define SBC_SENSE_KEY_DATA_PROTECT 0x07 00243 /** Indicates that a write-once device or a sequential-access device */ 00244 /** encountered blank medium or format-defined end-of-data indication while */ 00245 /** reading or a write-once device encountered a non-blank medium while writing. */ 00246 #define SBC_SENSE_KEY_BLANK_CHECK 0x08 00247 /** Reporting vendor specific conditions. */ 00248 #define SBC_SENSE_KEY_VENDOR_SPECIFIC 0x09 00249 /** EXTENDED COPY command was aborted. */ 00250 #define SBC_SENSE_KEY_COPY_ABORTED 0x0A 00251 /** Device aborted the command. */ 00252 #define SBC_SENSE_KEY_ABORTED_COMMAND 0x0B 00253 /** A buffered peripheral device is overflow. */ 00254 #define SBC_SENSE_KEY_VOLUME_OVERFLOW 0x0D 00255 /** The source data did not match the data read from the medium. */ 00256 #define SBC_SENSE_KEY_MISCOMPARE 0x0E 00257 /** @}*/ 00258 00259 /** \addtogroup usbd_sbc_sense_additionals SBC Sense Additional 00260 * @{ 00261 * This page lists additional sense code values returned in REQUEST SENSE data 00262 * \see spc4r06.pdf - Section 4.5.6 - Table 28 00263 * 00264 * \section Additional Codes 00265 * - SBC_ASC_LOGICAL_UNIT_NOT_READY 00266 * - SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 00267 * - SBC_ASC_INVALID_FIELD_IN_CDB 00268 * - SBC_ASC_WRITE_PROTECTED 00269 * - SBC_ASC_FORMAT_CORRUPTED 00270 * - SBC_ASC_INVALID_COMMAND_OPERATION_CODE 00271 * - SBC_ASC_TOO_MUCH_WRITE_DATA 00272 * - SBC_ASC_NOT_READY_TO_READY_CHANGE 00273 * - SBC_ASC_MEDIUM_NOT_PRESENT 00274 */ 00275 00276 #define SBC_ASC_LOGICAL_UNIT_NOT_READY 0x04 00277 #define SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21 00278 #define SBC_ASC_INVALID_FIELD_IN_CDB 0x24 00279 #define SBC_ASC_WRITE_PROTECTED 0x27 00280 #define SBC_ASC_FORMAT_CORRUPTED 0x31 00281 #define SBC_ASC_INVALID_COMMAND_OPERATION_CODE 0x20 00282 #define SBC_ASC_TOO_MUCH_WRITE_DATA 0x26 00283 #define SBC_ASC_NOT_READY_TO_READY_CHANGE 0x28 00284 #define SBC_ASC_MEDIUM_NOT_PRESENT 0x3A 00285 /** @}*/ 00286 00287 /*------------------------------------------------------------------------------ */ 00288 /** \brief MEDIUM TYPE field value for direct-access block devices */ 00289 /** \see sbc3r06.pdf - Section 6.3.1 */ 00290 #define SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE 0x00 00291 /*------------------------------------------------------------------------------ */ 00292 00293 /*------------------------------------------------------------------------------ */ 00294 /** \brief MRIE field values */ 00295 /** \see sbc3r06.pdf - Section 7.4.11 - Table 286 */ 00296 #define SBC_MRIE_NO_REPORTING 0x00 00297 #define SBC_MRIE_ASYNCHRONOUS 0x01 00298 #define SBC_MRIE_GENERATE_UNIT_ATTENTION 0x02 00299 #define SBC_MRIE_COND_GENERATE_RECOVERED_ERROR 0x03 00300 #define SBC_MRIE_UNCOND_GENERATE_RECOVERED_ERROR 0x04 00301 #define SBC_MRIE_GENERATE_NO_SENSE 0x05 00302 #define SBC_MRIE_ON_REQUEST 0x06 00303 /*------------------------------------------------------------------------------ */ 00304 00305 /*------------------------------------------------------------------------------ */ 00306 /** \brief Supported mode pages */ 00307 /** \see sbc3r06.pdf - Section 6.3.1 - Table 115 */ 00308 #define SBC_PAGE_READ_WRITE_ERROR_RECOVERY 0x01 00309 #define SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL 0x1C 00310 #define SBC_PAGE_RETURN_ALL 0x3F 00311 #define SBC_PAGE_VENDOR_SPECIFIC 0x00 00312 /*------------------------------------------------------------------------------ */ 00313 00314 /** \addtogroup usbd_msd_endian_macros MSD Endian Macros 00315 * @{ 00316 * This page lists the macros for endianness conversion. 00317 * 00318 * \section Macros 00319 * - WORDB 00320 * - DWORDB 00321 * - STORE_DWORDB 00322 * - STORE_WORDB 00323 */ 00324 00325 /** \brief Converts a byte array to a word value using the big endian format */ 00326 #define WORDB(bytes) ((unsigned short) ((bytes[0] << 8) | bytes[1])) 00327 00328 /** \brief Converts a byte array to a dword value using the big endian format */ 00329 #define DWORDB(bytes) ((unsigned int) ((bytes[0] << 24) | (bytes[1] << 16) \ 00330 | (bytes[2] << 8) | bytes[3])) 00331 00332 /** \brief Stores a dword value in a byte array, in big endian format */ 00333 #define STORE_DWORDB(dword, bytes) \ 00334 bytes[0] = (unsigned char) (((dword) >> 24) & 0xFF); \ 00335 bytes[1] = (unsigned char) (((dword) >> 16) & 0xFF); \ 00336 bytes[2] = (unsigned char) (((dword) >> 8) & 0xFF); \ 00337 bytes[3] = (unsigned char) ((dword) & 0xFF); 00338 00339 /** \brief Stores a word value in a byte array, in big endian format */ 00340 #define STORE_WORDB(word, bytes) \ 00341 bytes[0] = (unsigned char) (((word) >> 8) & 0xFF); \ 00342 bytes[1] = (unsigned char) ((word) & 0xFF); 00343 /** @}*/ 00344 00345 /*------------------------------------------------------------------------------ 00346 * Structures 00347 *------------------------------------------------------------------------------*/ 00348 #pragma pack(1) 00349 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */ 00350 #elif defined ( __ICCARM__ ) /* IAR Ewarm */ 00351 #define __attribute__(...) 00352 #define __packed__ packed 00353 #elif defined ( __GNUC__ ) /* GCC CS3 */ 00354 #define __packed__ aligned(1) 00355 #endif 00356 /** 00357 * \typedef SBCInquiry 00358 * \brief Structure for the INQUIRY command 00359 * \see spc4r06.pdf - Section 6.4.1 - Table 81 00360 */ 00361 typedef struct _SBCInquiry { 00362 00363 unsigned char bOperationCode; /*!< 0x12 : SBC_INQUIRY */ 00364 unsigned char isEVPD:1, /*!< Type of requested data */ 00365 bReserved1:7; /*!< Reserved bits */ 00366 unsigned char bPageCode; /*!< Specifies the VPD to return */ 00367 unsigned char pAllocationLength[2]; /*!< Size of host buffer */ 00368 unsigned char bControl; /*!< 0x00 */ 00369 00370 } __attribute__ ((__packed__)) SBCInquiry; /* GCC */ 00371 00372 /** 00373 * \typedef SBCInquiryData 00374 * \brief Standard INQUIRY data format returned by the device 00375 * \see spc4r06.pdf - Section 6.4.2 - Table 82 00376 */ 00377 typedef struct _SBCInquiryData { 00378 00379 unsigned char bPeripheralDeviceType:5, /*!< Peripheral device type */ 00380 bPeripheralQualifier :3; /*!< Peripheral qualifier */ 00381 unsigned char bReserved1:7, /*!< Reserved bits */ 00382 isRMB :1; /*!< Is media removable ? */ 00383 unsigned char bVersion; /*!< SPC version used */ 00384 unsigned char bResponseDataFormat:4, /*!< Must be 0x2 */ 00385 isHIGHSUP :1, /*!< Hierarchical addressing used ? */ 00386 isNORMACA :1, /*!< ACA attribute supported ? */ 00387 bObsolete1 :2; /*!< Obsolete bits */ 00388 unsigned char bAdditionalLength; /*!< Length of remaining INQUIRY data */ 00389 unsigned char isSCCS :1, /*!< Embedded SCC ? */ 00390 isACC :1, /*!< Access control coordinator ? */ 00391 bTPGS :2, /*!< Target port support group */ 00392 is3PC :1, /*!< Third-party copy supported ? */ 00393 bReserved2:2, /*!< Reserved bits */ 00394 isProtect :1; /*!< Protection info supported ? */ 00395 unsigned char bObsolete2:1, /*!< Obsolete bit */ 00396 isEncServ :1, /*!< Embedded enclosure service comp? */ 00397 isVS :1, /*!< ??? */ 00398 isMultiP :1, /*!< Multi-port device ? */ 00399 bObsolete3:3, /*!< Obsolete bits */ 00400 bUnused1 :1; /*!< Unused feature */ 00401 unsigned char bUnused2:6, /*!< Unused features */ 00402 isCmdQue:1, /*!< Task management model supported ? */ 00403 isVS2 :1; /*!< ??? */ 00404 unsigned char pVendorID[8]; /*!< T10 vendor identification */ 00405 unsigned char pProductID[16]; /*!< Vendor-defined product ID */ 00406 unsigned char pProductRevisionLevel[4];/*!< Vendor-defined product revision */ 00407 unsigned char pVendorSpecific[20]; /*!< Vendor-specific data */ 00408 unsigned char bUnused3; /*!< Unused features */ 00409 unsigned char bReserved3; /*!< Reserved bits */ 00410 unsigned short pVersionDescriptors[8]; /*!< Standards the device complies to */ 00411 unsigned char pReserved4[22]; /*!< Reserved bytes */ 00412 00413 } __attribute__ ((__packed__)) SBCInquiryData; /* GCC */ 00414 00415 /** 00416 * \typedef SBCRead10 00417 * \brief Data structure for the READ (10) command 00418 * \see sbc3r07.pdf - Section 5.7 - Table 34 00419 */ 00420 typedef struct _SBCRead10 { 00421 00422 unsigned char bOperationCode; /*!< 0x28 : SBC_READ_10 */ 00423 unsigned char bObsolete1:1, /*!< Obsolete bit */ 00424 isFUA_NV:1, /*!< Cache control bit */ 00425 bReserved1:1, /*!< Reserved bit */ 00426 isFUA:1, /*!< Cache control bit */ 00427 isDPO:1, /*!< Cache control bit */ 00428 bRdProtect:3; /*!< Protection information to send */ 00429 unsigned char pLogicalBlockAddress[4]; /*!< Index of first block to read */ 00430 unsigned char bGroupNumber:5, /*!< Information grouping */ 00431 bReserved2:3; /*!< Reserved bits */ 00432 unsigned char pTransferLength[2]; /*!< Number of blocks to transmit */ 00433 unsigned char bControl; /*!< 0x00 */ 00434 00435 } __attribute__ ((__packed__)) SBCRead10; /* GCC */ 00436 00437 /** 00438 * \typedef SBCReadCapacity10 00439 * \brief Structure for the READ CAPACITY (10) command 00440 * \see sbc3r07.pdf - Section 5.11.1 - Table 40 00441 */ 00442 typedef struct _SBCReadCapacity10 { 00443 00444 unsigned char bOperationCode; /*!< 0x25 : RBC_READ_CAPACITY */ 00445 unsigned char bObsolete1:1, /*!< Obsolete bit */ 00446 bReserved1:7; /*!< Reserved bits */ 00447 unsigned char pLogicalBlockAddress[4]; /*!< Block to evaluate if PMI is set */ 00448 unsigned char pReserved2[2]; /*!< Reserved bytes */ 00449 unsigned char isPMI:1, /*!< Partial medium indicator bit */ 00450 bReserved3:7; /*!< Reserved bits */ 00451 unsigned char bControl; /*!< 0x00 */ 00452 00453 } SBCReadCapacity10; 00454 00455 /*------------------------------------------------------------------------------ 00456 * \brief Data returned by the device after a READ CAPACITY (10) command 00457 * \see sbc3r07.pdf - Section 5.11.2 - Table 41 00458 *------------------------------------------------------------------------------*/ 00459 typedef struct { 00460 00461 unsigned char pLogicalBlockAddress[4]; /*!< Address of last logical block */ 00462 unsigned char pLogicalBlockLength[4]; /*!< Length of each logical block */ 00463 00464 } SBCReadCapacity10Data; 00465 00466 /*------------------------------------------------------------------------------ 00467 * \brief Structure for the REQUEST SENSE command 00468 * \see spc4r06.pdf - Section 6.26 - Table 170 00469 *------------------------------------------------------------------------------*/ 00470 typedef struct { 00471 00472 unsigned char bOperationCode; /*!< 0x03 : SBC_REQUEST_SENSE */ 00473 unsigned char isDesc :1, /*!< Type of information expected */ 00474 bReserved1:7; /*!< Reserved bits */ 00475 unsigned char pReserved2[2]; /*!< Reserved bytes */ 00476 unsigned char bAllocationLength; /*!< Size of host buffer */ 00477 unsigned char bControl; /*!< 0x00 */ 00478 00479 } SBCRequestSense; 00480 00481 /*------------------------------------------------------------------------------ 00482 * \brief Fixed format sense data returned after a REQUEST SENSE command has 00483 * been received with a DESC bit cleared. 00484 * \see spc4r06.pdf - Section 4.5.3 - Table 26 00485 *------------------------------------------------------------------------------*/ 00486 typedef struct { 00487 00488 unsigned char bResponseCode:7, /*!< Sense data format */ 00489 isValid :1; /*!< Information field is standard */ 00490 unsigned char bObsolete1; /*!< Obsolete byte */ 00491 unsigned char bSenseKey :4, /*!< Generic error information */ 00492 bReserved1:1, /*!< Reserved bit */ 00493 isILI :1, /*!< SSC */ 00494 isEOM :1, /*!< SSC */ 00495 isFilemark:1; /*!< SSC */ 00496 unsigned char pInformation[4]; /*!< Command-specific */ 00497 unsigned char bAdditionalSenseLength; /*!< sizeof(SBCRequestSense_data)-8 */ 00498 unsigned char pCommandSpecificInformation[4]; /*!< Command-specific */ 00499 unsigned char bAdditionalSenseCode; /*!< Additional error information */ 00500 unsigned char bAdditionalSenseCodeQualifier; /*!< Further error information */ 00501 unsigned char bFieldReplaceableUnitCode; /*!< Specific component code */ 00502 unsigned char bSenseKeySpecific:7, /*!< Additional exception info */ 00503 isSKSV :1; /*!< Is sense key specific valid? */ 00504 unsigned char pSenseKeySpecific[2]; /*!< Additional exception info */ 00505 00506 } SBCRequestSenseData; 00507 00508 /** 00509 * \brief SBCTestUnitReady 00510 * Data structure for the TEST UNIT READY command 00511 * \see spc4r06.pdf - Section 6.34 - Table 192 00512 */ 00513 typedef struct _SBCTestUnitReady { 00514 00515 unsigned char bOperationCode; /*!< 0x00 : SBC_TEST_UNIT_READY */ 00516 unsigned char pReserved1[4]; /*!< Reserved bits */ 00517 unsigned char bControl; /*!< 0x00 */ 00518 00519 } __attribute__ ((__packed__)) SBCTestUnitReady; /* GCC */ 00520 00521 /** 00522 * \typedef SBCWrite10 00523 * \brief Structure for the WRITE (10) command 00524 * \see sbc3r07.pdf - Section 5.26 - Table 70 00525 */ 00526 typedef struct _SBCWrite10 { 00527 00528 unsigned char bOperationCode; /*!< 0x2A : SBC_WRITE_10 */ 00529 unsigned char bObsolete1:1, /*!< Obsolete bit */ 00530 isFUA_NV:1, /*!< Cache control bit */ 00531 bReserved1:1, /*!< Reserved bit */ 00532 isFUA:1, /*!< Cache control bit */ 00533 isDPO:1, /*!< Cache control bit */ 00534 bWrProtect:3; /*!< Protection information to send */ 00535 unsigned char pLogicalBlockAddress[4]; /*!< First block to write */ 00536 unsigned char bGroupNumber:5, /*!< Information grouping */ 00537 bReserved2:3; /*!< Reserved bits */ 00538 unsigned char pTransferLength[2]; /*!< Number of blocks to write */ 00539 unsigned char bControl; /*!< 0x00 */ 00540 00541 } SBCWrite10; 00542 00543 /** 00544 * \typedef SBCMediumRemoval 00545 * \brief Structure for the PREVENT/ALLOW MEDIUM REMOVAL command 00546 * \see sbc3r07.pdf - Section 5.5 - Table 30 00547 */ 00548 typedef struct _SBCMediumRemoval { 00549 00550 unsigned char bOperationCode; /*!< 0x1E : SBC_PREVENT_ALLOW_MEDIUM_REMOVAL */ 00551 unsigned char pReserved1[3]; /*!< Reserved bytes */ 00552 unsigned char bPrevent:2, /*!< Accept/prohibit removal */ 00553 bReserved2:6; /*!< Reserved bits */ 00554 unsigned char bControl; /*!< 0x00 */ 00555 00556 } __attribute__ ((__packed__)) SBCMediumRemoval; /* GCC */ 00557 00558 /** 00559 * \typedef SBCModeSense6 00560 * \brief Structure for the MODE SENSE (6) command 00561 * \see spc4r06 - Section 6.9.1 - Table 98 00562 */ 00563 typedef struct _SBCModeSense6 { 00564 00565 unsigned char bOperationCode; /*!< 0x1A : SBC_MODE_SENSE_6 */ 00566 unsigned char bReserved1:3, /*!< Reserved bits */ 00567 isDBD:1, /*!< Disable block descriptors bit */ 00568 bReserved2:4; /*!< Reserved bits */ 00569 unsigned char bPageCode:6, /*!< Mode page to return */ 00570 bPC:2; /*!< Type of parameter values to return */ 00571 unsigned char bSubpageCode; /*!< Mode subpage to return */ 00572 unsigned char bAllocationLength; /*!< Host buffer allocated size */ 00573 unsigned char bControl; /*!< 0x00 */ 00574 00575 } __attribute__ ((__packed__)) SBCModeSense6; /* GCC */ 00576 00577 /** 00578 * \typedef SBCModeParameterHeader6 00579 * \brief Header for the data returned after a MODE SENSE (6) command 00580 * \see spc4r06.pdf - Section 7.4.3 - Table 268 00581 */ 00582 typedef struct _SBCModeParameterHeader6 { 00583 00584 unsigned char bModeDataLength; /*!< Length of mode data to follow */ 00585 unsigned char bMediumType; /*!< Type of medium (SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE) */ 00586 unsigned char bReserved1:4, /*!< Reserved bits */ 00587 isDPOFUA:1, /*!< DPO/FUA bits supported ? */ 00588 bReserved2:2, /*!< Reserved bits */ 00589 isWP:1; /*!< Is medium write-protected ? */ 00590 unsigned char bBlockDescriptorLength; /*!< Length of all block descriptors */ 00591 00592 } __attribute__ ((__packed__)) SBCModeParameterHeader6; /* GCC */ 00593 00594 /** 00595 * \typedef SBCInformationalExceptionsControl 00596 * \brief Informational exceptions control mode page 00597 * \see spc4r06.pdf - Section 7.4.11 - Table 285 00598 */ 00599 typedef struct _SBCInformationalExceptionsControl { 00600 00601 unsigned char bPageCode:6, /*!< 0x1C : SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL */ 00602 isSPF:1, /*!< Page or subpage data format */ 00603 isPS:1; /*!< Parameters savable ? */ 00604 unsigned char bPageLength; /*!< Length of page data (0x0A) */ 00605 unsigned char isLogErr:1, /*!< Should informational exceptions be logged ? */ 00606 isEBackErr:1, /*!< Enable background error bit */ 00607 isTest:1, /*!< Create a device test failure ? */ 00608 isDExcpt:1, /*!< Disable exception control bit */ 00609 isEWasc:1, /*!< Report warnings ? */ 00610 isEBF:1, /*!< Enable background function bit */ 00611 bReserved1:1, /*!< Reserved bit */ 00612 isPerf:1; /*!< Delay acceptable when treating exceptions ? */ 00613 unsigned char bMRIE:4, /*!< Method of reporting informational exceptions */ 00614 bReserved2:4; /*!< Reserved bits */ 00615 unsigned char pIntervalTimer[4]; /*!< Error reporting period */ 00616 unsigned char pReportCount[4]; /*!< Maximum number of time a report can be issued */ 00617 00618 } __attribute__ ((__packed__)) SBCInformationalExceptionsControl; /* GCC */ 00619 00620 /** 00621 * \typedef SBCReadWriteErrorRecovery 00622 * \brief Read/write error recovery mode page 00623 * \see sbc3r07.pdf - Section 6.3.5 - Table 122 00624 */ 00625 typedef struct _SBCReadWriteErrorRecovery { 00626 00627 unsigned char bPageCode:6, /*!< 0x01 : SBC_PAGE_READ_WRITE_ERROR_RECOVERY */ 00628 isSPF:1, /*!< Page or subpage data format */ 00629 isPS:1; /*!< Parameters savable ? */ 00630 unsigned char bPageLength; /*!< Length of page data (0x0A) */ 00631 unsigned char isDCR:1, /*!< Disable correction bit */ 00632 isDTE:1, /*!< Data terminate on error bit */ 00633 isPER:1, /*!< Post error bit */ 00634 isEER:1, /*!< Enable early recovery bit */ 00635 isRC:1, /*!< Read continuous bit */ 00636 isTB:1, /*!< Transfer block bit */ 00637 isARRE:1, /*!< Automatic read reallocation enabled bit */ 00638 isAWRE:1; /*!< Automatic write reallocation enabled bit */ 00639 unsigned char bReadRetryCount; /*!< Number of retries when reading */ 00640 unsigned char pObsolete1[3]; /*!< Obsolete bytes */ 00641 unsigned char bReserved1; /*!< Reserved byte */ 00642 unsigned char bWriteRetryCount; /*!< Number of retries when writing */ 00643 unsigned char bReserved2; /*!< Reserved byte */ 00644 unsigned char pRecoveryTimeLimit[2]; /*!< Maximum time duration for error recovery */ 00645 00646 } __attribute__ ((__packed__)) SBCReadWriteErrorRecovery; /* GCC */ 00647 00648 /** 00649 * \typedef SBCCommand 00650 * \brief Generic structure for holding information about SBC commands 00651 * \see SBCInquiry 00652 * \see SBCRead10 00653 * \see SBCReadCapacity10 00654 * \see SBCRequestSense 00655 * \see SBCTestUnitReady 00656 * \see SBCWrite10 00657 * \see SBCMediumRemoval 00658 * \see SBCModeSense6 00659 */ 00660 typedef union _SBCCommand { 00661 00662 unsigned char bOperationCode; /*!< Operation code of the command */ 00663 SBCInquiry inquiry; /*!< INQUIRY command */ 00664 SBCRead10 read10; /*!< READ (10) command */ 00665 SBCReadCapacity10 readCapacity10; /*!< READ CAPACITY (10) command */ 00666 SBCRequestSense requestSense; /*!< REQUEST SENSE command */ 00667 SBCTestUnitReady testUnitReady; /*!< TEST UNIT READY command */ 00668 SBCWrite10 write10; /*!< WRITE (10) command */ 00669 SBCMediumRemoval mediumRemoval; /*!< PREVENT/ALLOW MEDIUM REMOVAL command */ 00670 SBCModeSense6 modeSense6; /*!< MODE SENSE (6) command */ 00671 00672 } SBCCommand; 00673 00674 #pragma pack() 00675 00676 /**@}*/ 00677 00678 #endif /*#ifndef SBC_H */ 00679