- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

# scsi_decoder.h

Go to the documentation of this file.

    00001
    00015 #ifndef _SCSI_DECODER_H_
    00016 #define _SCSI_DECODER_H_
    00017
    00018 //_____ I N C L U D E S ____________________________________________________
    00019
    00020
    00021 //_____ M A C R O S ________________________________________________________
    00022
    00023 typedef struct
    00024 {
    00025   U8      key;
    00026   U8      asc;
    00027   U8      ascq;
    00028 } s_scsi_sense;
    00029
    00030
    00031 //_____ D E C L A R A T I O N S ____________________________________________
    00032
    00033 Bool scsi_decode_command  (void);
    00034
    00035 /****************************************************************************/
    00036 /* Command for all SCSI device types                                        */
    00037 /****************************************************************************/
    00038
    00039 #define SBC_CMD_TEST_UNIT_READY                   (0x00)
    00040 #define SBC_CMD_REQUEST_SENSE                     (0x03)
    00041 #define SBC_CMD_FORMAT_UNIT                       (0x04)
    00042 #define SBC_CMD_READ_6                            (0x08)
    00043 #define SBC_CMD_INQUIRY                           (0x12)
    00044 #define SBC_CMD_MODE_SELECT_6                     (0x15)
    00045 #define SBC_CMD_MODE_SENSE_6                      (0x1A)
    00046 #define SBC_CMD_START_STOP_UNIT                   (0x1B)
    00047 #define SBC_CMD_RECEIVE_DIAGNOSTICS               (0x1C)
    00048 #define SBC_CMD_SEND_DIAGNOSTIC                   (0x1D)
    00049 #define SBC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL      (0x1E)
    00050 #define SBC_CMD_READ_LONG                         (0x23)
    00051 #define SBC_CMD_READ_CAPACITY                     (0x25)
    00052 #define SBC_CMD_READ_CD_ROM_CAPACITY              (0x25)
    00053 #define SBC_CMD_READ_10                           (0x28)
    00054 #define SBC_CMD_WRITE_10                          (0x2A)
    00055 #define SBC_CMD_VERIFY_10                         (0x2F)
    00056 #define SBC_CMD_SYNCHRONIZE_CACHE                 (0x35)
    00057 #define SBC_CMD_WRITE_BUFFER                      (0x3B)
    00058 #define SBC_CMD_CHANGE_DEFINITION                 (0x40)
    00059 #define SBC_CMD_READ_TOC                          (0x43)
    00060 #define SBC_CMD_MODE_SELECT_10                    (0x55)
    00061 #define SBC_CMD_RESERVE_10                        (0x56)
    00062 #define SBC_CMD_RELEASE_10                        (0x57)
    00063 #define SBC_CMD_MODE_SENSE_10                     (0x5A)
    00064
    00065 #define SBC_CONTROL_BYTE                          (0x00)
    00066 #define SBC_CMD_DIR_IN                            (0x80)
    00067 #define SBC_CMD_DIR_OUT                           (0x00)
    00068
    00069
    00070 /****************************************************************************/
    00071 /* Sense Key Code                                                           */
    00072 /****************************************************************************/
    00073 #define SBC_SENSE_KEY_NO_SENSE                        (0x00)
    00074 #define SBC_SENSE_KEY_RECOVERED_ERROR                 (0x01)
    00075 #define SBC_SENSE_KEY_NOT_READY                       (0x02)
    00076 #define SBC_SENSE_KEY_MEDIUM_ERROR                    (0x03)
    00077 #define SBC_SENSE_KEY_HARDWARE_ERROR                  (0x04)
    00078 #define SBC_SENSE_KEY_ILLEGAL_REQUEST                 (0x05)
    00079 #define SBC_SENSE_KEY_UNIT_ATTENTION                  (0x06)
    00080 #define SBC_SENSE_KEY_DATA_PROTECT                    (0x07)
    00081 #define SBC_SENSE_KEY_BLANK_CHECK                     (0x08)
    00082 #define SBC_SENSE_KEY_VENDOR_SPECIFIC                 (0x09)
    00083 #define SBC_SENSE_KEY_COPY_ABORTED                    (0x0A)
    00084 #define SBC_SENSE_KEY_ABORTED_COMMAND                 (0x0B)
    00085 #define SBC_SENSE_KEY_VOLUME_OVERFLOW                 (0x0D)
    00086 #define SBC_SENSE_KEY_MISCOMPARE                      (0x0E)
    00087
    00088 /****************************************************************************/
    00089 /* ASC code assignments                                                     */
    00090 /****************************************************************************/
    00091 #define SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION       (0x00)
    00092 #define SBC_ASC_LOGICAL_UNIT_NOT_READY                (0x04)
    00093 #define SBC_ASC_INVALID_FIELD_IN_CDB                  (0x24)
    00094 #define SBC_ASC_WRITE_PROTECTED                       (0x27)
    00095 #define SBC_ASC_FORMAT_ERROR                          (0x31)
    00096 #define SBC_ASC_INVALID_COMMAND_OPERATION_CODE        (0x20)
    00097 #define SBC_ASC_NOT_READY_TO_READY_CHANGE             (0x28)
    00098 #define SBC_ASC_MEDIUM_NOT_PRESENT                    (0x3A)
    00099
    00100 /****************************************************************************/
    00101 /* ASCQ code assignments                                                    */
    00102 /****************************************************************************/
    00103 #define SBC_ASCQ_FORMAT_COMMAND_FAILED                (0x01)
    00104 #define SBC_ASCQ_INITIALIZING_COMMAND_REQUIRED        (0x02)
    00105 #define SBC_ASCQ_OPERATION_IN_PROGRESS                (0x07)
    00106
    00107
    00108 /****************************************************************************/
    00109 /* REQUEST SENSE PARAMETERS                                                 */
    00110 /****************************************************************************/
    00111 #define SBC_RESPONSE_CODE_SENSE                       (0x70)
    00112 #define SBC_ADDITIONAL_SENSE_LENGTH                   (0x0A)
    00113 #define SBC_COMMAND_SPECIFIC_INFORMATION_3            (0x00)
    00114 #define SBC_COMMAND_SPECIFIC_INFORMATION_2            (0x00)
    00115 #define SBC_COMMAND_SPECIFIC_INFORMATION_1            (0x00)
    00116 #define SBC_COMMAND_SPECIFIC_INFORMATION_0            (0x00)
    00117 #define SBC_FIELD_REPLACEABLE_UNIT_CODE               (0x00)
    00118 #define SBC_SENSE_KEY_SPECIFIC_2                      (0x00)
    00119 #define SBC_SENSE_KEY_SPECIFIC_1                      (0x00)
    00120 #define SBC_SENSE_KEY_SPECIFIC_0                      (0x00)
    00121
    00122 /******* number of bytes of READ CAPACITY response *********/
    00123 #define SBC_READ_CAPACITY_LENGTH                      (0x08)
    00124
    00125
    00126 /****************************************************************************/
    00127 /*MODE SENSE and REQUEST SENSE DEFINITIONS                                  */
    00128 /****************************************************************************/
    00129
    00130 /*************** Direct access medium type ****************/
    00131 #define SBC_DEFAULT_MEDIUM_TYPE                       (0x00)
    00132 #define SBC_FLEXIBLE_DISK_SINGLE_SIDED_UNSPECIFIED    (0x01)
    00133 #define SBC_FLEXIBLE_DISK_DOUBLE_SIDED_UNSPECIFIED    (0x02)
    00134
    00135 #define SBC_MEDIUM_TYPE                               SBC_DEFAULT_MEDIUM_TYPE
    00136
    00137 #define SBC_DEV_SPEC_PARAM_WR_ENABLE                  (0x00)
    00138 #define SBC_DEV_SPEC_PARAM_WR_PROTECT                 (0x80)
    00139 #define SBC_BLOCK_DESCRIPTOR_LENGTH                   (0x00)
    00140
    00141 #define SBC_MSK_DBD                                   (0x08)
    00142 #define SBC_MSK_PAGE_CONTROL                          (0xC0)
    00143 #define SBC_MSK_PAGE_CODE                             (0x3F)
    00144
    00145
    00146 /************ General Page Code paramaters *****************/
    00147 #define SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY       (0x01)
    00148 #define SBC_PAGE_CODE_FORMAT_DEVICE                   (0x03)
    00149 #define SBC_PAGE_CODE_FLEXIBLE_DISK                   (0x05)
    00150 #define SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS        (0x1C)
    00151 #define SBC_PAGE_CODE_ALL                             (0x3F)
    00152
    00153
    00154 #define SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS      (0x0A)
    00155 #define SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY     (0x0A)
    00156 #define SBC_PAGE_LENGTH_FLEXIBLE_DISK                 (0x1E)
    00157 #define SBC_PAGE_LENGTH_FORMAT_DEVICE                 (0x16)
    00158
    00159
    00160
    00161 #define SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS   (SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS + 2 + 3)
    00162 #define SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY  (SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY + 2 + 3 )
    00163 #define SBC_MODE_DATA_LENGTH_FLEXIBLE_DISK              (SBC_PAGE_LENGTH_FLEXIBLE_DISK + 2 + 3 )
    00164 #define SBC_MODE_DATA_LENGTH_FORMAT_DEVICE              (SBC_PAGE_LENGTH_FORMAT_DEVICE + 2 + 3 )
    00165 /*SBC_PAGE_LENGTH_FLEXIBLE_DISK + 2  + \*/
    00166 #define SBC_MODE_DATA_LENGTH_CODE_ALL                 (SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY + 2 + \
    00167                                                        SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS + 2 + \
    00168                                                        SBC_BLOCK_DESCRIPTOR_LENGTH + \
    00169                                                        + 3 )
    00170
    00171 /*                                                       SBC_MODE_DATA_LENGTH_FORMAT_DEVICE + 2 + \*/
    00172 /****** Information exceptions control page parameters *****/
    00173 #define SBC_MRIE                                      (0x05)
    00174
    00175 /*************** Format device page parameters *************/
    00176 #define SBC_TRACK_PER_ZONE_MSB                        (0x00)
    00177 #define SBC_TRACK_PER_ZONE_LSB                        (0x00)
    00178 #define SBC_ALTERNATE_SECTORS_PER_ZONE_MSB            (0x00)
    00179 #define SBC_ALTERNATE_SECTORS_PER_ZONE_LSB            (0x00)
    00180 #define SBC_ALTERNATE_TRACK_PER_ZONE_MSB              (0x00)
    00181 #define SBC_ALTERNATE_TRACK_PER_ZONE_LSB              (0x00)
    00182 #define SBC_ALTERNATE_TRACK_PER_LU_MSB                (0x00)
    00183 #define SBC_ALTERNATE_TRACK_PER_LU_LSB                (0x00)
    00184
    00185 /************* Flexible Disk page Parameters ***************/
    00186 #define SBC_TRANSFER_RATE_MSB                         (0x13)
    00187 #define SBC_TRANSFER_RATE_LSB                         (0x88)
    00188 /* 1388h    5 Mbit/s   */
    00189 /* 07D0h    2 Mbit/s   */
    00190 /* 03E8h    1 Mbit/s   */
    00191 /* 01F4h    500 kbit/s */
    00192 /* 012Ch    300 kbit/s */
    00193 /* 00FAh    250 kbit/s */
    00194
    00195 #define SBC_NUMBER_OF_HEAD                            (0x04)
    00196 #define SBC_SECTOR_PER_TRACK                          (0x20)
    00197 #define SBC_DATA_BYTE_PER_SECTOR_MSB                  (0x02)
    00198 #define SBC_DATA_BYTE_PER_SECTOR_LSB                  (0x00)
    00199 #define SBC_NUMBER_OF_CYLINDERS_MSB                   (0x01)
    00200 #define SBC_NUMBER_OF_CYLINDERS_LSB                   (0xE9)
    00201 #define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_MSB  (0x00)
    00202 #define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_LSB  (0x00)
    00203 #define SBC_STARTING_CYLINDER_REDUCED_WRITE_MSB       (0x00)
    00204 #define SBC_STARTING_CYLINDER_REDUCED_WRITE_LSB       (0x00)
    00205 #define SBC_DEVICE_STEP_RATE_MSB                      (0x00)
    00206 #define SBC_DEVICE_STEP_RATE_LSB                      (0x00)
    00207 #define SBC_DEVICE_STEP_PULSE_WIDTH                   (0x00)
    00208 #define SBC_HEAD_SETTLE_DELAY_MSB                     (0x00)
    00209 #define SBC_HEAD_SETTLE_DELAY_LSB                     (0x00)
    00210 #define SBC_MOTOR_ON_DELAY                            (0x00)
    00211 #define SBC_MOTOR_OFF_DELAY                           (0x00)
    00212 #define SBC_STEP_PULSE_PER_CYLINDER                   (0x00)
    00213 #define SBC_WRITE_COMPENSATION                        (0x00)
    00214 #define SBC_HEAD_LOAD_DELAY                           (0x00)
    00215 #define SBC_HEAD_UNLOAD_DELAY                         (0x00)
    00216 #define SBC_PIN34_PIN2                                (0x00)
    00217 #define SBC_PIN4_PIN1                                 (0x00)
    00218 #define SBC_MEDIUM_ROTATION_RATE_MSB                  (0x00)
    00219 #define SBC_MEDIUM_ROTATION_RATE_LSB                  (0x00)
    00220
    00221 /************ Read/Write Error Recovery parameters**********/
    00222 #define SBC_READ_RETRY_COUNT                          (0x03)
    00223 #define SBC_WRITE_RETRY_COUNT                         (0x80)
    00224 #define SBC_CORRECTION_SPAN                           (0x00)
    00225 #define SBC_HEAD_OFFSET_COUNT                         (0x00)
    00226 #define SBC_DATA_STROBE_OFFSET                        (0x00)
    00227 #define SBC_RECOVERY_LIMIT_MSB                        (0x00)
    00228 #define SBC_RECOVERY_LIMIT_LSB                        (0x00)
    00229
    00230
    00231 /*_____ D E F I N I T I O N ________________________________________________*/
    00232
    00233 #define SBC_MAX_INQUIRY_DATA                          (0x60) // value ?
    00234
    00235 struct sbc_st_std_inquiry_data
    00236 {
    00237   Byte    DeviceType : 5;
    00238   Byte    PeripheralQualifier : 3;
    00239
    00240   Byte    Reserved1 : 7;
    00241   Byte    RemovableMedia : 1;
    00242
    00243   Byte    Version;
    00244
    00245   Byte    Reserved3 : 5;
    00246   Byte    NormACA : 1;
    00247   Byte    Obsolete0 : 1;
    00248   Byte    AERC : 1;
    00249
    00250   Byte    Reserved4[3];
    00251
    00252   Byte    SoftReset : 1;
    00253   Byte    CommandQueue : 1;
    00254   Byte    Reserved5 : 1;
    00255   Byte    LinkedCommands : 1;
    00256   Byte    Synchronous : 1;
    00257   Byte    Wide16Bit : 1;
    00258   Byte    Wide32Bit : 1;
    00259   Byte    RelativeAddressing : 1;
    00260 };
    00261
    00262
    00263 //_____ D E C L A R A T I O N S ____________________________________________
    00264
    00265 #define Sbc_send_failed()                 (g_scsi_status = COMMAND_FAILED)
    00266 #define Sbc_send_check_condition()        (g_scsi_status = CHECK_CONDITION)
    00267 #define Sbc_send_good()                   (g_scsi_status = COMMAND_PASSED)
    00268
    00269 /*#define Sbc_valid_write_usb(length)       ( Usb_set_TXRDY(), \
    00270                                             dCBWDataTransferLength -= length, \
    00271                                             while (!Usb_tx_complete()),\
    00272                                             Usb_clear_TXCMPL() )
    00273 */
    00274 #define Sbc_build_sense(skey, sasc, sascq)   ( g_scsi_sense.key  = skey, \
    00275                                                g_scsi_sense.asc  = sasc, \
    00276                                                g_scsi_sense.ascq = sascq )
    00277
    00278 #define Sbc_valid_write_usb(length)          ( Usb_send_in(), \
    00279                                                g_scsi_data_remaining -= length )
    00280
    00281
    00282 #define COMMAND_PASSED                0x00
    00283 #define COMMAND_FAILED                0x01
    00284 #define CHECK_CONDITION               0x02
    00285 #define PHASE_ERROR                   0x02
    00286
    00287
    00288 Bool  sbc_inquiry (void);
    00289 Bool  sbc_mode_sense( Bool sense_10 );
    00290 Bool  sbc_mode_select_6 (void);
    00291 Bool  sbc_request_sense (void);
    00292 Bool  sbc_format (void);
    00293 Bool  sbc_write_10 (void);
    00294 Bool  sbc_read_10  (void);
    00295 Bool  sbc_test_unit_ready(void);
    00296 Bool  sbc_read_capacity(void);
    00297 Bool  sbc_prevent_allow_medium_removal(void);
    00298
    00299 void  sbc_lun_status_is_good(void);
    00300 void  sbc_lun_status_is_busy_or_change(void);
    00301 void  sbc_lun_status_is_not_present(void);
    00302 void  sbc_lun_status_is_fail(void);
    00303 void  sbc_lun_status_is_protected(void);
    00304
    00305 #endif /* _SCSI_DECODER_H_ */