Go to the source code of this file.
Definition in file scsi_decoder.h.
| #define SBC_CMD_TEST_UNIT_READY (0x00) |
| #define SBC_CMD_REQUEST_SENSE (0x03) |
| #define SBC_CMD_FORMAT_UNIT (0x04) |
| #define SBC_CMD_READ_6 (0x08) |
Definition at line 64 of file scsi_decoder.h.
| #define SBC_CMD_INQUIRY (0x12) |
| #define SBC_CMD_MODE_SELECT_6 (0x15) |
| #define SBC_CMD_READ_FORMAT_CAPACITY (0x23) |
Definition at line 67 of file scsi_decoder.h.
| #define SBC_CMD_MODE_SENSE_6 (0x1A) |
| #define SBC_CMD_START_STOP_UNIT (0x1B) |
| #define SBC_CMD_RECEIVE_DIAGNOSTICS (0x1C) |
Definition at line 70 of file scsi_decoder.h.
| #define SBC_CMD_SEND_DIAGNOSTIC (0x1D) |
| #define SBC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL (0x1E) |
| #define SBC_CMD_READ_LONG (0x23) |
| #define SBC_CMD_READ_CAPACITY (0x25) |
| #define SBC_CMD_READ_CD_ROM_CAPACITY (0x25) |
Definition at line 75 of file scsi_decoder.h.
| #define SBC_CMD_READ_10 (0x28) |
| #define SBC_CMD_WRITE_10 (0x2A) |
| #define SBC_CMD_VERIFY_10 (0x2F) |
| #define SBC_CMD_SYNCHRONIZE_CACHE (0x35) |
| #define SBC_CMD_WRITE_BUFFER (0x3B) |
| #define SBC_CMD_CHANGE_DEFINITION (0x40) |
Definition at line 81 of file scsi_decoder.h.
| #define SBC_CMD_READ_TOC (0x43) |
Definition at line 82 of file scsi_decoder.h.
| #define SBC_CMD_MODE_SELECT_10 (0x55) |
Definition at line 83 of file scsi_decoder.h.
| #define SBC_CMD_RESERVE_10 (0x56) |
| #define SBC_CMD_RELEASE_10 (0x57) |
| #define SBC_CMD_MODE_SENSE_10 (0x5A) |
| #define SBC_CONTROL_BYTE (0x00) |
Definition at line 88 of file scsi_decoder.h.
| #define SBC_CMD_DIR_IN (0x80) |
Definition at line 89 of file scsi_decoder.h.
| #define SBC_CMD_DIR_OUT (0x00) |
Definition at line 90 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_NO_SENSE (0x00) |
| #define SBC_SENSE_KEY_RECOVERED_ERROR (0x01) |
Definition at line 97 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_NOT_READY (0x02) |
| #define SBC_SENSE_KEY_MEDIUM_ERROR (0x03) |
Definition at line 99 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_HARDWARE_ERROR (0x04) |
| #define SBC_SENSE_KEY_ILLEGAL_REQUEST (0x05) |
Definition at line 101 of file scsi_decoder.h.
Referenced by sbc_lun_status_is_cdb_field(), and scsi_decode_command().
| #define SBC_SENSE_KEY_UNIT_ATTENTION (0x06) |
| #define SBC_SENSE_KEY_DATA_PROTECT (0x07) |
| #define SBC_SENSE_KEY_BLANK_CHECK (0x08) |
Definition at line 104 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_VENDOR_SPECIFIC (0x09) |
Definition at line 105 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_COPY_ABORTED (0x0A) |
Definition at line 106 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_ABORTED_COMMAND (0x0B) |
Definition at line 107 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_VOLUME_OVERFLOW (0x0D) |
Definition at line 108 of file scsi_decoder.h.
| #define SBC_SENSE_KEY_MISCOMPARE (0x0E) |
Definition at line 109 of file scsi_decoder.h.
| #define SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION (0x00) |
Definition at line 114 of file scsi_decoder.h.
Referenced by sbc_lun_status_is_fail(), and sbc_lun_status_is_good().
| #define SBC_ASC_LOGICAL_UNIT_NOT_READY (0x04) |
Definition at line 115 of file scsi_decoder.h.
| #define SBC_ASC_INVALID_FIELD_IN_CDB (0x24) |
| #define SBC_ASC_WRITE_PROTECTED (0x27) |
| #define SBC_ASC_FORMAT_ERROR (0x31) |
Definition at line 118 of file scsi_decoder.h.
| #define SBC_ASC_INVALID_COMMAND_OPERATION_CODE (0x20) |
| #define SBC_ASC_NOT_READY_TO_READY_CHANGE (0x28) |
| #define SBC_ASC_MEDIUM_NOT_PRESENT (0x3A) |
| #define SBC_ASCQ_FORMAT_COMMAND_FAILED (0x01) |
Definition at line 126 of file scsi_decoder.h.
| #define SBC_ASCQ_INITIALIZING_COMMAND_REQUIRED (0x02) |
Definition at line 127 of file scsi_decoder.h.
| #define SBC_ASCQ_OPERATION_IN_PROGRESS (0x07) |
Definition at line 128 of file scsi_decoder.h.
| #define SBC_RESPONSE_CODE_SENSE (0x70) |
| #define SBC_ADDITIONAL_SENSE_LENGTH (0x0A) |
| #define SBC_COMMAND_SPECIFIC_INFORMATION_3 (0x00) |
| #define SBC_COMMAND_SPECIFIC_INFORMATION_2 (0x00) |
| #define SBC_COMMAND_SPECIFIC_INFORMATION_1 (0x00) |
| #define SBC_COMMAND_SPECIFIC_INFORMATION_0 (0x00) |
| #define SBC_FIELD_REPLACEABLE_UNIT_CODE (0x00) |
| #define SBC_SENSE_KEY_SPECIFIC_2 (0x00) |
| #define SBC_SENSE_KEY_SPECIFIC_1 (0x00) |
| #define SBC_SENSE_KEY_SPECIFIC_0 (0x00) |
| #define SBC_READ_CAPACITY_LENGTH (0x08) |
| #define SBC_DEFAULT_MEDIUM_TYPE (0x00) |
Definition at line 154 of file scsi_decoder.h.
| #define SBC_FLEXIBLE_DISK_SINGLE_SIDED_UNSPECIFIED (0x01) |
Definition at line 155 of file scsi_decoder.h.
| #define SBC_FLEXIBLE_DISK_DOUBLE_SIDED_UNSPECIFIED (0x02) |
Definition at line 156 of file scsi_decoder.h.
| #define SBC_MEDIUM_TYPE SBC_DEFAULT_MEDIUM_TYPE |
| #define SBC_DEV_SPEC_PARAM_WR_ENABLE (0x00) |
| #define SBC_DEV_SPEC_PARAM_WR_PROTECT (0x80) |
| #define SBC_BLOCK_DESCRIPTOR_LENGTH (0x00) |
| #define SBC_MSK_DBD (0x08) |
Definition at line 164 of file scsi_decoder.h.
| #define SBC_MSK_PAGE_CONTROL (0xC0) |
Definition at line 165 of file scsi_decoder.h.
| #define SBC_MSK_PAGE_CODE (0x3F) |
| #define SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY (0x01) |
Definition at line 170 of file scsi_decoder.h.
Referenced by sbc_mode_sense(), and send_read_write_error_recovery_page().
| #define SBC_PAGE_CODE_FORMAT_DEVICE (0x03) |
Definition at line 171 of file scsi_decoder.h.
| #define SBC_PAGE_CODE_FLEXIBLE_DISK (0x05) |
Definition at line 172 of file scsi_decoder.h.
| #define SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS (0x1C) |
Definition at line 173 of file scsi_decoder.h.
Referenced by sbc_mode_sense(), and send_informational_exceptions_page().
| #define SBC_PAGE_CODE_ALL (0x3F) |
| #define SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS (0x0A) |
| #define SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY (0x0A) |
| #define SBC_PAGE_LENGTH_FLEXIBLE_DISK (0x1E) |
Definition at line 179 of file scsi_decoder.h.
| #define SBC_PAGE_LENGTH_FORMAT_DEVICE (0x16) |
Definition at line 180 of file scsi_decoder.h.
| #define SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS (SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS + 2 + 3) |
| #define SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY (SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY + 2 + 3 ) |
| #define SBC_MODE_DATA_LENGTH_FLEXIBLE_DISK (SBC_PAGE_LENGTH_FLEXIBLE_DISK + 2 + 3 ) |
Definition at line 186 of file scsi_decoder.h.
| #define SBC_MODE_DATA_LENGTH_FORMAT_DEVICE (SBC_PAGE_LENGTH_FORMAT_DEVICE + 2 + 3 ) |
Definition at line 187 of file scsi_decoder.h.
| #define SBC_MODE_DATA_LENGTH_CODE_ALL |
Value:
(SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY + 2 + \ SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS + 2 + \ SBC_BLOCK_DESCRIPTOR_LENGTH + \ + 3 )
Definition at line 189 of file scsi_decoder.h.
Referenced by sbc_mode_sense().
| #define SBC_MRIE (0x05) |
| #define SBC_TRACK_PER_ZONE_MSB (0x00) |
Definition at line 199 of file scsi_decoder.h.
| #define SBC_TRACK_PER_ZONE_LSB (0x00) |
Definition at line 200 of file scsi_decoder.h.
| #define SBC_ALTERNATE_SECTORS_PER_ZONE_MSB (0x00) |
Definition at line 201 of file scsi_decoder.h.
| #define SBC_ALTERNATE_SECTORS_PER_ZONE_LSB (0x00) |
Definition at line 202 of file scsi_decoder.h.
| #define SBC_ALTERNATE_TRACK_PER_ZONE_MSB (0x00) |
Definition at line 203 of file scsi_decoder.h.
| #define SBC_ALTERNATE_TRACK_PER_ZONE_LSB (0x00) |
Definition at line 204 of file scsi_decoder.h.
| #define SBC_ALTERNATE_TRACK_PER_LU_MSB (0x00) |
Definition at line 205 of file scsi_decoder.h.
| #define SBC_ALTERNATE_TRACK_PER_LU_LSB (0x00) |
Definition at line 206 of file scsi_decoder.h.
| #define SBC_TRANSFER_RATE_MSB (0x13) |
Definition at line 209 of file scsi_decoder.h.
| #define SBC_TRANSFER_RATE_LSB (0x88) |
Definition at line 210 of file scsi_decoder.h.
| #define SBC_NUMBER_OF_HEAD (0x04) |
Definition at line 218 of file scsi_decoder.h.
| #define SBC_SECTOR_PER_TRACK (0x20) |
Definition at line 219 of file scsi_decoder.h.
| #define SBC_DATA_BYTE_PER_SECTOR_MSB (0x02) |
Definition at line 220 of file scsi_decoder.h.
| #define SBC_DATA_BYTE_PER_SECTOR_LSB (0x00) |
Definition at line 221 of file scsi_decoder.h.
| #define SBC_NUMBER_OF_CYLINDERS_MSB (0x01) |
Definition at line 222 of file scsi_decoder.h.
| #define SBC_NUMBER_OF_CYLINDERS_LSB (0xE9) |
Definition at line 223 of file scsi_decoder.h.
| #define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_MSB (0x00) |
Definition at line 224 of file scsi_decoder.h.
| #define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_LSB (0x00) |
Definition at line 225 of file scsi_decoder.h.
| #define SBC_STARTING_CYLINDER_REDUCED_WRITE_MSB (0x00) |
Definition at line 226 of file scsi_decoder.h.
| #define SBC_STARTING_CYLINDER_REDUCED_WRITE_LSB (0x00) |
Definition at line 227 of file scsi_decoder.h.
| #define SBC_DEVICE_STEP_RATE_MSB (0x00) |
Definition at line 228 of file scsi_decoder.h.
| #define SBC_DEVICE_STEP_RATE_LSB (0x00) |
Definition at line 229 of file scsi_decoder.h.
| #define SBC_DEVICE_STEP_PULSE_WIDTH (0x00) |
Definition at line 230 of file scsi_decoder.h.
| #define SBC_HEAD_SETTLE_DELAY_MSB (0x00) |
Definition at line 231 of file scsi_decoder.h.
| #define SBC_HEAD_SETTLE_DELAY_LSB (0x00) |
Definition at line 232 of file scsi_decoder.h.
| #define SBC_MOTOR_ON_DELAY (0x00) |
Definition at line 233 of file scsi_decoder.h.
| #define SBC_MOTOR_OFF_DELAY (0x00) |
Definition at line 234 of file scsi_decoder.h.
| #define SBC_STEP_PULSE_PER_CYLINDER (0x00) |
Definition at line 235 of file scsi_decoder.h.
| #define SBC_WRITE_COMPENSATION (0x00) |
Definition at line 236 of file scsi_decoder.h.
| #define SBC_HEAD_LOAD_DELAY (0x00) |
Definition at line 237 of file scsi_decoder.h.
| #define SBC_HEAD_UNLOAD_DELAY (0x00) |
Definition at line 238 of file scsi_decoder.h.
| #define SBC_PIN34_PIN2 (0x00) |
Definition at line 239 of file scsi_decoder.h.
| #define SBC_PIN4_PIN1 (0x00) |
Definition at line 240 of file scsi_decoder.h.
| #define SBC_MEDIUM_ROTATION_RATE_MSB (0x00) |
Definition at line 241 of file scsi_decoder.h.
| #define SBC_MEDIUM_ROTATION_RATE_LSB (0x00) |
Definition at line 242 of file scsi_decoder.h.
| #define SBC_READ_RETRY_COUNT (0x03) |
| #define SBC_WRITE_RETRY_COUNT (0x80) |
| #define SBC_CORRECTION_SPAN (0x00) |
| #define SBC_HEAD_OFFSET_COUNT (0x00) |
| #define SBC_DATA_STROBE_OFFSET (0x00) |
| #define SBC_RECOVERY_LIMIT_MSB (0x00) |
| #define SBC_RECOVERY_LIMIT_LSB (0x00) |
| #define SBC_MAX_INQUIRY_DATA (0x60) |
| #define Sbc_send_failed | ( | ) | (g_scsi_status = COMMAND_FAILED) |
Definition at line 288 of file scsi_decoder.h.
Referenced by sbc_lun_status_is_busy_or_change(), sbc_lun_status_is_cdb_field(), sbc_lun_status_is_fail(), sbc_lun_status_is_not_present(), sbc_lun_status_is_protected(), and scsi_decode_command().
| #define Sbc_send_check_condition | ( | ) | (g_scsi_status = CHECK_CONDITION) |
Definition at line 289 of file scsi_decoder.h.
| #define Sbc_send_good | ( | ) | (g_scsi_status = COMMAND_PASSED) |
| #define Sbc_build_sense | ( | skey, | |||
| sasc, | |||||
| sascq | ) |
Value:
( g_scsi_sense.key = skey, \ g_scsi_sense.asc = sasc, \ g_scsi_sense.ascq = sascq )
Definition at line 291 of file scsi_decoder.h.
Referenced by sbc_lun_status_is_busy_or_change(), sbc_lun_status_is_cdb_field(), sbc_lun_status_is_fail(), sbc_lun_status_is_good(), sbc_lun_status_is_not_present(), sbc_lun_status_is_protected(), and scsi_decode_command().
| #define Sbc_valid_write_usb | ( | length | ) |
Value:
( Usb_send_in(), \ g_scsi_data_remaining -= length )
Definition at line 294 of file scsi_decoder.h.
Referenced by sbc_inquiry(), sbc_mode_sense(), sbc_read_capacity(), and sbc_request_sense().
| #define COMMAND_PASSED 0x00 |
Definition at line 298 of file scsi_decoder.h.
| #define COMMAND_FAILED 0x01 |
Definition at line 299 of file scsi_decoder.h.
| #define CHECK_CONDITION 0x02 |
Definition at line 300 of file scsi_decoder.h.
| #define PHASE_ERROR 0x02 |
Definition at line 301 of file scsi_decoder.h.
| Bool scsi_decode_command | ( | void | ) |
SCSI decoder function This function read the SCSI command and launches the appropriate function
| nonr |
0x1B - Optional
Definition at line 132 of file scsi_decoder.c.
References FALSE, g_scsi_command, SBC_ASC_INVALID_COMMAND_OPERATION_CODE, Sbc_build_sense, SBC_CMD_FORMAT_UNIT, SBC_CMD_INQUIRY, SBC_CMD_MODE_SELECT_6, SBC_CMD_MODE_SENSE_10, SBC_CMD_MODE_SENSE_6, SBC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL, SBC_CMD_READ_10, SBC_CMD_READ_CAPACITY, SBC_CMD_READ_LONG, SBC_CMD_RELEASE_10, SBC_CMD_REQUEST_SENSE, SBC_CMD_RESERVE_10, SBC_CMD_SEND_DIAGNOSTIC, SBC_CMD_START_STOP_UNIT, SBC_CMD_SYNCHRONIZE_CACHE, SBC_CMD_TEST_UNIT_READY, SBC_CMD_VERIFY_10, SBC_CMD_WRITE_10, SBC_CMD_WRITE_BUFFER, sbc_inquiry(), sbc_lun_status_is_good(), sbc_mode_sense(), sbc_prevent_allow_medium_removal(), sbc_read_10(), sbc_read_capacity(), sbc_request_sense(), Sbc_send_failed, SBC_SENSE_KEY_ILLEGAL_REQUEST, sbc_test_unit_ready(), sbc_write_10(), Scsi_start_read_action, Scsi_start_write_action, Scsi_stop_read_action, Scsi_stop_write_action, and TRUE.
00133 { 00134 Bool status; 00135 00136 if (g_scsi_command[0] == SBC_CMD_WRITE_10) 00137 { 00138 Scsi_start_write_action(); 00139 status = sbc_write_10(); 00140 Scsi_stop_write_action(); 00141 return status; 00142 } 00143 if (g_scsi_command[0] == SBC_CMD_READ_10 ) 00144 { 00145 Scsi_start_read_action(); 00146 status = sbc_read_10(); 00147 Scsi_stop_read_action(); 00148 return status; 00149 } 00150 00151 switch (g_scsi_command[0]) 00152 { 00153 case SBC_CMD_REQUEST_SENSE: // 0x03 - Mandatory 00154 return sbc_request_sense(); 00155 break; 00156 00157 case SBC_CMD_INQUIRY: // 0x12 - Mandatory 00158 return sbc_inquiry(); 00159 break; 00160 00161 case SBC_CMD_TEST_UNIT_READY: // 0x00 - Mandatory 00162 return sbc_test_unit_ready(); 00163 break; 00164 00165 case SBC_CMD_READ_CAPACITY: // 0x25 - Mandatory 00166 return sbc_read_capacity(); 00167 break; 00168 00169 case SBC_CMD_MODE_SENSE_6: // 0x1A - Optional 00170 return sbc_mode_sense( FALSE ); 00171 break; 00172 00173 case SBC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:// 0x1E 00174 return sbc_prevent_allow_medium_removal(); 00175 break; 00176 00177 case SBC_CMD_VERIFY_10: // 0x2F - Optional 00178 sbc_lun_status_is_good(); 00179 break; 00180 00181 case SBC_CMD_MODE_SENSE_10: // 0x5A - Optional 00182 return sbc_mode_sense( TRUE ); 00183 break; 00184 00185 case SBC_CMD_FORMAT_UNIT: // 0x04 - Mandatory 00186 case SBC_CMD_MODE_SELECT_6: // 0x15 - Optional 00187 case SBC_CMD_START_STOP_UNIT: 00188 case SBC_CMD_SEND_DIAGNOSTIC: // 0x1D - 00189 case SBC_CMD_READ_LONG: // 0x23 - Optional 00190 case SBC_CMD_SYNCHRONIZE_CACHE: // 0x35 - Optional 00191 case SBC_CMD_WRITE_BUFFER: // 0x3B - Optional 00192 case SBC_CMD_RESERVE_10: // 0x56 - Mandatory 00193 case SBC_CMD_RELEASE_10: // 0x57 - Mandatory - see chapter 7.16 - SPC 2 00194 default: 00195 // Command not supported 00196 Sbc_send_failed(); 00197 Sbc_build_sense(SBC_SENSE_KEY_ILLEGAL_REQUEST, SBC_ASC_INVALID_COMMAND_OPERATION_CODE, 0x00); 00198 return FALSE; 00199 break; 00200 } 00201 return TRUE; 00202 }
| Bool sbc_inquiry | ( | void | ) |
This function manages the SCSI INQUIRY command (0x12) The SCSI Inquiry field contains information regarding parameters of the target. For example:
| none |
Definition at line 287 of file scsi_decoder.c.
References FALSE, g_sbc_product_id, g_sbc_revision_id, g_sbc_vendor_id, g_scsi_command, sbc_lun_status_is_cdb_field(), sbc_lun_status_is_good(), SBC_MAX_INQUIRY_DATA, Sbc_valid_write_usb, TRUE, and Usb_write_byte.
00288 { 00289 U8 allocation_length, i; 00290 00291 #ifdef __GNUC__ 00292 PGM_VOID_P ptr; 00293 #else 00294 U8 code *ptr; 00295 #endif 00296 00297 if( (0 != (g_scsi_command[1] & 0x03) ) // CMDT and EPVD bits are 0 00298 || (0 != g_scsi_command[2] ) ) // PAGE or OPERATION CODE fields = 0x00? 00299 { 00300 // (CMDT=EVPD <> 0) or (PAGE CODE <> 0x00) 00301 sbc_lun_status_is_cdb_field(); 00302 return FALSE; 00303 } 00304 00305 // Check the size of inquiry data 00306 allocation_length = g_scsi_command[4]; 00307 if (allocation_length > SBC_MAX_INQUIRY_DATA) 00308 { 00309 allocation_length = SBC_MAX_INQUIRY_DATA; 00310 } 00311 00312 // send first inquiry data (0 to 8) 00313 ptr = (code U8*) &sbc_std_inquiry_data; 00314 00315 for ( i=0 ; ((i != 36) && (allocation_length > i)); i++) 00316 { 00317 if( 8 == i ) 00318 { // send vendor id (8 to 16) 00319 ptr = (code U8 *) &g_sbc_vendor_id; 00320 } 00321 if( 16 == i ) 00322 { // send product id (16 to 32) 00323 ptr = (code U8 *) &g_sbc_product_id; 00324 } 00325 if( 32 == i ) 00326 { // send revision id (32 to 36) 00327 ptr = (code U8 *) &g_sbc_revision_id; 00328 } 00329 #ifndef __GNUC__ 00330 Usb_write_byte((U8)(*ptr++)); 00331 #else // AVRGCC does not support point to PGM space 00332 //warning with AVRGCC assumes devices descriptors are stored in the lower 64Kbytes of on-chip flash memory 00333 Usb_write_byte(pgm_read_byte_near((unsigned int)ptr++)); 00334 #endif 00335 00336 } 00337 Sbc_valid_write_usb(i); 00338 sbc_lun_status_is_good(); 00339 return TRUE; 00340 }
This function manages the SCSI MODE SENSE command (0x1A for sense 6 and 0x5A for sense 10) The SCSI mode sense function returns parameters to an application client. It is a complementary command to the SCSI MODE SELECT command.
| b_sens_10 | ( TRUE = sense 10, TRUE = sense 6) |
Definition at line 543 of file scsi_decoder.c.
References g_scsi_command, sbc_header_mode_sense(), sbc_lun_status_is_cdb_field(), sbc_lun_status_is_good(), SBC_MODE_DATA_LENGTH_CODE_ALL, SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS, SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY, SBC_MSK_PAGE_CODE, SBC_PAGE_CODE_ALL, SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS, SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY, Sbc_valid_write_usb, send_informational_exceptions_page(), send_read_write_error_recovery_page(), and TRUE.
00544 { 00545 U8 allocation_length; 00546 00547 if( b_sense_10 ) 00548 allocation_length = g_scsi_command[8]; 00549 else 00550 allocation_length = g_scsi_command[4]; 00551 00552 // switch for page code 00553 switch ( g_scsi_command[2] & SBC_MSK_PAGE_CODE ) 00554 { 00555 case SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS: 00556 sbc_header_mode_sense( b_sense_10 , SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS ); 00557 send_informational_exceptions_page(); 00558 Sbc_valid_write_usb(SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS + 1); 00559 break; 00560 00561 case SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY: 00562 sbc_header_mode_sense( b_sense_10 , SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY ); 00563 send_read_write_error_recovery_page(allocation_length); 00564 Sbc_valid_write_usb(SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY + 1); 00565 break; 00566 00567 case SBC_PAGE_CODE_ALL: 00568 sbc_header_mode_sense( b_sense_10 , SBC_MODE_DATA_LENGTH_CODE_ALL ); 00569 if( b_sense_10 ) 00570 { 00571 if (allocation_length == 8) 00572 { 00573 Sbc_valid_write_usb(8); 00574 break; 00575 } 00576 } 00577 else 00578 { 00579 if (allocation_length == 4) 00580 { 00581 Sbc_valid_write_usb(4); 00582 break; 00583 } 00584 } 00585 // send page by ascending order code 00586 send_read_write_error_recovery_page(allocation_length); // 12 bytes 00587 if (allocation_length > 12) 00588 { 00589 send_informational_exceptions_page(); // 12 bytes 00590 Sbc_valid_write_usb(SBC_MODE_DATA_LENGTH_CODE_ALL + 1); 00591 } 00592 else 00593 { 00594 Sbc_valid_write_usb(allocation_length); 00595 } 00596 break; 00597 00598 default: 00599 sbc_lun_status_is_cdb_field(); 00600 return TRUE; 00601 break; 00602 } 00603 sbc_lun_status_is_good(); 00604 return TRUE; 00605 }
| Bool sbc_mode_select_6 | ( | void | ) |
| Bool sbc_request_sense | ( | void | ) |
This function manages the SCSI REQUEST SENSE command (0x03) The SCSI Sense contains the status of the last command This status is composed of 3 Bytes :
| none |
Definition at line 222 of file scsi_decoder.c.
References s_scsi_sense::asc, s_scsi_sense::ascq, g_scsi_command, s_scsi_sense::key, SBC_ADDITIONAL_SENSE_LENGTH, SBC_COMMAND_SPECIFIC_INFORMATION_0, SBC_COMMAND_SPECIFIC_INFORMATION_1, SBC_COMMAND_SPECIFIC_INFORMATION_2, SBC_COMMAND_SPECIFIC_INFORMATION_3, SBC_FIELD_REPLACEABLE_UNIT_CODE, sbc_lun_status_is_good(), SBC_RESPONSE_CODE_SENSE, SBC_SENSE_KEY_SPECIFIC_0, SBC_SENSE_KEY_SPECIFIC_1, SBC_SENSE_KEY_SPECIFIC_2, Sbc_valid_write_usb, TRUE, and Usb_write_byte.
00223 { 00224 U8 allocation_length, i; 00225 U8 request_sens_output[18]; // the maximum size of request is 17 00226 00227 allocation_length = g_scsi_command[4]; // Allocation length 00228 if( allocation_length > 18 ) 00229 { 00230 allocation_length = 18; 00231 } 00232 // Initialize the request sense data 00233 request_sens_output[0] = SBC_RESPONSE_CODE_SENSE; // 70h 00234 request_sens_output[1] = 0x00; // Obsolete 00235 request_sens_output[2] = g_scsi_sense.key; 00236 00237 request_sens_output[3] = 0x00; // For direct access media, Information field 00238 request_sens_output[4] = 0x00; // give the unsigned logical block 00239 request_sens_output[5] = 0x00; // address associated with the sense key 00240 request_sens_output[6] = 0x00; 00241 00242 request_sens_output[7] = SBC_ADDITIONAL_SENSE_LENGTH; // UFI device shall not adjust the Additional sense length to reflect truncation 00243 request_sens_output[8] = SBC_COMMAND_SPECIFIC_INFORMATION_3; 00244 request_sens_output[9] = SBC_COMMAND_SPECIFIC_INFORMATION_2; 00245 request_sens_output[10] = SBC_COMMAND_SPECIFIC_INFORMATION_1; 00246 request_sens_output[11] = SBC_COMMAND_SPECIFIC_INFORMATION_0; 00247 00248 request_sens_output[12] = g_scsi_sense.asc; 00249 request_sens_output[13] = g_scsi_sense.ascq; 00250 00251 request_sens_output[14] = SBC_FIELD_REPLACEABLE_UNIT_CODE; 00252 request_sens_output[15] = SBC_SENSE_KEY_SPECIFIC_2; 00253 request_sens_output[16] = SBC_SENSE_KEY_SPECIFIC_1; 00254 request_sens_output[17] = SBC_SENSE_KEY_SPECIFIC_0; 00255 00256 // Send the request data 00257 for( i=0 ; i<allocation_length ; i++ ) 00258 { 00259 Usb_write_byte( request_sens_output[i] ); 00260 } 00261 Sbc_valid_write_usb( allocation_length ); 00262 00263 sbc_lun_status_is_good(); 00264 return TRUE; 00265 }
| Bool sbc_format | ( | void | ) |
| Bool sbc_write_10 | ( | void | ) |
warning For Win98 data must be read to avoid blocking
Definition at line 466 of file scsi_decoder.c.
References CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, CTRL_NO_PRESENT, FALSE, g_scsi_command, g_scsi_data_remaining, LSB, mem_wr_protect(), MSB, MSB0, MSB1, MSB2, MSB3, sbc_lun_status_is_busy_or_change(), sbc_lun_status_is_cdb_field(), sbc_lun_status_is_fail(), sbc_lun_status_is_good(), sbc_lun_status_is_not_present(), sbc_lun_status_is_protected(), TRUE, usb_2_memory(), and usb_LUN.
00467 { 00468 U32 mass_addr; // rd or wr block address 00469 U16 mass_size; // rd or write nb of blocks 00470 00471 MSB0(mass_addr) = g_scsi_command[2]; // read address 00472 MSB1(mass_addr) = g_scsi_command[3]; 00473 MSB2(mass_addr) = g_scsi_command[4]; 00474 MSB3(mass_addr) = g_scsi_command[5]; 00475 00476 MSB(mass_size) = g_scsi_command[7]; // read size 00477 LSB(mass_size) = g_scsi_command[8]; 00478 00479 if( 0 == g_scsi_data_remaining ) 00480 { 00481 if( mass_size == (g_scsi_data_remaining/512) ) 00482 { 00483 sbc_lun_status_is_good(); 00484 }else{ 00485 sbc_lun_status_is_cdb_field(); 00486 } 00487 return TRUE; 00488 } 00489 00490 if( TRUE == mem_wr_protect( usb_LUN ) ) 00491 { 00493 sbc_lun_status_is_protected(); 00494 return TRUE; 00495 } 00496 00497 switch (usb_2_memory( usb_LUN , mass_addr, g_scsi_data_remaining/512 )) 00498 { 00499 case CTRL_GOOD : 00500 if( mass_size == (g_scsi_data_remaining/512) ) 00501 { 00502 sbc_lun_status_is_good(); 00503 }else{ 00504 sbc_lun_status_is_cdb_field(); 00505 } 00506 g_scsi_data_remaining = 0; 00507 break; 00508 00509 case CTRL_NO_PRESENT : 00510 sbc_lun_status_is_not_present(); 00511 return FALSE; 00512 break; 00513 00514 case CTRL_BUSY : 00515 sbc_lun_status_is_busy_or_change(); 00516 return FALSE; 00517 break; 00518 00519 case CTRL_FAIL : 00520 default : 00521 sbc_lun_status_is_fail(); 00522 return FALSE; 00523 break; 00524 } 00525 return TRUE; 00526 }
| Bool sbc_read_10 | ( | void | ) |
Definition at line 405 of file scsi_decoder.c.
References CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, CTRL_NO_PRESENT, FALSE, g_scsi_command, g_scsi_data_remaining, Is_usb_ms_data_direction_out, LSB, memory_2_usb(), MSB, MSB0, MSB1, MSB2, MSB3, sbc_lun_status_is_busy_or_change(), sbc_lun_status_is_cdb_field(), sbc_lun_status_is_fail(), sbc_lun_status_is_good(), sbc_lun_status_is_not_present(), TRUE, and usb_LUN.
00406 { 00407 U32 mass_addr; // rd or wr block address 00408 U16 mass_size; // rd or write nb of blocks 00409 00410 MSB0(mass_addr) = g_scsi_command[2]; // read address 00411 MSB1(mass_addr) = g_scsi_command[3]; 00412 MSB2(mass_addr) = g_scsi_command[4]; 00413 MSB3(mass_addr) = g_scsi_command[5]; 00414 00415 MSB(mass_size) = g_scsi_command[7]; // read size 00416 LSB(mass_size) = g_scsi_command[8]; 00417 00418 if( Is_usb_ms_data_direction_out() ) 00419 { 00420 sbc_lun_status_is_cdb_field(); 00421 return FALSE; 00422 } 00423 if( 0 == g_scsi_data_remaining ) 00424 { 00425 if( mass_size == (g_scsi_data_remaining/512) ) 00426 { 00427 sbc_lun_status_is_good(); 00428 }else{ 00429 sbc_lun_status_is_cdb_field(); 00430 } 00431 return TRUE; 00432 } 00433 00434 switch ( memory_2_usb( usb_LUN , mass_addr, g_scsi_data_remaining/512 ) ) 00435 { 00436 case CTRL_GOOD : 00437 if( mass_size == (g_scsi_data_remaining/512) ) 00438 { 00439 sbc_lun_status_is_good(); 00440 }else{ 00441 sbc_lun_status_is_cdb_field(); 00442 } 00443 g_scsi_data_remaining = 0; 00444 break; 00445 00446 case CTRL_NO_PRESENT : 00447 sbc_lun_status_is_not_present(); 00448 return FALSE; 00449 break; 00450 00451 case CTRL_BUSY : 00452 sbc_lun_status_is_busy_or_change(); 00453 return FALSE; 00454 break; 00455 00456 case CTRL_FAIL : 00457 default : 00458 sbc_lun_status_is_fail(); 00459 return FALSE; 00460 break; 00461 } 00462 return TRUE; 00463 }
| Bool sbc_test_unit_ready | ( | void | ) |
Definition at line 343 of file scsi_decoder.c.
References CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, CTRL_NO_PRESENT, mem_test_unit_ready(), sbc_lun_status_is_busy_or_change(), sbc_lun_status_is_fail(), sbc_lun_status_is_good(), sbc_lun_status_is_not_present(), TRUE, and usb_LUN.
00344 { 00345 switch ( mem_test_unit_ready(usb_LUN) ) 00346 { 00347 case CTRL_GOOD : 00348 sbc_lun_status_is_good(); 00349 break; 00350 00351 case CTRL_NO_PRESENT : 00352 sbc_lun_status_is_not_present(); 00353 break; 00354 00355 case CTRL_BUSY : 00356 sbc_lun_status_is_busy_or_change(); 00357 break; 00358 00359 case CTRL_FAIL : 00360 default : 00361 sbc_lun_status_is_fail(); 00362 break; 00363 } 00364 return TRUE; 00365 }
| Bool sbc_read_capacity | ( | void | ) |
Definition at line 368 of file scsi_decoder.c.
References CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, CTRL_NO_PRESENT, mem_read_capacity(), MSB0, MSB1, MSB2, MSB3, sbc_lun_status_is_busy_or_change(), sbc_lun_status_is_fail(), sbc_lun_status_is_good(), sbc_lun_status_is_not_present(), SBC_READ_CAPACITY_LENGTH, Sbc_valid_write_usb, TRUE, usb_LUN, and Usb_write_byte.
00369 { 00370 U32 mem_size_nb_sector; 00371 00372 switch ( mem_read_capacity( usb_LUN, &mem_size_nb_sector ) ) 00373 { 00374 case CTRL_GOOD : 00375 Usb_write_byte(MSB0(mem_size_nb_sector)); // return nb block 00376 Usb_write_byte(MSB1(mem_size_nb_sector)); 00377 Usb_write_byte(MSB2(mem_size_nb_sector)); 00378 Usb_write_byte(MSB3(mem_size_nb_sector)); 00379 Usb_write_byte( 0 ); // return block size (= 512B) 00380 Usb_write_byte( 0 ); 00381 Usb_write_byte( (U8)(512 >> 8) ); 00382 Usb_write_byte( (U8)(512 & 0xFF)); 00383 00384 Sbc_valid_write_usb(SBC_READ_CAPACITY_LENGTH); 00385 sbc_lun_status_is_good(); 00386 break; 00387 00388 case CTRL_NO_PRESENT : 00389 sbc_lun_status_is_not_present(); 00390 break; 00391 00392 case CTRL_BUSY : 00393 sbc_lun_status_is_busy_or_change(); 00394 break; 00395 00396 case CTRL_FAIL : 00397 default : 00398 sbc_lun_status_is_fail(); 00399 break; 00400 } 00401 return TRUE; 00402 }
| Bool sbc_prevent_allow_medium_removal | ( | void | ) |
This function manages the SCSI PREVENT ALLOW MEDIUM REMOVAL command (0x1E) The SCSI prevent allow medium removal command requests that the target enable or disable the removal of the medium in the logical unit.
| none |
Definition at line 728 of file scsi_decoder.c.
References sbc_lun_status_is_good(), and TRUE.
00729 { 00730 sbc_lun_status_is_good(); 00731 return TRUE; 00732 }
| void sbc_lun_status_is_good | ( | void | ) |
This fonction send the UFI status GOOD.
Definition at line 737 of file scsi_decoder.c.
References SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, Sbc_build_sense, Sbc_send_good, and SBC_SENSE_KEY_NO_SENSE.
00738 { 00739 Sbc_send_good(); 00740 Sbc_build_sense(SBC_SENSE_KEY_NO_SENSE, SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, 0x00); 00741 }
| void sbc_lun_status_is_busy_or_change | ( | void | ) |
This fonction send the UFI status busy and change.
Definition at line 753 of file scsi_decoder.c.
References SBC_ASC_NOT_READY_TO_READY_CHANGE, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_UNIT_ATTENTION.
00754 { 00755 Sbc_send_failed(); 00756 Sbc_build_sense(SBC_SENSE_KEY_UNIT_ATTENTION, SBC_ASC_NOT_READY_TO_READY_CHANGE, 0x00 ); 00757 }
| void sbc_lun_status_is_not_present | ( | void | ) |
This fonction send the UFI status "lun not present".
Definition at line 745 of file scsi_decoder.c.
References SBC_ASC_MEDIUM_NOT_PRESENT, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_NOT_READY.
00746 { 00747 Sbc_send_failed(); 00748 Sbc_build_sense(SBC_SENSE_KEY_NOT_READY, SBC_ASC_MEDIUM_NOT_PRESENT, 0x00); 00749 }
| void sbc_lun_status_is_fail | ( | void | ) |
This fonction send the UFI status FAIL.
Definition at line 761 of file scsi_decoder.c.
References SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_HARDWARE_ERROR.
00762 { 00763 Sbc_send_failed(); 00764 Sbc_build_sense(SBC_SENSE_KEY_HARDWARE_ERROR, SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, 0x00); 00765 }
| void sbc_lun_status_is_protected | ( | void | ) |
This fonction send the UFI status FAIL because write protection.
Definition at line 769 of file scsi_decoder.c.
References SBC_ASC_WRITE_PROTECTED, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_DATA_PROTECT.
00770 { 00771 Sbc_send_failed(); 00772 Sbc_build_sense(SBC_SENSE_KEY_DATA_PROTECT, SBC_ASC_WRITE_PROTECTED, 0x00); 00773 }
| void sbc_lun_status_is_cdb_field | ( | void | ) |
This fonction send the UFI status FAIL because CDB field is invalid.
Definition at line 777 of file scsi_decoder.c.
References SBC_ASC_INVALID_FIELD_IN_CDB, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_ILLEGAL_REQUEST.
00778 { 00779 Sbc_send_failed(); 00780 Sbc_build_sense(SBC_SENSE_KEY_ILLEGAL_REQUEST, SBC_ASC_INVALID_FIELD_IN_CDB, 0x00); 00781 }
1.5.3