SAM3S8/SD8 Software Package: libraries/usb/include/SBC.h Source File

SAM3S8/SD8 Software Package 1.2

# SBC.h

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------------
    00002  *         ATMEL Microcontroller Software Support
    00003  * ----------------------------------------------------------------------------
    00004  * Copyright (c) 2008, Atmel Corporation
    00005  *
    00006  * All rights reserved.
    00007  *
    00008  * Redistribution and use in source and binary forms, with or without
    00009  * modification, are permitted provided that the following conditions are met:
    00010  *
    00011  * - Redistributions of source code must retain the above copyright notice,
    00012  * this list of conditions and the disclaimer below.
    00013  *
    00014  * Atmel's name may not be used to endorse or promote products derived from
    00015  * this software without specific prior written permission.
    00016  *
    00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
    00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
    00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00027  * ----------------------------------------------------------------------------
    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 /**      @}*/
    00202
    00203 /** \addtogroup usbd_sbc_sense_keys SBC Sense Keys
    00204  *      @{
    00205  * This page lists sense key values returned in the REQUEST SENSE data
    00206  * \see    spc4r06.pdf - Section 4.5.6 - Table 27
    00207  *
    00208  * \section Keys
    00209  * - SBC_SENSE_KEY_NO_SENSE
    00210  * - SBC_SENSE_KEY_RECOVERED_ERROR
    00211  * - SBC_SENSE_KEY_NOT_READY
    00212  * - SBC_SENSE_KEY_MEDIUM_ERROR
    00213  * - SBC_SENSE_KEY_HARDWARE_ERROR
    00214  * - SBC_SENSE_KEY_ILLEGAL_REQUEST
    00215  * - SBC_SENSE_KEY_UNIT_ATTENTION
    00216  * - SBC_SENSE_KEY_DATA_PROTECT
    00217  * - SBC_SENSE_KEY_BLANK_CHECK
    00218  * - SBC_SENSE_KEY_VENDOR_SPECIFIC
    00219  * - SBC_SENSE_KEY_COPY_ABORTED
    00220  * - SBC_SENSE_KEY_ABORTED_COMMAND
    00221  * - SBC_SENSE_KEY_VOLUME_OVERFLOW
    00222  * - SBC_SENSE_KEY_MISCOMPARE
    00223  */
    00224
    00225 /** No specific sense key. Successful command. */
    00226 #define SBC_SENSE_KEY_NO_SENSE                        0x00
    00227 /** Command completed succesfully with some recovery action by the %device. */
    00228 #define SBC_SENSE_KEY_RECOVERED_ERROR                 0x01
    00229 /** The device can not be accessed. */
    00230 #define SBC_SENSE_KEY_NOT_READY                       0x02
    00231 /** Command terminated with a error condition that was probably caused by a */
    00232 /** flaw in the medium or an error in the recorded data. */
    00233 #define SBC_SENSE_KEY_MEDIUM_ERROR                    0x03
    00234 /** Hardware failure while performing the command or during a self test. */
    00235 #define SBC_SENSE_KEY_HARDWARE_ERROR                  0x04
    00236 /** Illegal parameter found in the command or additional parameters. */
    00237 #define SBC_SENSE_KEY_ILLEGAL_REQUEST                 0x05
    00238 /** Removable medium may have been changed or the %device has been reset. */
    00239 #define SBC_SENSE_KEY_UNIT_ATTENTION                  0x06
    00240 /** Write on a block that is protected. */
    00241 #define SBC_SENSE_KEY_DATA_PROTECT                    0x07
    00242 /** Indicates that a write-once device or a sequential-access device */
    00243 /** encountered blank medium or format-defined end-of-data indication while */
    00244 /** reading or a write-once device encountered a non-blank medium while writing. */
    00245 #define SBC_SENSE_KEY_BLANK_CHECK                     0x08
    00246 /** Reporting vendor specific conditions. */
    00247 #define SBC_SENSE_KEY_VENDOR_SPECIFIC                 0x09
    00248 /** EXTENDED COPY command was aborted. */
    00249 #define SBC_SENSE_KEY_COPY_ABORTED                    0x0A
    00250 /** Device aborted the command. */
    00251 #define SBC_SENSE_KEY_ABORTED_COMMAND                 0x0B
    00252 /** A buffered peripheral device is overflow. */
    00253 #define SBC_SENSE_KEY_VOLUME_OVERFLOW                 0x0D
    00254 /** The source data did not match the data read from the medium. */
    00255 #define SBC_SENSE_KEY_MISCOMPARE                      0x0E
    00256 /**      @}*/
    00257
    00258 /** \addtogroup usbd_sbc_sense_additionals SBC Sense Additionals
    00259  *      @{
    00260  * This page lists additional sense code values returned in REQUEST SENSE data
    00261  * \see    spc4r06.pdf - Section 4.5.6 - Table 28
    00262  *
    00263  * \section Additional Codes
    00264  * - SBC_ASC_LOGICAL_UNIT_NOT_READY
    00265  * - SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE
    00266  * - SBC_ASC_INVALID_FIELD_IN_CDB
    00267  * - SBC_ASC_WRITE_PROTECTED
    00268  * - SBC_ASC_FORMAT_CORRUPTED
    00269  * - SBC_ASC_INVALID_COMMAND_OPERATION_CODE
    00270  * - SBC_ASC_TOO_MUCH_WRITE_DATA
    00271  * - SBC_ASC_NOT_READY_TO_READY_CHANGE
    00272  * - SBC_ASC_MEDIUM_NOT_PRESENT
    00273  */
    00274
    00275 #define SBC_ASC_LOGICAL_UNIT_NOT_READY                0x04
    00276 #define SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE    0x21
    00277 #define SBC_ASC_INVALID_FIELD_IN_CDB                  0x24
    00278 #define SBC_ASC_WRITE_PROTECTED                       0x27
    00279 #define SBC_ASC_FORMAT_CORRUPTED                      0x31
    00280 #define SBC_ASC_INVALID_COMMAND_OPERATION_CODE        0x20
    00281 #define SBC_ASC_TOO_MUCH_WRITE_DATA                   0x26
    00282 #define SBC_ASC_NOT_READY_TO_READY_CHANGE             0x28
    00283 #define SBC_ASC_MEDIUM_NOT_PRESENT                    0x3A
    00284 /**      @}*/
    00285
    00286 /*------------------------------------------------------------------------------ */
    00287 /** \brief  MEDIUM TYPE field value for direct-access block devices */
    00288 /** \see    sbc3r06.pdf - Section 6.3.1 */
    00289 #define SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE    0x00
    00290 /*------------------------------------------------------------------------------ */
    00291
    00292 /*------------------------------------------------------------------------------ */
    00293 /** \brief  MRIE field values */
    00294 /** \see    sbc3r06.pdf - Section 7.4.11 - Table 286 */
    00295 #define SBC_MRIE_NO_REPORTING                         0x00
    00296 #define SBC_MRIE_ASYNCHRONOUS                         0x01
    00297 #define SBC_MRIE_GENERATE_UNIT_ATTENTION              0x02
    00298 #define SBC_MRIE_COND_GENERATE_RECOVERED_ERROR        0x03
    00299 #define SBC_MRIE_UNCOND_GENERATE_RECOVERED_ERROR      0x04
    00300 #define SBC_MRIE_GENERATE_NO_SENSE                    0x05
    00301 #define SBC_MRIE_ON_REQUEST                           0x06
    00302 /*------------------------------------------------------------------------------ */
    00303
    00304 /*------------------------------------------------------------------------------ */
    00305 /** \brief  Supported mode pages */
    00306 /** \see    sbc3r06.pdf - Section 6.3.1 - Table 115 */
    00307 #define SBC_PAGE_READ_WRITE_ERROR_RECOVERY            0x01
    00308 #define SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL     0x1C
    00309 #define SBC_PAGE_RETURN_ALL                           0x3F
    00310 #define SBC_PAGE_VENDOR_SPECIFIC                      0x00
    00311 /*------------------------------------------------------------------------------ */
    00312
    00313 /** \addtogroup usbd_msd_endian_macros MSD Endian Macros
    00314  *      @{
    00315  * This page lists the macros for endianness conversion.
    00316  *
    00317  * \section Macros
    00318  * - WORDB
    00319  * - DWORDB
    00320  * - STORE_DWORDB
    00321  * - STORE_WORDB
    00322  */
    00323
    00324  /** \brief  Converts a byte array to a word value using the big endian format */
    00325 #define WORDB(bytes)            ((unsigned short) ((bytes[0] << 8) | bytes[1]))
    00326
    00327 /** \brief  Converts a byte array to a dword value using the big endian format */
    00328 #define DWORDB(bytes)   ((unsigned int) ((bytes[0] << 24) | (bytes[1] << 16) \
    00329                                          | (bytes[2] << 8) | bytes[3]))
    00330
    00331 /** \brief  Stores a dword value in a byte array, in big endian format */
    00332 #define STORE_DWORDB(dword, bytes) \
    00333     bytes[0] = (unsigned char) (((dword) >> 24) & 0xFF); \
    00334     bytes[1] = (unsigned char) (((dword) >> 16) & 0xFF); \
    00335     bytes[2] = (unsigned char) (((dword) >> 8) & 0xFF); \
    00336     bytes[3] = (unsigned char) ((dword) & 0xFF);
    00337
    00338 /** \brief  Stores a word value in a byte array, in big endian format */
    00339 #define STORE_WORDB(word, bytes) \
    00340     bytes[0] = (unsigned char) (((word) >> 8) & 0xFF); \
    00341     bytes[1] = (unsigned char) ((word) & 0xFF);
    00342 /**      @}*/
    00343
    00344 /*------------------------------------------------------------------------------
    00345  *      Structures
    00346  *------------------------------------------------------------------------------*/
    00347
    00348 #ifdef __ICCARM__          /* IAR */
    00349 #pragma pack(1)            /* IAR */
    00350 #define __attribute__(...) /* IAR */
    00351 #endif                     /* IAR */
    00352
    00353 /**
    00354  * \typedef SBCInquiry
    00355  * \brief  Structure for the INQUIRY command
    00356  * \see    spc4r06.pdf - Section 6.4.1 - Table 81
    00357  */
    00358 typedef struct _SBCInquiry {
    00359
    00360     unsigned char bOperationCode;       /*!< 0x12 : SBC_INQUIRY */
    00361     unsigned char isEVPD:1,             /*!< Type of requested data */
    00362                   bReserved1:7;         /*!< Reserved bits */
    00363     unsigned char bPageCode;            /*!< Specifies the VPD to return */
    00364     unsigned char pAllocationLength[2]; /*!< Size of host buffer */
    00365     unsigned char bControl;             /*!< 0x00 */
    00366
    00367 } __attribute__ ((packed)) SBCInquiry; /* GCC */
    00368
    00369 /**
    00370  * \typedef SBCInquiryData
    00371  * \brief  Standard INQUIRY data format returned by the device
    00372  * \see    spc4r06.pdf - Section 6.4.2 - Table 82
    00373  */
    00374 typedef struct _SBCInquiryData {
    00375
    00376     unsigned char  bPeripheralDeviceType:5, /*!< Peripheral device type */
    00377                    bPeripheralQualifier :3; /*!< Peripheral qualifier */
    00378     unsigned char  bReserved1:7,            /*!< Reserved bits */
    00379                    isRMB     :1;            /*!< Is media removable ? */
    00380     unsigned char  bVersion;                /*!< SPC version used */
    00381     unsigned char  bResponseDataFormat:4,   /*!< Must be 0x2 */
    00382                    isHIGHSUP          :1,   /*!< Hierarchical addressing used ? */
    00383                    isNORMACA          :1,   /*!< ACA attribute supported ? */
    00384                    bObsolete1         :2;   /*!< Obsolete bits */
    00385     unsigned char  bAdditionalLength;       /*!< Length of remaining INQUIRY data */
    00386     unsigned char  isSCCS    :1,            /*!< Embedded SCC ? */
    00387                    isACC     :1,            /*!< Access control coordinator ? */
    00388                    bTPGS     :2,            /*!< Target port support group */
    00389                    is3PC     :1,            /*!< Third-party copy supported ? */
    00390                    bReserved2:2,            /*!< Reserved bits */
    00391                    isProtect :1;            /*!< Protection info supported ? */
    00392     unsigned char  bObsolete2:1,            /*!< Obsolete bit */
    00393                    isEncServ :1,            /*!< Embedded enclosure service comp? */
    00394                    isVS      :1,            /*!< ??? */
    00395                    isMultiP  :1,            /*!< Multi-port device ? */
    00396                    bObsolete3:3,            /*!< Obsolete bits */
    00397                    bUnused1  :1;            /*!< Unused feature */
    00398     unsigned char  bUnused2:6,              /*!< Unused features */
    00399                    isCmdQue:1,              /*!< Task management model supported ? */
    00400                    isVS2   :1;              /*!< ??? */
    00401     unsigned char  pVendorID[8];            /*!< T10 vendor identification */
    00402     unsigned char  pProductID[16];          /*!< Vendor-defined product ID */
    00403     unsigned char  pProductRevisionLevel[4];/*!< Vendor-defined product revision */
    00404     unsigned char  pVendorSpecific[20];     /*!< Vendor-specific data */
    00405     unsigned char  bUnused3;                /*!< Unused features */
    00406     unsigned char  bReserved3;              /*!< Reserved bits */
    00407     unsigned short pVersionDescriptors[8];  /*!< Standards the device complies to */
    00408     unsigned char  pReserved4[22];          /*!< Reserved bytes */
    00409
    00410 } __attribute__ ((packed)) SBCInquiryData; /* GCC */
    00411
    00412 /**
    00413  * \typedef SBCRead10
    00414  * \brief  Data structure for the READ (10) command
    00415  * \see    sbc3r07.pdf - Section 5.7 - Table 34
    00416  */
    00417 typedef struct _SBCRead10 {
    00418
    00419     unsigned char bOperationCode;          /*!< 0x28 : SBC_READ_10 */
    00420     unsigned char bObsolete1:1,            /*!< Obsolete bit */
    00421                   isFUA_NV:1,              /*!< Cache control bit */
    00422                   bReserved1:1,            /*!< Reserved bit */
    00423                   isFUA:1,                 /*!< Cache control bit */
    00424                   isDPO:1,                 /*!< Cache control bit */
    00425                   bRdProtect:3;            /*!< Protection information to send */
    00426     unsigned char pLogicalBlockAddress[4]; /*!< Index of first block to read */
    00427     unsigned char bGroupNumber:5,          /*!< Information grouping */
    00428                   bReserved2:3;            /*!< Reserved bits */
    00429     unsigned char pTransferLength[2];      /*!< Number of blocks to transmit */
    00430     unsigned char bControl;                /*!< 0x00 */
    00431
    00432 } __attribute__ ((packed)) SBCRead10; /* GCC */
    00433
    00434 /**
    00435  * \typedef SBCReadCapacity10
    00436  * \brief  Structure for the READ CAPACITY (10) command
    00437  * \see    sbc3r07.pdf - Section 5.11.1 - Table 40
    00438  */
    00439 typedef struct _SBCReadCapacity10 {
    00440
    00441     unsigned char bOperationCode;          /*!< 0x25 : RBC_READ_CAPACITY */
    00442     unsigned char bObsolete1:1,            /*!< Obsolete bit */
    00443                   bReserved1:7;            /*!< Reserved bits */
    00444     unsigned char pLogicalBlockAddress[4]; /*!< Block to evaluate if PMI is set */
    00445     unsigned char pReserved2[2];           /*!< Reserved bytes */
    00446     unsigned char isPMI:1,                 /*!< Partial medium indicator bit */
    00447                   bReserved3:7;            /*!< Reserved bits */
    00448     unsigned char bControl;                /*!< 0x00 */
    00449
    00450 } SBCReadCapacity10;
    00451
    00452 /*------------------------------------------------------------------------------
    00453  * \brief  Data returned by the device after a READ CAPACITY (10) command
    00454  * \see    sbc3r07.pdf - Section 5.11.2 - Table 41
    00455  *------------------------------------------------------------------------------*/
    00456 typedef struct {
    00457
    00458     unsigned char pLogicalBlockAddress[4]; /*!< Address of last logical block */
    00459     unsigned char pLogicalBlockLength[4];  /*!< Length of each logical block */
    00460
    00461 } SBCReadCapacity10Data;
    00462
    00463 /*------------------------------------------------------------------------------
    00464  * \brief  Structure for the REQUEST SENSE command
    00465  * \see    spc4r06.pdf - Section 6.26 - Table 170
    00466  *------------------------------------------------------------------------------*/
    00467 typedef struct {
    00468
    00469     unsigned char bOperationCode;    /*!< 0x03 : SBC_REQUEST_SENSE */
    00470     unsigned char isDesc    :1,      /*!< Type of information expected */
    00471                   bReserved1:7;      /*!< Reserved bits */
    00472     unsigned char pReserved2[2];     /*!< Reserved bytes */
    00473     unsigned char bAllocationLength; /*!< Size of host buffer */
    00474     unsigned char bControl;          /*!< 0x00 */
    00475
    00476 } SBCRequestSense;
    00477
    00478 /*------------------------------------------------------------------------------
    00479  * \brief  Fixed format sense data returned after a REQUEST SENSE command has
    00480  *         been received with a DESC bit cleared.
    00481  * \see    spc4r06.pdf - Section 4.5.3 - Table 26
    00482  *------------------------------------------------------------------------------*/
    00483 typedef struct {
    00484
    00485     unsigned char bResponseCode:7,                /*!< Sense data format */
    00486                   isValid      :1;                /*!< Information field is standard */
    00487     unsigned char bObsolete1;                     /*!< Obsolete byte */
    00488     unsigned char bSenseKey :4,                   /*!< Generic error information */
    00489                   bReserved1:1,                   /*!< Reserved bit */
    00490                   isILI     :1,                   /*!< SSC */
    00491                   isEOM     :1,                   /*!< SSC */
    00492                   isFilemark:1;                   /*!< SSC */
    00493     unsigned char pInformation[4];                /*!< Command-specific */
    00494     unsigned char bAdditionalSenseLength;         /*!< sizeof(SBCRequestSense_data)-8 */
    00495     unsigned char pCommandSpecificInformation[4]; /*!< Command-specific */
    00496     unsigned char bAdditionalSenseCode;           /*!< Additional error information */
    00497     unsigned char bAdditionalSenseCodeQualifier;  /*!< Further error information */
    00498     unsigned char bFieldReplaceableUnitCode;      /*!< Specific component code */
    00499     unsigned char bSenseKeySpecific:7,            /*!< Additional exception info */
    00500                   isSKSV           :1;            /*!< Is sense key specific valid? */
    00501     unsigned char pSenseKeySpecific[2];           /*!< Additional exception info */
    00502
    00503 } SBCRequestSenseData;
    00504
    00505 /**
    00506  * \brief  SBCTestUnitReady
    00507  *         Data structure for the TEST UNIT READY command
    00508  * \see    spc4r06.pdf - Section 6.34 - Table 192
    00509  */
    00510 typedef struct _SBCTestUnitReady {
    00511
    00512     unsigned char bOperationCode; /*!< 0x00 : SBC_TEST_UNIT_READY */
    00513     unsigned char pReserved1[4];  /*!< Reserved bits */
    00514     unsigned char bControl;       /*!< 0x00 */
    00515
    00516 } __attribute__ ((packed)) SBCTestUnitReady; /* GCC */
    00517
    00518 /**
    00519  * \typedef SBCWrite10
    00520  * \brief  Structure for the WRITE (10) command
    00521  * \see    sbc3r07.pdf - Section 5.26 - Table 70
    00522  */
    00523 typedef struct _SBCWrite10 {
    00524
    00525     unsigned char bOperationCode;          /*!< 0x2A : SBC_WRITE_10 */
    00526     unsigned char bObsolete1:1,            /*!< Obsolete bit */
    00527                   isFUA_NV:1,              /*!< Cache control bit */
    00528                   bReserved1:1,            /*!< Reserved bit */
    00529                   isFUA:1,                 /*!< Cache control bit */
    00530                   isDPO:1,                 /*!< Cache control bit */
    00531                   bWrProtect:3;            /*!< Protection information to send */
    00532     unsigned char pLogicalBlockAddress[4]; /*!< First block to write */
    00533     unsigned char bGroupNumber:5,          /*!< Information grouping */
    00534                   bReserved2:3;            /*!< Reserved bits */
    00535     unsigned char pTransferLength[2];      /*!< Number of blocks to write */
    00536     unsigned char bControl;                /*!< 0x00 */
    00537
    00538 } SBCWrite10;
    00539
    00540 /**
    00541  * \typedef SBCMediumRemoval
    00542  * \brief  Structure for the PREVENT/ALLOW MEDIUM REMOVAL command
    00543  * \see    sbc3r07.pdf - Section 5.5 - Table 30
    00544  */
    00545 typedef struct _SBCMediumRemoval {
    00546
    00547     unsigned char bOperationCode; /*!< 0x1E : SBC_PREVENT_ALLOW_MEDIUM_REMOVAL */
    00548     unsigned char pReserved1[3];  /*!< Reserved bytes */
    00549     unsigned char bPrevent:2,     /*!< Accept/prohibit removal */
    00550                   bReserved2:6;   /*!< Reserved bits */
    00551     unsigned char bControl;       /*!< 0x00 */
    00552
    00553 } __attribute__ ((packed)) SBCMediumRemoval; /* GCC */
    00554
    00555 /**
    00556  * \typedef SBCModeSense6
    00557  * \brief  Structure for the MODE SENSE (6) command
    00558  * \see    spc4r06 - Section 6.9.1 - Table 98
    00559  */
    00560 typedef struct _SBCModeSense6 {
    00561
    00562     unsigned char bOperationCode;    /*!< 0x1A : SBC_MODE_SENSE_6 */
    00563     unsigned char bReserved1:3,      /*!< Reserved bits */
    00564                   isDBD:1,           /*!< Disable block descriptors bit */
    00565                   bReserved2:4;      /*!< Reserved bits */
    00566     unsigned char bPageCode:6,       /*!< Mode page to return */
    00567                   bPC:2;             /*!< Type of parameter values to return */
    00568     unsigned char bSubpageCode;      /*!< Mode subpage to return */
    00569     unsigned char bAllocationLength; /*!< Host buffer allocated size */
    00570     unsigned char bControl;          /*!< 0x00 */
    00571
    00572 } __attribute__ ((packed)) SBCModeSense6; /* GCC */
    00573
    00574 /**
    00575  * \typedef SBCModeParameterHeader6
    00576  * \brief  Header for the data returned after a MODE SENSE (6) command
    00577  * \see    spc4r06.pdf - Section 7.4.3 - Table 268
    00578  */
    00579 typedef struct _SBCModeParameterHeader6 {
    00580
    00581     unsigned char bModeDataLength;          /*!< Length of mode data to follow */
    00582     unsigned char bMediumType;              /*!< Type of medium (SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE) */
    00583     unsigned char bReserved1:4,             /*!< Reserved bits */
    00584                   isDPOFUA:1,               /*!< DPO/FUA bits supported ? */
    00585                   bReserved2:2,             /*!< Reserved bits */
    00586                   isWP:1;                   /*!< Is medium write-protected ? */
    00587     unsigned char bBlockDescriptorLength;   /*!< Length of all block descriptors */
    00588
    00589 } __attribute__ ((packed)) SBCModeParameterHeader6; /* GCC */
    00590
    00591 /**
    00592  * \typedef SBCInformationalExceptionsControl
    00593  * \brief  Informational exceptions control mode page
    00594  * \see    spc4r06.pdf - Section 7.4.11 - Table 285
    00595  */
    00596 typedef struct _SBCInformationalExceptionsControl {
    00597
    00598     unsigned char bPageCode:6,       /*!< 0x1C : SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL */
    00599                   isSPF:1,           /*!< Page or subpage data format */
    00600                   isPS:1;            /*!< Parameters saveable ? */
    00601     unsigned char bPageLength;       /*!< Length of page data (0x0A) */
    00602     unsigned char isLogErr:1,        /*!< Should informational exceptions be logged ? */
    00603                   isEBackErr:1,      /*!< Enable background error bit */
    00604                   isTest:1,          /*!< Create a device test failure ? */
    00605                   isDExcpt:1,        /*!< Disable exception control bit */
    00606                   isEWasc:1,         /*!< Report warnings ? */
    00607                   isEBF:1,           /*!< Enable background function bit */
    00608                   bReserved1:1,      /*!< Reserved bit */
    00609                   isPerf:1;          /*!< Delay acceptable when treating exceptions ? */
    00610     unsigned char bMRIE:4,           /*!< Method of reporting informational exceptions */
    00611                   bReserved2:4;      /*!< Reserved bits */
    00612     unsigned char pIntervalTimer[4]; /*!< Error reporting period */
    00613     unsigned char pReportCount[4];   /*!< Maximum number of time a report can be issued */
    00614
    00615 } __attribute__ ((packed)) SBCInformationalExceptionsControl; /* GCC */
    00616
    00617 /**
    00618  * \typedef SBCReadWriteErrorRecovery
    00619  * \brief  Read/write error recovery mode page
    00620  * \see    sbc3r07.pdf - Section 6.3.5 - Table 122
    00621  */
    00622 typedef struct _SBCReadWriteErrorRecovery {
    00623
    00624     unsigned char bPageCode:6,           /*!< 0x01 : SBC_PAGE_READ_WRITE_ERROR_RECOVERY */
    00625                   isSPF:1,               /*!< Page or subpage data format */
    00626                   isPS:1;                /*!< Parameters saveable ? */
    00627     unsigned char bPageLength;           /*!< Length of page data (0x0A) */
    00628     unsigned char isDCR:1,               /*!< Disable correction bit */
    00629                   isDTE:1,               /*!< Data terminate on error bit */
    00630                   isPER:1,               /*!< Post error bit */
    00631                   isEER:1,               /*!< Enable early recovery bit */
    00632                   isRC:1,                /*!< Read continuous bit */
    00633                   isTB:1,                /*!< Transfer block bit */
    00634                   isARRE:1,              /*!< Automatic read reallocation enabled bit */
    00635                   isAWRE:1;              /*!< Automatic write reallocation enabled bit */
    00636     unsigned char bReadRetryCount;       /*!< Number of retries when reading */
    00637     unsigned char pObsolete1[3];         /*!< Obsolete bytes */
    00638     unsigned char bReserved1;            /*!< Reserved byte */
    00639     unsigned char bWriteRetryCount;      /*!< Number of retries when writing */
    00640     unsigned char bReserved2;            /*!< Reserved byte */
    00641     unsigned char pRecoveryTimeLimit[2]; /*!< Maximum time duration for error recovery */
    00642
    00643 } __attribute__ ((packed)) SBCReadWriteErrorRecovery; /* GCC */
    00644
    00645 /**
    00646  * \typedef SBCCommand
    00647  * \brief  Generic structure for holding information about SBC commands
    00648  * \see    SBCInquiry
    00649  * \see    SBCRead10
    00650  * \see    SBCReadCapacity10
    00651  * \see    SBCRequestSense
    00652  * \see    SBCTestUnitReady
    00653  * \see    SBCWrite10
    00654  * \see    SBCMediumRemoval
    00655  * \see    SBCModeSense6
    00656  */
    00657 typedef union _SBCCommand {
    00658
    00659     unsigned char     bOperationCode; /*!< Operation code of the command */
    00660     SBCInquiry        inquiry;        /*!< INQUIRY command */
    00661     SBCRead10         read10;         /*!< READ (10) command */
    00662     SBCReadCapacity10 readCapacity10; /*!< READ CAPACITY (10) command */
    00663     SBCRequestSense   requestSense;   /*!< REQUEST SENSE command */
    00664     SBCTestUnitReady  testUnitReady;  /*!< TEST UNIT READY command */
    00665     SBCWrite10        write10;        /*!< WRITE (10) command */
    00666     SBCMediumRemoval  mediumRemoval;  /*!< PREVENT/ALLOW MEDIUM REMOVAL command */
    00667     SBCModeSense6     modeSense6;     /*!< MODE SENSE (6) command */
    00668
    00669 } SBCCommand;
    00670
    00671 #ifdef __ICCARM__          /* IAR */
    00672 #pragma pack()             /* IAR */
    00673 #endif                     /* IAR */
    00674
    00675 /**@}*/
    00676
    00677 #endif /*#ifndef SBC_H */
    00678

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines