47 #ifndef _SCSI_DECODER_H_
48 #define _SCSI_DECODER_H_
71 #define SBC_CMD_TEST_UNIT_READY (0x00)
72 #define SBC_CMD_REQUEST_SENSE (0x03)
73 #define SBC_CMD_FORMAT_UNIT (0x04)
74 #define SBC_CMD_READ_6 (0x08)
75 #define SBC_CMD_INQUIRY (0x12)
76 #define SBC_CMD_MODE_SELECT_6 (0x15)
77 #define SBC_CMD_MODE_SENSE_6 (0x1A)
78 #define SBC_CMD_START_STOP_UNIT (0x1B)
79 #define SBC_CMD_RECEIVE_DIAGNOSTICS (0x1C)
80 #define SBC_CMD_SEND_DIAGNOSTIC (0x1D)
81 #define SBC_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL (0x1E)
82 #define SBC_CMD_READ_LONG (0x23)
83 #define SBC_CMD_READ_CAPACITY (0x25)
84 #define SBC_CMD_READ_CD_ROM_CAPACITY (0x25)
85 #define SBC_CMD_READ_10 (0x28)
86 #define SBC_CMD_WRITE_10 (0x2A)
87 #define SBC_CMD_VERIFY_10 (0x2F)
88 #define SBC_CMD_SYNCHRONIZE_CACHE (0x35)
89 #define SBC_CMD_WRITE_BUFFER (0x3B)
90 #define SBC_CMD_CHANGE_DEFINITION (0x40)
91 #define SBC_CMD_READ_TOC (0x43)
92 #define SBC_CMD_MODE_SELECT_10 (0x55)
93 #define SBC_CMD_RESERVE_10 (0x56)
94 #define SBC_CMD_RELEASE_10 (0x57)
95 #define SBC_CMD_MODE_SENSE_10 (0x5A)
97 #define SBC_CONTROL_BYTE (0x00)
98 #define SBC_CMD_DIR_IN (0x80)
99 #define SBC_CMD_DIR_OUT (0x00)
105 #define SBC_SENSE_KEY_NO_SENSE (0x00)
106 #define SBC_SENSE_KEY_RECOVERED_ERROR (0x01)
107 #define SBC_SENSE_KEY_NOT_READY (0x02)
108 #define SBC_SENSE_KEY_MEDIUM_ERROR (0x03)
109 #define SBC_SENSE_KEY_HARDWARE_ERROR (0x04)
110 #define SBC_SENSE_KEY_ILLEGAL_REQUEST (0x05)
111 #define SBC_SENSE_KEY_UNIT_ATTENTION (0x06)
112 #define SBC_SENSE_KEY_DATA_PROTECT (0x07)
113 #define SBC_SENSE_KEY_BLANK_CHECK (0x08)
114 #define SBC_SENSE_KEY_VENDOR_SPECIFIC (0x09)
115 #define SBC_SENSE_KEY_COPY_ABORTED (0x0A)
116 #define SBC_SENSE_KEY_ABORTED_COMMAND (0x0B)
117 #define SBC_SENSE_KEY_VOLUME_OVERFLOW (0x0D)
118 #define SBC_SENSE_KEY_MISCOMPARE (0x0E)
123 #define SBC_ASC_NO_ADDITIONAL_SENSE_INFORMATION (0x00)
124 #define SBC_ASC_LOGICAL_UNIT_NOT_READY (0x04)
125 #define SBC_ASC_INVALID_FIELD_IN_CDB (0x24)
126 #define SBC_ASC_WRITE_PROTECTED (0x27)
127 #define SBC_ASC_FORMAT_ERROR (0x31)
128 #define SBC_ASC_INVALID_COMMAND_OPERATION_CODE (0x20)
129 #define SBC_ASC_NOT_READY_TO_READY_CHANGE (0x28)
130 #define SBC_ASC_MEDIUM_NOT_PRESENT (0x3A)
135 #define SBC_ASCQ_FORMAT_COMMAND_FAILED (0x01)
136 #define SBC_ASCQ_INITIALIZING_COMMAND_REQUIRED (0x02)
137 #define SBC_ASCQ_OPERATION_IN_PROGRESS (0x07)
143 #define SBC_RESPONSE_CODE_SENSE (0x70)
144 #define SBC_ADDITIONAL_SENSE_LENGTH (0x0A)
145 #define SBC_COMMAND_SPECIFIC_INFORMATION_3 (0x00)
146 #define SBC_COMMAND_SPECIFIC_INFORMATION_2 (0x00)
147 #define SBC_COMMAND_SPECIFIC_INFORMATION_1 (0x00)
148 #define SBC_COMMAND_SPECIFIC_INFORMATION_0 (0x00)
149 #define SBC_FIELD_REPLACEABLE_UNIT_CODE (0x00)
150 #define SBC_SENSE_KEY_SPECIFIC_2 (0x00)
151 #define SBC_SENSE_KEY_SPECIFIC_1 (0x00)
152 #define SBC_SENSE_KEY_SPECIFIC_0 (0x00)
155 #define SBC_READ_CAPACITY_LENGTH (0x08)
163 #define SBC_DEFAULT_MEDIUM_TYPE (0x00)
164 #define SBC_FLEXIBLE_DISK_SINGLE_SIDED_UNSPECIFIED (0x01)
165 #define SBC_FLEXIBLE_DISK_DOUBLE_SIDED_UNSPECIFIED (0x02)
167 #define SBC_MEDIUM_TYPE SBC_DEFAULT_MEDIUM_TYPE
169 #define SBC_DEV_SPEC_PARAM_WR_ENABLE (0x00)
170 #define SBC_DEV_SPEC_PARAM_WR_PROTECT (0x80)
171 #define SBC_BLOCK_DESCRIPTOR_LENGTH (0x00)
173 #define SBC_MSK_DBD (0x08)
174 #define SBC_MSK_PAGE_CONTROL (0xC0)
175 #define SBC_MSK_PAGE_CODE (0x3F)
179 #define SBC_PAGE_CODE_READ_WRITE_ERROR_RECOVERY (0x01)
180 #define SBC_PAGE_CODE_FORMAT_DEVICE (0x03)
181 #define SBC_PAGE_CODE_FLEXIBLE_DISK (0x05)
182 #define SBC_PAGE_CODE_INFORMATIONAL_EXCEPTIONS (0x1C)
183 #define SBC_PAGE_CODE_ALL (0x3F)
186 #define SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS (0x0A)
187 #define SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY (0x0A)
188 #define SBC_PAGE_LENGTH_FLEXIBLE_DISK (0x1E)
189 #define SBC_PAGE_LENGTH_FORMAT_DEVICE (0x16)
193 #define SBC_MODE_DATA_LENGTH_INFORMATIONAL_EXCEPTIONS (SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS + 2 + 3)
194 #define SBC_MODE_DATA_LENGTH_READ_WRITE_ERROR_RECOVERY (SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY + 2 + 3 )
195 #define SBC_MODE_DATA_LENGTH_FLEXIBLE_DISK (SBC_PAGE_LENGTH_FLEXIBLE_DISK + 2 + 3 )
196 #define SBC_MODE_DATA_LENGTH_FORMAT_DEVICE (SBC_PAGE_LENGTH_FORMAT_DEVICE + 2 + 3 )
198 #define SBC_MODE_DATA_LENGTH_CODE_ALL (SBC_PAGE_LENGTH_READ_WRITE_ERROR_RECOVERY + 2 + \
199 SBC_PAGE_LENGTH_INFORMATIONAL_EXCEPTIONS + 2 + \
200 SBC_BLOCK_DESCRIPTOR_LENGTH + \
205 #define SBC_MRIE (0x05)
208 #define SBC_TRACK_PER_ZONE_MSB (0x00)
209 #define SBC_TRACK_PER_ZONE_LSB (0x00)
210 #define SBC_ALTERNATE_SECTORS_PER_ZONE_MSB (0x00)
211 #define SBC_ALTERNATE_SECTORS_PER_ZONE_LSB (0x00)
212 #define SBC_ALTERNATE_TRACK_PER_ZONE_MSB (0x00)
213 #define SBC_ALTERNATE_TRACK_PER_ZONE_LSB (0x00)
214 #define SBC_ALTERNATE_TRACK_PER_LU_MSB (0x00)
215 #define SBC_ALTERNATE_TRACK_PER_LU_LSB (0x00)
218 #define SBC_TRANSFER_RATE_MSB (0x13)
219 #define SBC_TRANSFER_RATE_LSB (0x88)
227 #define SBC_NUMBER_OF_HEAD (0x04)
228 #define SBC_SECTOR_PER_TRACK (0x20)
229 #define SBC_DATA_BYTE_PER_SECTOR_MSB (0x02)
230 #define SBC_DATA_BYTE_PER_SECTOR_LSB (0x00)
231 #define SBC_NUMBER_OF_CYLINDERS_MSB (0x01)
232 #define SBC_NUMBER_OF_CYLINDERS_LSB (0xE9)
233 #define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_MSB (0x00)
234 #define SBC_STARTING_CYLINDER_WRITE_COMPENSATION_LSB (0x00)
235 #define SBC_STARTING_CYLINDER_REDUCED_WRITE_MSB (0x00)
236 #define SBC_STARTING_CYLINDER_REDUCED_WRITE_LSB (0x00)
237 #define SBC_DEVICE_STEP_RATE_MSB (0x00)
238 #define SBC_DEVICE_STEP_RATE_LSB (0x00)
239 #define SBC_DEVICE_STEP_PULSE_WIDTH (0x00)
240 #define SBC_HEAD_SETTLE_DELAY_MSB (0x00)
241 #define SBC_HEAD_SETTLE_DELAY_LSB (0x00)
242 #define SBC_MOTOR_ON_DELAY (0x00)
243 #define SBC_MOTOR_OFF_DELAY (0x00)
244 #define SBC_STEP_PULSE_PER_CYLINDER (0x00)
245 #define SBC_WRITE_COMPENSATION (0x00)
246 #define SBC_HEAD_LOAD_DELAY (0x00)
247 #define SBC_HEAD_UNLOAD_DELAY (0x00)
248 #define SBC_PIN34_PIN2 (0x00)
249 #define SBC_PIN4_PIN1 (0x00)
250 #define SBC_MEDIUM_ROTATION_RATE_MSB (0x00)
251 #define SBC_MEDIUM_ROTATION_RATE_LSB (0x00)
254 #define SBC_READ_RETRY_COUNT (0x03)
255 #define SBC_WRITE_RETRY_COUNT (0x80)
256 #define SBC_CORRECTION_SPAN (0x00)
257 #define SBC_HEAD_OFFSET_COUNT (0x00)
258 #define SBC_DATA_STROBE_OFFSET (0x00)
259 #define SBC_RECOVERY_LIMIT_MSB (0x00)
260 #define SBC_RECOVERY_LIMIT_LSB (0x00)
265 #define SBC_MAX_INQUIRY_DATA (0x60) // value ?
267 struct sbc_st_std_inquiry_data
270 Byte PeripheralQualifier : 3;
273 Byte RemovableMedia : 1;
285 Byte CommandQueue : 1;
287 Byte LinkedCommands : 1;
288 Byte Synchronous : 1;
291 Byte RelativeAddressing : 1;
297 #define Sbc_send_failed() (g_scsi_status = COMMAND_FAILED)
298 #define Sbc_send_check_condition() (g_scsi_status = CHECK_CONDITION)
299 #define Sbc_send_good() (g_scsi_status = COMMAND_PASSED)
306 #define Sbc_build_sense(skey, sasc, sascq) ( g_scsi_sense.key = skey, \
307 g_scsi_sense.asc = sasc, \
308 g_scsi_sense.ascq = sascq )
310 #define Sbc_valid_write_usb(length) ( Usb_send_in(), \
311 g_scsi_data_remaining -= length )
314 #define COMMAND_PASSED 0x00
315 #define COMMAND_FAILED 0x01
316 #define CHECK_CONDITION 0x02
317 #define PHASE_ERROR 0x02
322 Bool sbc_mode_select_6 (
void);
324 Bool sbc_format (
void);
325 Bool sbc_write_10 (
void);
326 Bool sbc_read_10 (
void);
327 Bool sbc_test_unit_ready(
void);
328 Bool sbc_read_capacity(
void);