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 12 typedef 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_10 = 0x28, 21 SCSI_WRITE_10 = 0x2a, 22 SCSI_SYNCHRONIZE_CACHE_10 = 0x35, 23 SCSI_READ_12 = 0xA8, 24 SCSI_WRITE_12 = 0xAA, 25 SCSI_READ_16 = 0x88, 26 SCSI_WRITE_16 = 0x8A, 27 SCSI_SERVICE_ACTION_IN = 0x9E, 28 } scsi_operations; 29 30 typedef enum { 31 SCSI_SAI_READ_CAPACITY_16 = 0x10, 32 } scsi_service_actions; 33 34 // common command structures 35 typedef struct scsi_command_6_s { 36 uint8 operation; 37 uint8 lun; 38 uint8 reserved[2]; 39 uint8 allocation_length; 40 uint8 control; 41 } _PACKED scsi_command_6; 42 43 typedef struct scsi_command_10_s { 44 uint8 operation; 45 uint8 lun_flags; 46 uint32 logical_block_address; 47 uint8 additional_data; 48 uint16 transfer_length; 49 uint8 control; 50 } _PACKED scsi_command_10; 51 52 // parameters = returned data 53 typedef struct scsi_request_sense_6_parameter_s { 54 uint8 error_code : 7; 55 uint8 valid : 1; 56 uint8 segment_number; 57 uint8 sense_key : 4; 58 uint8 unused_1 : 4; 59 uint32 information; 60 uint8 additional_sense_length; 61 uint32 command_specific_information; 62 uint8 additional_sense_code; 63 uint8 additional_sense_code_qualifier; 64 uint8 field_replacable_unit_code; 65 uint8 sense_key_specific[3]; 66 } _PACKED scsi_request_sense_6_parameter; 67 68 typedef struct scsi_inquiry_6_parameter_s { 69 uint8 peripherial_device_type : 5; 70 uint8 peripherial_qualifier : 3; 71 uint8 reserved_1 : 7; 72 uint8 removable_medium : 1; 73 uint8 version; 74 uint8 response_data_format : 4; 75 uint8 unused_1 : 4; 76 uint8 additional_length; 77 uint8 unused_2[3]; 78 char vendor_identification[8]; 79 char product_identification[16]; 80 char product_revision_level[4]; 81 } _PACKED scsi_inquiry_6_parameter; 82 83 typedef struct scsi_mode_sense_6_parameter_s { 84 uint8 data_length; 85 uint8 medium_type; 86 uint8 device_specific; 87 uint8 block_descriptor_length; 88 uint8 densitiy; 89 uint8 num_blocks[3]; 90 uint8 reserved; 91 uint8 block_length[3]; 92 } _PACKED scsi_mode_sense_6_parameter; 93 94 typedef struct scsi_read_capacity_10_parameter_s { 95 uint32 last_logical_block_address; 96 uint32 logical_block_length; 97 } _PACKED scsi_read_capacity_10_parameter; 98 99 typedef struct scsi_read_capacity_16_parameter_s { 100 uint64 last_logical_block_address; 101 uint32 logical_block_length; 102 uint8 reserved[20]; 103 } _PACKED scsi_read_capacity_16_parameter; 104 105 // request sense keys/codes 106 typedef enum { 107 SCSI_SENSE_KEY_NO_SENSE = 0x00, 108 SCSI_SENSE_KEY_RECOVERED_ERROR = 0x01, 109 SCSI_SENSE_KEY_NOT_READY = 0x02, 110 SCSI_SENSE_KEY_MEDIUM_ERROR = 0x03, 111 SCSI_SENSE_KEY_HARDWARE_ERROR = 0x04, 112 SCSI_SENSE_KEY_ILLEGAL_REQUEST = 0x05, 113 SCSI_SENSE_KEY_UNIT_ATTENTION = 0x06, 114 SCSI_SENSE_KEY_DATA_PROTECT = 0x07, 115 SCSI_SENSE_KEY_ABORTED_COMMAND = 0x0b, 116 } scsi_sense_key; 117 118 // request sense additional sense codes 119 #define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3a 120 121 // mode sense page code/parameter 122 #define SCSI_MODE_PAGE_DEVICE_CONFIGURATION 0x10 123 #define SCSI_DEVICE_SPECIFIC_WRITE_PROTECT 0x80 124 125 #endif // _USB_DISK_SCSI_H_ 126