ATMEL: scsi_decoder.h File Reference

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

# scsi_decoder.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | s_scsi_sense
struct | sbc_st_std_inquiry_data

## Defines

#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)
#define | SBC_CMD_INQUIRY (0x12)
#define | SBC_CMD_MODE_SELECT_6 (0x15)
#define | SBC_CMD_READ_FORMAT_CAPACITY (0x23)
#define | SBC_CMD_MODE_SENSE_6 (0x1A)
#define | SBC_CMD_START_STOP_UNIT (0x1B)
#define | SBC_CMD_RECEIVE_DIAGNOSTICS (0x1C)
#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)
#define | SBC_CMD_READ_10 (0x28)
#define | SBC_CMD_WRITE_10 (0x2A)
#define | SBC_CMD_SEEK (0x2B)
#define | SBC_CMD_WRITE_VERIFY_10 (0x2E)
#define | SBC_CMD_VERIFY_10 (0x2F)
#define | SBC_CMD_SYNCHRONIZE_CACHE (0x35)
#define | SBC_CMD_WRITE_BUFFER (0x3B)
#define | SBC_CMD_CHANGE_DEFINITION (0x40)
#define | SBC_CMD_READ_TOC (0x43)
#define | SBC_CMD_MODE_SELECT_10 (0x55)
#define | SBC_CMD_RESERVE_10 (0x56)
#define | SBC_CMD_RELEASE_10 (0x57)
#define | SBC_CMD_MODE_SENSE_10 (0x5A)
#define | SBC_CONTROL_BYTE (0x00)
#define | SBC_CMD_DIR_IN (0x80)
#define | SBC_CMD_DIR_OUT (0x00)
#define | SBC_SENSE_KEY_NO_SENSE (0x00)
#define | SBC_SENSE_KEY_RECOVERED_ERROR (0x01)
#define | SBC_SENSE_KEY_NOT_READY (0x02)
#define | SBC_SENSE_KEY_MEDIUM_ERROR (0x03)
#define | SBC_SENSE_KEY_HARDWARE_ERROR (0x04)
#define | SBC_SENSE_KEY_ILLEGAL_REQUEST (0x05)
#define | SBC_SENSE_KEY_UNIT_ATTENTION (0x06)
#define | SBC_SENSE_KEY_DATA_PROTECT (0x07)
#define | SBC_SENSE_KEY_BLANK_CHECK (0x08)
#define | SBC_SENSE_KEY_VENDOR_SPECIFIC (0x09)
#define | SBC_SENSE_KEY_COPY_ABORTED (0x0A)
#define | SBC_SENSE_KEY_ABORTED_COMMAND (0x0B)
#define | SBC_SENSE_KEY_VOLUME_OVERFLOW (0x0D)
#define | SBC_SENSE_KEY_MISCOMPARE (0x0E)
#define | SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION (0x00)
#define | SBC_ASC_LOGICAL_UNIT_NOT_READY (0x04)
#define | SBC_ASC_INVALID_FIELD_IN_CDB (0x24)
#define | SBC_ASC_WRITE_PROTECTED (0x27)
#define | SBC_ASC_FORMAT_ERROR (0x31)
#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)
#define | SBC_ASCQ_INITIALIZING_COMMAND_REQUIRED (0x02)
#define | SBC_ASCQ_OPERATION_IN_PROGRESS (0x07)
#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)
#define | SBC_FLEXIBLE_DISK_SINGLE_SIDED_UNSPECIFIED (0x01)
#define | SBC_FLEXIBLE_DISK_DOUBLE_SIDED_UNSPECIFIED (0x02)
#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)
#define | SBC_MSK_PAGE_CONTROL (0xC0)
#define | SBC_MSK_PAGE_CODE (0x3F)
#define | SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY (0x01)
#define | SBC_PAGE_CODE_FORMAT_DEVICE (0x03)
#define | SBC_PAGE_CODE_FLEXIBLE_DISK (0x05)
#define | SBC_PAGE_CODE_CACHING_MODE_PAGE (0x08)
#define | SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS (0x1C)
#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)
#define | SBC_PAGE_LENGTH_FORMAT_DEVICE (0x16)
#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 )
#define | SBC_MODE_DATA_LENGTH_FORMAT_DEVICE (SBC_PAGE_LENGTH_FORMAT_DEVICE + 2 + 3 )
#define | SBC_MODE_DATA_LENGTH_CODE_ALL
#define | SBC_MRIE (0x05)
#define | SBC_TRACK_PER_ZONE_MSB (0x00)
#define | SBC_TRACK_PER_ZONE_LSB (0x00)
#define | SBC_ALTERNATE_SECTORS_PER_ZONE_MSB (0x00)
#define | SBC_ALTERNATE_SECTORS_PER_ZONE_LSB (0x00)
#define | SBC_ALTERNATE_TRACK_PER_ZONE_MSB (0x00)
#define | SBC_ALTERNATE_TRACK_PER_ZONE_LSB (0x00)
#define | SBC_ALTERNATE_TRACK_PER_LU_MSB (0x00)
#define | SBC_ALTERNATE_TRACK_PER_LU_LSB (0x00)
#define | SBC_TRANSFER_RATE_MSB (0x13)
#define | SBC_TRANSFER_RATE_LSB (0x88)
#define | SBC_NUMBER_OF_HEAD (0x04)
#define | SBC_SECTOR_PER_TRACK (0x20)
#define | SBC_DATA_BYTE_PER_SECTOR_MSB (0x02)
#define | SBC_DATA_BYTE_PER_SECTOR_LSB (0x00)
#define | SBC_NUMBER_OF_CYLINDERS_MSB (0x01)
#define | SBC_NUMBER_OF_CYLINDERS_LSB (0xE9)
#define | SBC_STARTING_CYLINDER_WRITE_COMPENSATION_MSB (0x00)
#define | SBC_STARTING_CYLINDER_WRITE_COMPENSATION_LSB (0x00)
#define | SBC_STARTING_CYLINDER_REDUCED_WRITE_MSB (0x00)
#define | SBC_STARTING_CYLINDER_REDUCED_WRITE_LSB (0x00)
#define | SBC_DEVICE_STEP_RATE_MSB (0x00)
#define | SBC_DEVICE_STEP_RATE_LSB (0x00)
#define | SBC_DEVICE_STEP_PULSE_WIDTH (0x00)
#define | SBC_HEAD_SETTLE_DELAY_MSB (0x00)
#define | SBC_HEAD_SETTLE_DELAY_LSB (0x00)
#define | SBC_MOTOR_ON_DELAY (0x00)
#define | SBC_MOTOR_OFF_DELAY (0x00)
#define | SBC_STEP_PULSE_PER_CYLINDER (0x00)
#define | SBC_WRITE_COMPENSATION (0x00)
#define | SBC_HEAD_LOAD_DELAY (0x00)
#define | SBC_HEAD_UNLOAD_DELAY (0x00)
#define | SBC_PIN34_PIN2 (0x00)
#define | SBC_PIN4_PIN1 (0x00)
#define | SBC_MEDIUM_ROTATION_RATE_MSB (0x00)
#define | SBC_MEDIUM_ROTATION_RATE_LSB (0x00)
#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)
#define | Sbc_send_check_condition() (g_scsi_status = CHECK_CONDITION)
#define | Sbc_send_good() (g_scsi_status = COMMAND_PASSED)
#define | Sbc_build_sense(skey, sasc, sascq)
#define | Sbc_valid_write_usb(length)
#define | COMMAND_PASSED 0x00
#define | COMMAND_FAILED 0x01
#define | CHECK_CONDITION 0x02
#define | PHASE_ERROR 0x02

## Functions

Bool | scsi_decode_command (void)
Bool | sbc_inquiry (void)
Bool | sbc_mode_sense (Bool sense_10)
Bool | sbc_mode_select_6 (void)
Bool | sbc_request_sense (void)
Bool | sbc_format (void)
Bool | sbc_write_10 (void)
Bool | sbc_read_10 (void)
Bool | sbc_test_unit_ready (void)
Bool | sbc_read_capacity (void)
Bool | sbc_prevent_allow_medium_removal (void)
void | sbc_lun_status_is_good (void)
| This fonction send the UFI status GOOD.
void | sbc_lun_status_is_busy_or_change (void)
| This fonction send the UFI status busy and change.
void | sbc_lun_status_is_not_present (void)
| This fonction send the UFI status "lun not present".
void | sbc_lun_status_is_fail (void)
| This fonction send the UFI status FAIL.
void | sbc_lun_status_is_protected (void)
| This fonction send the UFI status FAIL because write protection.
void | sbc_lun_status_is_cdb_field (void)
| This fonction send the UFI status FAIL because CDB field is invalid.

## Detailed Description

This file contains declarations for the SCSI decoder module.

- Compiler: IAR EWAVR and GNU GCC for AVR
- Supported devices: AT90USB1287, AT90USB1286, AT90USB647, AT90USB646

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file scsi_decoder.h.

## Define Documentation

#define SBC_CMD_TEST_UNIT_READY (0x00)

Definition at line 78 of file scsi_decoder.h.

Referenced by host_mem_test_unit_ready(), and scsi_decode_command().

#define SBC_CMD_REQUEST_SENSE (0x03)

Definition at line 79 of file scsi_decoder.h.

Referenced by host_mem_request_sense(), and scsi_decode_command().

#define SBC_CMD_FORMAT_UNIT (0x04)

Definition at line 80 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_READ_6 (0x08)

Definition at line 81 of file scsi_decoder.h.

#define SBC_CMD_INQUIRY (0x12)

Definition at line 82 of file scsi_decoder.h.

Referenced by host_mem_inquiry(), and scsi_decode_command().

#define SBC_CMD_MODE_SELECT_6 (0x15)

Definition at line 83 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_READ_FORMAT_CAPACITY (0x23)

Definition at line 84 of file scsi_decoder.h.

#define SBC_CMD_MODE_SENSE_6 (0x1A)

Definition at line 85 of file scsi_decoder.h.

Referenced by host_mem_wr_protect(), and scsi_decode_command().

#define SBC_CMD_START_STOP_UNIT (0x1B)

Definition at line 86 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_RECEIVE_DIAGNOSTICS (0x1C)

Definition at line 87 of file scsi_decoder.h.

#define SBC_CMD_SEND_DIAGNOSTIC (0x1D)

Definition at line 88 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL (0x1E)

Definition at line 89 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_READ_LONG (0x23)

Definition at line 90 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_READ_CAPACITY (0x25)

Definition at line 91 of file scsi_decoder.h.

Referenced by host_mem_read_capacity(), and scsi_decode_command().

#define SBC_CMD_READ_CD_ROM_CAPACITY (0x25)

Definition at line 92 of file scsi_decoder.h.

#define SBC_CMD_READ_10 (0x28)

Definition at line 93 of file scsi_decoder.h.

Referenced by host_mem_mem_2_ram(), host_mem_mem_2_ram_ext(), and scsi_decode_command().

#define SBC_CMD_WRITE_10 (0x2A)

Definition at line 94 of file scsi_decoder.h.

Referenced by host_mem_ram_2_mem(), host_mem_ram_2_mem_ext(), and scsi_decode_command().

#define SBC_CMD_SEEK (0x2B)

Definition at line 95 of file scsi_decoder.h.

#define SBC_CMD_WRITE_VERIFY_10 (0x2E)

Definition at line 96 of file scsi_decoder.h.

#define SBC_CMD_VERIFY_10 (0x2F)

Definition at line 97 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_SYNCHRONIZE_CACHE (0x35)

Definition at line 98 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_WRITE_BUFFER (0x3B)

Definition at line 99 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_CHANGE_DEFINITION (0x40)

Definition at line 100 of file scsi_decoder.h.

#define SBC_CMD_READ_TOC (0x43)

Definition at line 101 of file scsi_decoder.h.

#define SBC_CMD_MODE_SELECT_10 (0x55)

Definition at line 102 of file scsi_decoder.h.

#define SBC_CMD_RESERVE_10 (0x56)

Definition at line 103 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_RELEASE_10 (0x57)

Definition at line 104 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CMD_MODE_SENSE_10 (0x5A)

Definition at line 105 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_CONTROL_BYTE (0x00)

Definition at line 107 of file scsi_decoder.h.

#define SBC_CMD_DIR_IN (0x80)

Definition at line 108 of file scsi_decoder.h.

Referenced by host_mem_inquiry(), host_mem_mem_2_ram(), host_mem_mem_2_ram_ext(), host_mem_read_capacity(), host_mem_request_sense(), and host_mem_wr_protect().

#define SBC_CMD_DIR_OUT (0x00)

Definition at line 109 of file scsi_decoder.h.

Referenced by host_mem_ram_2_mem(), host_mem_ram_2_mem_ext(), and host_mem_test_unit_ready().

#define SBC_SENSE_KEY_NO_SENSE (0x00)

Definition at line 115 of file scsi_decoder.h.

Referenced by sbc_lun_status_is_good().

#define SBC_SENSE_KEY_RECOVERED_ERROR (0x01)

Definition at line 116 of file scsi_decoder.h.

#define SBC_SENSE_KEY_NOT_READY (0x02)

Definition at line 117 of file scsi_decoder.h.

Referenced by host_mem_request_sense(), and sbc_lun_status_is_not_present().

#define SBC_SENSE_KEY_MEDIUM_ERROR (0x03)

Definition at line 118 of file scsi_decoder.h.

#define SBC_SENSE_KEY_HARDWARE_ERROR (0x04)

Definition at line 119 of file scsi_decoder.h.

Referenced by sbc_lun_status_is_fail().

#define SBC_SENSE_KEY_ILLEGAL_REQUEST (0x05)

Definition at line 120 of file scsi_decoder.h.

Referenced by sbc_lun_status_is_cdb_field(), and scsi_decode_command().

#define SBC_SENSE_KEY_UNIT_ATTENTION (0x06)

Definition at line 121 of file scsi_decoder.h.

Referenced by host_mem_request_sense(), and sbc_lun_status_is_busy_or_change().

#define SBC_SENSE_KEY_DATA_PROTECT (0x07)

Definition at line 122 of file scsi_decoder.h.

Referenced by sbc_lun_status_is_protected().

#define SBC_SENSE_KEY_BLANK_CHECK (0x08)

Definition at line 123 of file scsi_decoder.h.

#define SBC_SENSE_KEY_VENDOR_SPECIFIC (0x09)

Definition at line 124 of file scsi_decoder.h.

#define SBC_SENSE_KEY_COPY_ABORTED (0x0A)

Definition at line 125 of file scsi_decoder.h.

#define SBC_SENSE_KEY_ABORTED_COMMAND (0x0B)

Definition at line 126 of file scsi_decoder.h.

#define SBC_SENSE_KEY_VOLUME_OVERFLOW (0x0D)

Definition at line 127 of file scsi_decoder.h.

#define SBC_SENSE_KEY_MISCOMPARE (0x0E)

Definition at line 128 of file scsi_decoder.h.

#define SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION (0x00)

Definition at line 133 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 134 of file scsi_decoder.h.

#define SBC_ASC_INVALID_FIELD_IN_CDB (0x24)

Definition at line 135 of file scsi_decoder.h.

Referenced by sbc_lun_status_is_cdb_field().

#define SBC_ASC_WRITE_PROTECTED (0x27)

Definition at line 136 of file scsi_decoder.h.

Referenced by sbc_lun_status_is_protected().

#define SBC_ASC_FORMAT_ERROR (0x31)

Definition at line 137 of file scsi_decoder.h.

#define SBC_ASC_INVALID_COMMAND_OPERATION_CODE (0x20)

Definition at line 138 of file scsi_decoder.h.

Referenced by scsi_decode_command().

#define SBC_ASC_NOT_READY_TO_READY_CHANGE (0x28)

Definition at line 139 of file scsi_decoder.h.

Referenced by host_mem_request_sense(), and sbc_lun_status_is_busy_or_change().

#define SBC_ASC_MEDIUM_NOT_PRESENT (0x3A)

Definition at line 140 of file scsi_decoder.h.

Referenced by host_mem_request_sense(), and sbc_lun_status_is_not_present().

#define SBC_ASCQ_FORMAT_COMMAND_FAILED (0x01)

Definition at line 145 of file scsi_decoder.h.

#define SBC_ASCQ_INITIALIZING_COMMAND_REQUIRED (0x02)

Definition at line 146 of file scsi_decoder.h.

#define SBC_ASCQ_OPERATION_IN_PROGRESS (0x07)

Definition at line 147 of file scsi_decoder.h.

#define SBC_RESPONSE_CODE_SENSE (0x70)

Definition at line 153 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_ADDITIONAL_SENSE_LENGTH (0x0A)

Definition at line 154 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_COMMAND_SPECIFIC_INFORMATION_3 (0x00)

Definition at line 155 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_COMMAND_SPECIFIC_INFORMATION_2 (0x00)

Definition at line 156 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_COMMAND_SPECIFIC_INFORMATION_1 (0x00)

Definition at line 157 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_COMMAND_SPECIFIC_INFORMATION_0 (0x00)

Definition at line 158 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_FIELD_REPLACEABLE_UNIT_CODE (0x00)

Definition at line 159 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_SENSE_KEY_SPECIFIC_2 (0x00)

Definition at line 160 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_SENSE_KEY_SPECIFIC_1 (0x00)

Definition at line 161 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_SENSE_KEY_SPECIFIC_0 (0x00)

Definition at line 162 of file scsi_decoder.h.

Referenced by sbc_request_sense().

#define SBC_READ_CAPACITY_LENGTH (0x08)

Definition at line 165 of file scsi_decoder.h.

Referenced by sbc_read_capacity().

#define SBC_DEFAULT_MEDIUM_TYPE (0x00)

Definition at line 173 of file scsi_decoder.h.

#define SBC_FLEXIBLE_DISK_SINGLE_SIDED_UNSPECIFIED (0x01)

Definition at line 174 of file scsi_decoder.h.

#define SBC_FLEXIBLE_DISK_DOUBLE_SIDED_UNSPECIFIED (0x02)

Definition at line 175 of file scsi_decoder.h.

#define SBC_MEDIUM_TYPE SBC_DEFAULT_MEDIUM_TYPE

Definition at line 177 of file scsi_decoder.h.

Referenced by sbc_header_mode_sense().

#define SBC_DEV_SPEC_PARAM_WR_ENABLE (0x00)

Definition at line 179 of file scsi_decoder.h.

Referenced by sbc_header_mode_sense().

#define SBC_DEV_SPEC_PARAM_WR_PROTECT (0x80)

Definition at line 180 of file scsi_decoder.h.

Referenced by sbc_header_mode_sense().

#define SBC_BLOCK_DESCRIPTOR_LENGTH (0x00)

Definition at line 181 of file scsi_decoder.h.

Referenced by sbc_header_mode_sense().

#define SBC_MSK_DBD (0x08)

Definition at line 183 of file scsi_decoder.h.

#define SBC_MSK_PAGE_CONTROL (0xC0)

Definition at line 184 of file scsi_decoder.h.

#define SBC_MSK_PAGE_CODE (0x3F)

Definition at line 185 of file scsi_decoder.h.

Referenced by sbc_mode_sense().

#define SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY (0x01)

Definition at line 191 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 192 of file scsi_decoder.h.

#define SBC_PAGE_CODE_FLEXIBLE_DISK (0x05)

Definition at line 193 of file scsi_decoder.h.

#define SBC_PAGE_CODE_CACHING_MODE_PAGE (0x08)

Definition at line 194 of file scsi_decoder.h.

#define SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS (0x1C)

Definition at line 195 of file scsi_decoder.h.

Referenced by sbc_mode_sense(), and send_informational_exceptions_page().

#define SBC_PAGE_CODE_ALL (0x3F)

Definition at line 196 of file scsi_decoder.h.

Referenced by sbc_mode_sense().

#define SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS (0x0A)

Definition at line 198 of file scsi_decoder.h.

Referenced by send_informational_exceptions_page().

#define SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY (0x0A)

Definition at line 199 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_PAGE_LENGTH_FLEXIBLE_DISK (0x1E)

Definition at line 200 of file scsi_decoder.h.

#define SBC_PAGE_LENGTH_FORMAT_DEVICE (0x16)

Definition at line 201 of file scsi_decoder.h.

#define SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS (SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS + 2 + 3)

Definition at line 205 of file scsi_decoder.h.

Referenced by sbc_mode_sense().

#define SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY (SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY + 2 + 3 )

Definition at line 206 of file scsi_decoder.h.

Referenced by sbc_mode_sense().

#define SBC_MODE_DATA_LENGTH_FLEXIBLE_DISK (SBC_PAGE_LENGTH_FLEXIBLE_DISK + 2 + 3 )

Definition at line 207 of file scsi_decoder.h.

#define SBC_MODE_DATA_LENGTH_FORMAT_DEVICE (SBC_PAGE_LENGTH_FORMAT_DEVICE + 2 + 3 )

Definition at line 208 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 210 of file scsi_decoder.h.

Referenced by sbc_mode_sense().

#define SBC_MRIE (0x05)

Definition at line 217 of file scsi_decoder.h.

Referenced by send_informational_exceptions_page().

#define SBC_TRACK_PER_ZONE_MSB (0x00)

Definition at line 220 of file scsi_decoder.h.

#define SBC_TRACK_PER_ZONE_LSB (0x00)

Definition at line 221 of file scsi_decoder.h.

#define SBC_ALTERNATE_SECTORS_PER_ZONE_MSB (0x00)

Definition at line 222 of file scsi_decoder.h.

#define SBC_ALTERNATE_SECTORS_PER_ZONE_LSB (0x00)

Definition at line 223 of file scsi_decoder.h.

#define SBC_ALTERNATE_TRACK_PER_ZONE_MSB (0x00)

Definition at line 224 of file scsi_decoder.h.

#define SBC_ALTERNATE_TRACK_PER_ZONE_LSB (0x00)

Definition at line 225 of file scsi_decoder.h.

#define SBC_ALTERNATE_TRACK_PER_LU_MSB (0x00)

Definition at line 226 of file scsi_decoder.h.

#define SBC_ALTERNATE_TRACK_PER_LU_LSB (0x00)

Definition at line 227 of file scsi_decoder.h.

#define SBC_TRANSFER_RATE_MSB (0x13)

Definition at line 230 of file scsi_decoder.h.

#define SBC_TRANSFER_RATE_LSB (0x88)

Definition at line 231 of file scsi_decoder.h.

#define SBC_NUMBER_OF_HEAD (0x04)

Definition at line 239 of file scsi_decoder.h.

#define SBC_SECTOR_PER_TRACK (0x20)

Definition at line 240 of file scsi_decoder.h.

#define SBC_DATA_BYTE_PER_SECTOR_MSB (0x02)

Definition at line 241 of file scsi_decoder.h.

#define SBC_DATA_BYTE_PER_SECTOR_LSB (0x00)

Definition at line 242 of file scsi_decoder.h.

#define SBC_NUMBER_OF_CYLINDERS_MSB (0x01)

Definition at line 243 of file scsi_decoder.h.

#define SBC_NUMBER_OF_CYLINDERS_LSB (0xE9)

Definition at line 244 of file scsi_decoder.h.

#define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_MSB (0x00)

Definition at line 245 of file scsi_decoder.h.

#define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_LSB (0x00)

Definition at line 246 of file scsi_decoder.h.

#define SBC_STARTING_CYLINDER_REDUCED_WRITE_MSB (0x00)

Definition at line 247 of file scsi_decoder.h.

#define SBC_STARTING_CYLINDER_REDUCED_WRITE_LSB (0x00)

Definition at line 248 of file scsi_decoder.h.

#define SBC_DEVICE_STEP_RATE_MSB (0x00)

Definition at line 249 of file scsi_decoder.h.

#define SBC_DEVICE_STEP_RATE_LSB (0x00)

Definition at line 250 of file scsi_decoder.h.

#define SBC_DEVICE_STEP_PULSE_WIDTH (0x00)

Definition at line 251 of file scsi_decoder.h.

#define SBC_HEAD_SETTLE_DELAY_MSB (0x00)

Definition at line 252 of file scsi_decoder.h.

#define SBC_HEAD_SETTLE_DELAY_LSB (0x00)

Definition at line 253 of file scsi_decoder.h.

#define SBC_MOTOR_ON_DELAY (0x00)

Definition at line 254 of file scsi_decoder.h.

#define SBC_MOTOR_OFF_DELAY (0x00)

Definition at line 255 of file scsi_decoder.h.

#define SBC_STEP_PULSE_PER_CYLINDER (0x00)

Definition at line 256 of file scsi_decoder.h.

#define SBC_WRITE_COMPENSATION (0x00)

Definition at line 257 of file scsi_decoder.h.

#define SBC_HEAD_LOAD_DELAY (0x00)

Definition at line 258 of file scsi_decoder.h.

#define SBC_HEAD_UNLOAD_DELAY (0x00)

Definition at line 259 of file scsi_decoder.h.

#define SBC_PIN34_PIN2 (0x00)

Definition at line 260 of file scsi_decoder.h.

#define SBC_PIN4_PIN1 (0x00)

Definition at line 261 of file scsi_decoder.h.

#define SBC_MEDIUM_ROTATION_RATE_MSB (0x00)

Definition at line 262 of file scsi_decoder.h.

#define SBC_MEDIUM_ROTATION_RATE_LSB (0x00)

Definition at line 263 of file scsi_decoder.h.

#define SBC_READ_RETRY_COUNT (0x03)

Definition at line 266 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_WRITE_RETRY_COUNT (0x80)

Definition at line 267 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_CORRECTION_SPAN (0x00)

Definition at line 268 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_HEAD_OFFSET_COUNT (0x00)

Definition at line 269 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_DATA_STROBE_OFFSET (0x00)

Definition at line 270 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_RECOVERY_LIMIT_MSB (0x00)

Definition at line 271 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_RECOVERY_LIMIT_LSB (0x00)

Definition at line 272 of file scsi_decoder.h.

Referenced by send_read_write_error_recovery_page().

#define SBC_MAX_INQUIRY_DATA (0x60)

Definition at line 277 of file scsi_decoder.h.

Referenced by sbc_inquiry().

#define Sbc_send_failed | ( |  | ) | (g_scsi_status = COMMAND_FAILED)

Definition at line 309 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 310 of file scsi_decoder.h.

#define Sbc_send_good | ( |  | ) | (g_scsi_status = COMMAND_PASSED)

Definition at line 311 of file scsi_decoder.h.

Referenced by sbc_lun_status_is_good().

#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 312 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 315 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 319 of file scsi_decoder.h.

#define COMMAND_FAILED 0x01

Definition at line 320 of file scsi_decoder.h.

#define CHECK_CONDITION 0x02

Definition at line 321 of file scsi_decoder.h.

#define PHASE_ERROR 0x02

Definition at line 322 of file scsi_decoder.h.

## Function Documentation

Bool scsi_decode_command | ( | void |  | ) |

SCSI decoder function This function read the SCSI command and launches the appropriate function

Warning:
  Code:.. bytes (function code length)

Parameters:

  | nonr |

Returns:
  FALSE: result KO, TRUE: result OK

Definition at line 138 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.

    00139 {
    00140    Bool status;
    00141
    00142    if (g_scsi_command[0] == SBC_CMD_WRITE_10)
    00143    {
    00144       Scsi_start_write_action();
    00145       status = sbc_write_10();
    00146       Scsi_stop_write_action();
    00147       return status;
    00148    }
    00149    if (g_scsi_command[0] == SBC_CMD_READ_10 )
    00150    {
    00151       Scsi_start_read_action();
    00152       status = sbc_read_10();
    00153       Scsi_stop_read_action();
    00154       return status;
    00155    }
    00156
    00157    switch (g_scsi_command[0])
    00158    {
    00159       case SBC_CMD_REQUEST_SENSE:               // 0x03 - Mandatory
    00160       return sbc_request_sense();
    00161       break;
    00162
    00163       case SBC_CMD_INQUIRY:                     // 0x12 - Mandatory
    00164       return sbc_inquiry();
    00165       break;
    00166
    00167       case SBC_CMD_TEST_UNIT_READY:             // 0x00 - Mandatory
    00168       return sbc_test_unit_ready();
    00169       break;
    00170
    00171       case SBC_CMD_READ_CAPACITY:               // 0x25 - Mandatory
    00172       return sbc_read_capacity();
    00173       break;
    00174
    00175       case SBC_CMD_MODE_SENSE_6:                // 0x1A - Optional
    00176       return sbc_mode_sense( FALSE );
    00177       break;
    00178
    00179       case SBC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:// 0x1E
    00180       return sbc_prevent_allow_medium_removal();
    00181       break;
    00182
    00183       case SBC_CMD_VERIFY_10:                   // 0x2F - Optional
    00184       sbc_lun_status_is_good();
    00185       break;
    00186
    00187       case SBC_CMD_MODE_SENSE_10:               // 0x5A - Optional
    00188       return sbc_mode_sense( TRUE );
    00189       break;
    00190
    00191       case SBC_CMD_START_STOP_UNIT:             // 0x1B - Optional but ignored because this command is used by the Linux 2.4 kernel,
    00192       sbc_lun_status_is_good();                 // for which we can not reply INVALID COMMAND, otherwise the disk will not mount.
    00193       break;
    00194
    00195       case SBC_CMD_FORMAT_UNIT:                 // 0x04 - Mandatory
    00196       case SBC_CMD_MODE_SELECT_6:               // 0x15 - Optional
    00197       case SBC_CMD_SEND_DIAGNOSTIC:             // 0x1D -
    00198       case SBC_CMD_READ_LONG:                   // 0x23 - Optional
    00199       case SBC_CMD_SYNCHRONIZE_CACHE:           // 0x35 - Optional
    00200       case SBC_CMD_WRITE_BUFFER:                // 0x3B - Optional
    00201       case SBC_CMD_RESERVE_10:                  // 0x56 - Mandatory
    00202       case SBC_CMD_RELEASE_10:                  // 0x57 - Mandatory - see chapter 7.16 - SPC 2
    00203       default:
    00204       // Command not supported
    00205       Sbc_send_failed();
    00206       Sbc_build_sense(SBC_SENSE_KEY_ILLEGAL_REQUEST, SBC_ASC_INVALID_COMMAND_OPERATION_CODE, 0x00);
    00207       return FALSE;
    00208       break;
    00209    }
    00210    return TRUE;
    00211 }

Here is the call graph for this function:

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:

- vendor identification
- product identification
- peripheral qualifier
- peripheral device type
- etc

Warning:
  Code:.. bytes (function code length)

Parameters:

  | none |

Returns:
  FALSE: result KO, TRUE: result OK

Definition at line 296 of file scsi_decoder.c.

References FALSE, g_sbc_product_id, g_sbc_revision_id, g_sbc_vendor_id, g_scsi_command, i, sbc_lun_status_is_cdb_field(), sbc_lun_status_is_good(), SBC_MAX_INQUIRY_DATA, Sbc_valid_write_usb, TRUE, and Usb_write_byte.

    00297 {
    00298    U8 allocation_length, i;
    00299
    00300 #ifdef __GNUC__
    00301    PGM_VOID_P ptr;
    00302 #else
    00303    U8 code *ptr;
    00304 #endif
    00305
    00306    if( (0 != (g_scsi_command[1] & 0x03) )       // CMDT and EPVD bits are 0
    00307    ||  (0 !=  g_scsi_command[2]         ) )     // PAGE or OPERATION CODE fields = 0x00?
    00308    {
    00309       // (CMDT=EVPD <> 0) or (PAGE CODE <> 0x00)
    00310       // No standard inquiry asked
    00311       sbc_lun_status_is_cdb_field();
    00312       return FALSE;
    00313    }
    00314
    00315    // Manage the standard inquiry command
    00316    // Check the size of inquiry data
    00317    allocation_length = g_scsi_command[4];
    00318    if (allocation_length > SBC_MAX_INQUIRY_DATA)
    00319    {
    00320       allocation_length = SBC_MAX_INQUIRY_DATA;
    00321    }
    00322
    00323    // send first inquiry data (0 to 8)
    00324    ptr = (code U8*) &sbc_std_inquiry_data;
    00325
    00326    for ( i=0 ; ((i != 36) && (allocation_length > i)); i++)
    00327    {
    00328       if( 8 == i )
    00329       {  // send vendor id (8 to 16)
    00330            ptr = (code U8 *) &g_sbc_vendor_id;
    00331       }
    00332       if( 16 == i )
    00333       {  // send product id (16 to 32)
    00334          ptr = (code U8 *) &g_sbc_product_id;
    00335       }
    00336       if( 32 == i )
    00337       {  // send revision id (32 to 36)
    00338          ptr = (code U8 *) &g_sbc_revision_id;
    00339       }
    00340 #ifndef __GNUC__
    00341       Usb_write_byte((U8)(*ptr++));
    00342 #else    // AVRGCC does not support point to PGM space
    00343 //warning with AVRGCC assumes devices descriptors are stored in the lower 64Kbytes of on-chip flash memory
    00344       Usb_write_byte(pgm_read_byte_near((unsigned int)ptr++));
    00345 #endif
    00346
    00347    }
    00348    Sbc_valid_write_usb(i);
    00349    sbc_lun_status_is_good();
    00350    return TRUE;
    00351 }

Here is the call graph for this function:

Bool sbc_mode_sense | ( | Bool | b_sense_10 | ) |

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.

Warning:
  Code:.. bytes (function code length)

Parameters:

  | b_sens_10 | ( TRUE = sense 10, TRUE = sense 6)

Returns:
  FALSE: result KO, TRUE: result OK

Definition at line 560 of file scsi_decoder.c.

References FALSE, 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.

    00561 {
    00562    U8 allocation_length;
    00563
    00564    if( b_sense_10 )
    00565       allocation_length = g_scsi_command[8];
    00566    else
    00567       allocation_length = g_scsi_command[4];
    00568
    00569    // switch for page code
    00570    switch ( g_scsi_command[2] & SBC_MSK_PAGE_CODE )
    00571    {
    00572       case SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS:
    00573       sbc_header_mode_sense( b_sense_10 , SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS );
    00574       send_informational_exceptions_page();
    00575       Sbc_valid_write_usb(SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS + 1);
    00576       break;
    00577
    00578       case SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY:
    00579       sbc_header_mode_sense( b_sense_10 , SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY );
    00580       send_read_write_error_recovery_page(allocation_length);
    00581       Sbc_valid_write_usb(SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY + 1);
    00582       break;
    00583
    00584       case SBC_PAGE_CODE_ALL:
    00585       if( b_sense_10 ) {
    00586          sbc_header_mode_sense( b_sense_10 , (allocation_length < (SBC_MODE_DATA_LENGTH_CODE_ALL+2))? (allocation_length-2) : SBC_MODE_DATA_LENGTH_CODE_ALL );
    00587       }else{
    00588          sbc_header_mode_sense( b_sense_10 , (allocation_length < (SBC_MODE_DATA_LENGTH_CODE_ALL+1))? (allocation_length-1) : SBC_MODE_DATA_LENGTH_CODE_ALL );
    00589       }
    00590       if( b_sense_10 )
    00591       {
    00592          if (allocation_length == 8)
    00593          {
    00594             Sbc_valid_write_usb(8);
    00595             break;
    00596          }
    00597       }
    00598       else
    00599       {
    00600          if (allocation_length == 4)
    00601          {
    00602             Sbc_valid_write_usb(4);
    00603             break;
    00604          }
    00605       }
    00606       // send page by ascending order code
    00607       send_read_write_error_recovery_page(allocation_length);  // 12 bytes
    00608       if (allocation_length > 12)
    00609       {
    00610          send_informational_exceptions_page();                 // 12 bytes
    00611          Sbc_valid_write_usb(SBC_MODE_DATA_LENGTH_CODE_ALL + 1);
    00612       }
    00613       else
    00614       {
    00615          Sbc_valid_write_usb(allocation_length);
    00616       }
    00617       break;
    00618
    00619       default:
    00620       sbc_lun_status_is_cdb_field();
    00621       return FALSE;
    00622       break;
    00623    }
    00624    sbc_lun_status_is_good();
    00625    return TRUE;
    00626 }

Here is the call graph for this function:

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 :

- sense key (g_scsi_sense.key)
- additional sense code (g_scsi_sense.asc)
- additional sense code qualifier (g_scsi_sense.ascq)
  Warning:
    Code:.. bytes (function code length)
  Parameters:

    | none |

  Returns:
    FALSE: result KO, TRUE: result OK

Definition at line 231 of file scsi_decoder.c.

References s_scsi_sense::asc, s_scsi_sense::ascq, g_scsi_command, i, 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.

    00232 {
    00233    U8  allocation_length, i;
    00234    U8  request_sens_output[18];                             // the maximum size of request is 17
    00235
    00236    allocation_length = g_scsi_command[4];                   // Allocation length
    00237    if( allocation_length > 18 )
    00238    {
    00239       allocation_length = 18;
    00240    }
    00241    // Initialize the request sense data
    00242    request_sens_output[0] = SBC_RESPONSE_CODE_SENSE;        // 70h
    00243    request_sens_output[1] = 0x00;                           // Obsolete
    00244    request_sens_output[2] = g_scsi_sense.key;
    00245
    00246    request_sens_output[3] = 0x00;                           // For direct access media, Information field
    00247    request_sens_output[4] = 0x00;                           // give the unsigned logical block
    00248    request_sens_output[5] = 0x00;                           // address associated with the sense key
    00249    request_sens_output[6] = 0x00;
    00250
    00251    request_sens_output[7] = SBC_ADDITIONAL_SENSE_LENGTH;    // UFI device shall not adjust the Additional sense length to reflect truncation
    00252    request_sens_output[8] = SBC_COMMAND_SPECIFIC_INFORMATION_3;
    00253    request_sens_output[9] = SBC_COMMAND_SPECIFIC_INFORMATION_2;
    00254    request_sens_output[10] = SBC_COMMAND_SPECIFIC_INFORMATION_1;
    00255    request_sens_output[11] = SBC_COMMAND_SPECIFIC_INFORMATION_0;
    00256
    00257    request_sens_output[12] = g_scsi_sense.asc;
    00258    request_sens_output[13] = g_scsi_sense.ascq;
    00259
    00260    request_sens_output[14] = SBC_FIELD_REPLACEABLE_UNIT_CODE;
    00261    request_sens_output[15] = SBC_SENSE_KEY_SPECIFIC_2;
    00262    request_sens_output[16] = SBC_SENSE_KEY_SPECIFIC_1;
    00263    request_sens_output[17] = SBC_SENSE_KEY_SPECIFIC_0;
    00264
    00265    // Send the request data
    00266    for( i=0 ; i<allocation_length ; i++ )
    00267    {
    00268        Usb_write_byte( request_sens_output[i] );
    00269    }
    00270    Sbc_valid_write_usb( allocation_length );
    00271
    00272    sbc_lun_status_is_good();
    00273    return TRUE;
    00274 }

Here is the call graph for this function:

Bool sbc_format | ( | void |  | ) |

Bool sbc_write_10 | ( | void |  | ) |

Definition at line 478 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_in, 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.

    00479 {
    00480    U32   mass_addr;                       // rd or wr block address
    00481    U16   mass_size;                       // rd or write nb of blocks
    00482
    00483    MSB0(mass_addr) = g_scsi_command[2];   // read address
    00484    MSB1(mass_addr) = g_scsi_command[3];
    00485    MSB2(mass_addr) = g_scsi_command[4];
    00486    MSB3(mass_addr) = g_scsi_command[5];
    00487
    00488    MSB(mass_size) = g_scsi_command[7];    // read size
    00489    LSB(mass_size) = g_scsi_command[8];
    00490
    00491    if( Is_usb_ms_data_direction_in() )
    00492    {
    00493       sbc_lun_status_is_cdb_field();
    00494       return FALSE;
    00495    }
    00496
    00497    if( 0 == g_scsi_data_remaining )
    00498    {
    00499       if( mass_size == (g_scsi_data_remaining/512) )
    00500       {
    00501          sbc_lun_status_is_good();
    00502       }else{
    00503          sbc_lun_status_is_cdb_field();
    00504       }
    00505       return TRUE;
    00506    }
    00507
    00508    if( TRUE == mem_wr_protect( usb_LUN ) )
    00509    {
    00510       sbc_lun_status_is_protected();
    00511       return FALSE;
    00512    }
    00513
    00514    switch (usb_2_memory( usb_LUN , mass_addr, g_scsi_data_remaining/512 ))
    00515    {
    00516       case CTRL_GOOD :
    00517       if( mass_size == (g_scsi_data_remaining/512) )
    00518       {
    00519          sbc_lun_status_is_good();
    00520       }else{
    00521          sbc_lun_status_is_cdb_field();
    00522       }
    00523       g_scsi_data_remaining = 0;
    00524       break;
    00525
    00526       case CTRL_NO_PRESENT :
    00527       sbc_lun_status_is_not_present();
    00528       return FALSE;
    00529       break;
    00530
    00531       case CTRL_BUSY :
    00532       sbc_lun_status_is_busy_or_change();
    00533       return FALSE;
    00534       break;
    00535
    00536       case CTRL_FAIL :
    00537       default :
    00538       sbc_lun_status_is_fail();
    00539       return FALSE;
    00540       break;
    00541    }
    00542    return TRUE;
    00543 }

Here is the call graph for this function:

Bool sbc_read_10 | ( | void |  | ) |

Definition at line 417 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.

    00418 {
    00419    U32   mass_addr;                       // rd or wr block address
    00420    U16   mass_size;                       // rd or write nb of blocks
    00421
    00422    MSB0(mass_addr) = g_scsi_command[2];   // read address
    00423    MSB1(mass_addr) = g_scsi_command[3];
    00424    MSB2(mass_addr) = g_scsi_command[4];
    00425    MSB3(mass_addr) = g_scsi_command[5];
    00426
    00427    MSB(mass_size) = g_scsi_command[7];    // read size
    00428    LSB(mass_size) = g_scsi_command[8];
    00429
    00430    if( Is_usb_ms_data_direction_out() )
    00431    {
    00432       sbc_lun_status_is_cdb_field();
    00433       return FALSE;
    00434    }
    00435    if( 0 == g_scsi_data_remaining )
    00436    {
    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       return TRUE;
    00444    }
    00445
    00446    switch ( memory_2_usb( usb_LUN , mass_addr,  g_scsi_data_remaining/512 ) )
    00447    {
    00448       case CTRL_GOOD :
    00449       if( mass_size == (g_scsi_data_remaining/512) )
    00450       {
    00451          sbc_lun_status_is_good();
    00452       }else{
    00453          sbc_lun_status_is_cdb_field();
    00454       }
    00455       g_scsi_data_remaining = 0;
    00456       break;
    00457
    00458       case CTRL_NO_PRESENT :
    00459       sbc_lun_status_is_not_present();
    00460       return FALSE;
    00461       break;
    00462
    00463       case CTRL_BUSY :
    00464       sbc_lun_status_is_busy_or_change();
    00465       return FALSE;
    00466       break;
    00467
    00468       case CTRL_FAIL :
    00469       default :
    00470       sbc_lun_status_is_fail();
    00471       return FALSE;
    00472       break;
    00473    }
    00474    return TRUE;
    00475 }

Here is the call graph for this function:

Bool sbc_test_unit_ready | ( | void |  | ) |

Definition at line 354 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.

    00355 {
    00356    switch ( mem_test_unit_ready(usb_LUN) )
    00357    {
    00358       case CTRL_GOOD :
    00359       sbc_lun_status_is_good();
    00360       break;
    00361
    00362       case CTRL_NO_PRESENT :
    00363       sbc_lun_status_is_not_present();
    00364       break;
    00365
    00366       case CTRL_BUSY :
    00367       sbc_lun_status_is_busy_or_change();
    00368       break;
    00369
    00370       case CTRL_FAIL :
    00371       default :
    00372       sbc_lun_status_is_fail();
    00373       break;
    00374    }
    00375    return TRUE;
    00376 }

Here is the call graph for this function:

Bool sbc_read_capacity | ( | void |  | ) |

Definition at line 379 of file scsi_decoder.c.

References CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, CTRL_NO_PRESENT, FALSE, 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.

    00380 {
    00381    U32 mem_size_nb_sector;
    00382
    00383    switch ( mem_read_capacity( usb_LUN, &mem_size_nb_sector ) )
    00384    {
    00385       case CTRL_GOOD :
    00386       Usb_write_byte(MSB0(mem_size_nb_sector));    // return nb block
    00387       Usb_write_byte(MSB1(mem_size_nb_sector));
    00388       Usb_write_byte(MSB2(mem_size_nb_sector));
    00389       Usb_write_byte(MSB3(mem_size_nb_sector));
    00390       Usb_write_byte( 0               );           // return block size (= 512B)
    00391       Usb_write_byte( 0               );
    00392       Usb_write_byte( (U8)(512 >> 8)  );
    00393       Usb_write_byte( (U8)(512 & 0xFF));
    00394
    00395       Sbc_valid_write_usb(SBC_READ_CAPACITY_LENGTH);
    00396       sbc_lun_status_is_good();
    00397       return TRUE;
    00398       break;
    00399
    00400       case CTRL_NO_PRESENT :
    00401       sbc_lun_status_is_not_present();
    00402       break;
    00403
    00404       case CTRL_BUSY :
    00405       sbc_lun_status_is_busy_or_change();
    00406       break;
    00407
    00408       case CTRL_FAIL :
    00409       default :
    00410       sbc_lun_status_is_fail();
    00411       break;
    00412    }
    00413    return FALSE;
    00414 }

Here is the call graph for this function:

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.

Warning:
  Code:.. bytes (function code length)

Parameters:

  | none |

Returns:
  FALSE: result KO, TRUE: result OK

Definition at line 749 of file scsi_decoder.c.

References sbc_lun_status_is_good(), and TRUE.

    00750 {
    00751    sbc_lun_status_is_good();
    00752    return TRUE;
    00753 }

Here is the call graph for this function:

void sbc_lun_status_is_good | ( | void |  | ) |

This fonction send the UFI status GOOD.

Definition at line 758 of file scsi_decoder.c.

References SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, Sbc_build_sense, Sbc_send_good, and SBC_SENSE_KEY_NO_SENSE.

    00759 {
    00760    Sbc_send_good();
    00761    Sbc_build_sense(SBC_SENSE_KEY_NO_SENSE, SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, 0x00);
    00762 }

void sbc_lun_status_is_busy_or_change | ( | void |  | ) |

This fonction send the UFI status busy and change.

Definition at line 774 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.

    00775 {
    00776    Sbc_send_failed();
    00777    Sbc_build_sense(SBC_SENSE_KEY_UNIT_ATTENTION, SBC_ASC_NOT_READY_TO_READY_CHANGE, 0x00 );
    00778 }

void sbc_lun_status_is_not_present | ( | void |  | ) |

This fonction send the UFI status "lun not present".

Definition at line 766 of file scsi_decoder.c.

References SBC_ASC_MEDIUM_NOT_PRESENT, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_NOT_READY.

    00767 {
    00768    Sbc_send_failed();
    00769    Sbc_build_sense(SBC_SENSE_KEY_NOT_READY, SBC_ASC_MEDIUM_NOT_PRESENT, 0x00);
    00770 }

void sbc_lun_status_is_fail | ( | void |  | ) |

This fonction send the UFI status FAIL.

Definition at line 782 of file scsi_decoder.c.

References SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_HARDWARE_ERROR.

    00783 {
    00784    Sbc_send_failed();
    00785    Sbc_build_sense(SBC_SENSE_KEY_HARDWARE_ERROR, SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION, 0x00);
    00786 }

void sbc_lun_status_is_protected | ( | void |  | ) |

This fonction send the UFI status FAIL because write protection.

Definition at line 790 of file scsi_decoder.c.

References SBC_ASC_WRITE_PROTECTED, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_DATA_PROTECT.

    00791 {
    00792    Sbc_send_failed();
    00793    Sbc_build_sense(SBC_SENSE_KEY_DATA_PROTECT, SBC_ASC_WRITE_PROTECTED, 0x00);
    00794 }

void sbc_lun_status_is_cdb_field | ( | void |  | ) |

This fonction send the UFI status FAIL because CDB field is invalid.

Definition at line 798 of file scsi_decoder.c.

References SBC_ASC_INVALID_FIELD_IN_CDB, Sbc_build_sense, Sbc_send_failed, and SBC_SENSE_KEY_ILLEGAL_REQUEST.

    00799 {
    00800    Sbc_send_failed();
    00801    Sbc_build_sense(SBC_SENSE_KEY_ILLEGAL_REQUEST, SBC_ASC_INVALID_FIELD_IN_CDB, 0x00);
    00802 }