1/* 2 * Copyright 2008, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Lotz <mmlr@mlotz.ch> 7 */ 8 9#ifndef _USB_DISK_SCSI_H_ 10#define _USB_DISK_SCSI_H_ 11 12typedef enum { 13 SCSI_TEST_UNIT_READY_6 = 0x00, 14 SCSI_REQUEST_SENSE_6 = 0x03, 15 SCSI_INQUIRY_6 = 0x12, 16 SCSI_MODE_SENSE_6 = 0x1a, 17 SCSI_START_STOP_UNIT_6 = 0x1b, 18 SCSI_SEND_DIAGNOSTIC = 0x1d, 19 SCSI_READ_CAPACITY_10 = 0x25, 20 SCSI_READ_12 = 0xA8, 21 SCSI_WRITE_12 = 0xAA, 22 SCSI_SYNCHRONIZE_CACHE_10 = 0x35, 23} scsi_operations; 24 25// parameters = returned data 26typedef struct scsi_request_sense_6_parameter_s { 27 uint8 error_code : 7; 28 uint8 valid : 1; 29 uint8 segment_number; 30 uint8 sense_key : 4; 31 uint8 unused_1 : 4; 32 uint32 information; 33 uint8 additional_sense_length; 34 uint32 command_specific_information; 35 uint8 additional_sense_code; 36 uint8 additional_sense_code_qualifier; 37 uint8 field_replacable_unit_code; 38 uint8 sense_key_specific[3]; 39} _PACKED scsi_request_sense_6_parameter; 40 41typedef struct scsi_inquiry_6_parameter_s { 42 uint8 peripherial_device_type : 5; 43 uint8 peripherial_qualifier : 3; 44 uint8 reserved_1 : 7; 45 uint8 removable_medium : 1; 46 uint8 version; 47 uint8 response_data_format : 4; 48 uint8 unused_1 : 4; 49 uint8 additional_length; 50 uint8 unused_2[3]; 51 char vendor_identification[8]; 52 char product_identification[16]; 53 char product_revision_level[4]; 54} _PACKED scsi_inquiry_6_parameter; 55 56typedef struct scsi_mode_sense_6_parameter_s { 57 uint8 data_length; 58 uint8 medium_type; 59 uint8 device_specific; 60 uint8 block_descriptor_length; 61 uint8 densitiy; 62 uint8 num_blocks[3]; 63 uint8 reserved; 64 uint8 block_length[3]; 65} _PACKED scsi_mode_sense_6_parameter; 66 67typedef struct scsi_read_capacity_10_parameter_s { 68 uint32 last_logical_block_address; 69 uint32 logical_block_length; 70} _PACKED scsi_read_capacity_10_parameter; 71 72// request sense keys/codes 73typedef enum { 74 SCSI_SENSE_KEY_NO_SENSE = 0x00, 75 SCSI_SENSE_KEY_RECOVERED_ERROR = 0x01, 76 SCSI_SENSE_KEY_NOT_READY = 0x02, 77 SCSI_SENSE_KEY_MEDIUM_ERROR = 0x03, 78 SCSI_SENSE_KEY_HARDWARE_ERROR = 0x04, 79 SCSI_SENSE_KEY_ILLEGAL_REQUEST = 0x05, 80 SCSI_SENSE_KEY_UNIT_ATTENTION = 0x06, 81 SCSI_SENSE_KEY_DATA_PROTECT = 0x07, 82 SCSI_SENSE_KEY_ABORTED_COMMAND = 0x0b, 83} scsi_sense_key; 84 85// request sense additional sense codes 86#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3a 87 88// mode sense page code/parameter 89#define SCSI_MODE_PAGE_DEVICE_CONFIGURATION 0x10 90#define SCSI_DEVICE_SPECIFIC_WRITE_PROTECT 0x80 91 92#endif // _USB_DISK_SCSI_H_ 93