1f9f848faSopenharmony_ci/*- 2f9f848faSopenharmony_ci * Largely written by Julian Elischer (julian@tfs.com) 3f9f848faSopenharmony_ci * for TRW Financial Systems. 4f9f848faSopenharmony_ci * 5f9f848faSopenharmony_ci * TRW Financial Systems, in accordance with their agreement with Carnegie 6f9f848faSopenharmony_ci * Mellon University, makes this software available to CMU to distribute 7f9f848faSopenharmony_ci * or use in any manner that they see fit as long as this message is kept with 8f9f848faSopenharmony_ci * the software. For this reason TFS also grants any other persons or 9f9f848faSopenharmony_ci * organisations permission to use or modify this software. 10f9f848faSopenharmony_ci * 11f9f848faSopenharmony_ci * TFS supplies this software to be publicly redistributed 12f9f848faSopenharmony_ci * on the understanding that TFS is not responsible for the correct 13f9f848faSopenharmony_ci * functioning of this software in any circumstances. 14f9f848faSopenharmony_ci * 15f9f848faSopenharmony_ci * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 16f9f848faSopenharmony_ci */ 17f9f848faSopenharmony_ci 18f9f848faSopenharmony_ci/* 19f9f848faSopenharmony_ci * SCSI general interface description 20f9f848faSopenharmony_ci */ 21f9f848faSopenharmony_ci 22f9f848faSopenharmony_ci#ifndef __INCLUDE_SCSI_ALL_H 23f9f848faSopenharmony_ci#define __INCLUDE_SCSI_ALL_H 24f9f848faSopenharmony_ci 25f9f848faSopenharmony_ci#define SC_SCSI_1 0x01 26f9f848faSopenharmony_ci#define SC_SCSI_2 0x03 27f9f848faSopenharmony_ci 28f9f848faSopenharmony_ci#define SCSI_REV_2 0x02 29f9f848faSopenharmony_ci 30f9f848faSopenharmony_ci/* 31f9f848faSopenharmony_ci * Opcodes 32f9f848faSopenharmony_ci */ 33f9f848faSopenharmony_ci 34f9f848faSopenharmony_ci#define TEST_UNIT_READY 0x00 35f9f848faSopenharmony_ci#define REQUEST_SENSE 0x03 36f9f848faSopenharmony_ci#define READ_6 0x08 37f9f848faSopenharmony_ci#define WRITE_6 0x0A 38f9f848faSopenharmony_ci#define INQUIRY 0x12 39f9f848faSopenharmony_ci#define MODE_SELECT_6 0x15 40f9f848faSopenharmony_ci#define MODE_SENSE_6 0x1A 41f9f848faSopenharmony_ci#define START_STOP_UNIT 0x1B 42f9f848faSopenharmony_ci#define START_STOP 0x1B 43f9f848faSopenharmony_ci#define RESERVE 0x16 44f9f848faSopenharmony_ci#define RELEASE 0x17 45f9f848faSopenharmony_ci#define RECEIVE_DIAGNOSTIC 0x1C 46f9f848faSopenharmony_ci#define SEND_DIAGNOSTIC 0x1D 47f9f848faSopenharmony_ci#define PREVENT_ALLOW 0x1E 48f9f848faSopenharmony_ci#define READ_CAPACITY 0x25 49f9f848faSopenharmony_ci#define READ_10 0x28 50f9f848faSopenharmony_ci#define WRITE_10 0x2A 51f9f848faSopenharmony_ci#define POSITION_TO_ELEMENT 0x2B 52f9f848faSopenharmony_ci#define WRITE_VERIFY_10 0x2E 53f9f848faSopenharmony_ci#define VERIFY_10 0x2F 54f9f848faSopenharmony_ci#define SYNCHRONIZE_CACHE 0x35 55f9f848faSopenharmony_ci#define READ_DEFECT_DATA_10 0x37 56f9f848faSopenharmony_ci#define WRITE_BUFFER 0x3B 57f9f848faSopenharmony_ci#define READ_BUFFER 0x3C 58f9f848faSopenharmony_ci#define CHANGE_DEFINITION 0x40 59f9f848faSopenharmony_ci#define WRITE_SAME_10 0x41 60f9f848faSopenharmony_ci#define UNMAP 0x42 61f9f848faSopenharmony_ci#define LOG_SELECT 0x4C 62f9f848faSopenharmony_ci#define LOG_SENSE 0x4D 63f9f848faSopenharmony_ci#define MODE_SELECT_10 0x55 64f9f848faSopenharmony_ci#define RESERVE_10 0x56 65f9f848faSopenharmony_ci#define RELEASE_10 0x57 66f9f848faSopenharmony_ci#define MODE_SENSE_10 0x5A 67f9f848faSopenharmony_ci#define PERSISTENT_RES_IN 0x5E 68f9f848faSopenharmony_ci#define PERSISTENT_RES_OUT 0x5F 69f9f848faSopenharmony_ci#define EXTENDED_COPY 0x83 70f9f848faSopenharmony_ci#define RECEIVE_COPY_STATUS 0x84 71f9f848faSopenharmony_ci#define ATA_PASS_16 0x85 72f9f848faSopenharmony_ci#define READ_16 0x88 73f9f848faSopenharmony_ci#define COMPARE_AND_WRITE 0x89 74f9f848faSopenharmony_ci#define WRITE_16 0x8A 75f9f848faSopenharmony_ci#define WRITE_VERIFY_16 0x8E 76f9f848faSopenharmony_ci#define VERIFY_16 0x8F 77f9f848faSopenharmony_ci#define SYNCHRONIZE_CACHE_16 0x91 78f9f848faSopenharmony_ci#define WRITE_SAME_16 0x93 79f9f848faSopenharmony_ci#define SERVICE_ACTION_IN 0x9E 80f9f848faSopenharmony_ci#define REPORT_LUNS 0xA0 81f9f848faSopenharmony_ci#define ATA_PASS_12 0xA1 82f9f848faSopenharmony_ci#define MAINTENANCE_IN 0xA3 83f9f848faSopenharmony_ci#define MAINTENANCE_OUT 0xA4 84f9f848faSopenharmony_ci#define MOVE_MEDIUM 0xA5 85f9f848faSopenharmony_ci#define READ_12 0xA8 86f9f848faSopenharmony_ci#define WRITE_12 0xAA 87f9f848faSopenharmony_ci#define WRITE_VERIFY_12 0xAE 88f9f848faSopenharmony_ci#define VERIFY_12 0xAF 89f9f848faSopenharmony_ci#define READ_ELEMENT_STATUS 0xB8 90f9f848faSopenharmony_ci#define READ_CD 0xBE 91f9f848faSopenharmony_ci 92f9f848faSopenharmony_ci/* Maintenance In Service Action Codes */ 93f9f848faSopenharmony_ci#define REPORT_IDENTIFYING_INFRMATION 0x05 94f9f848faSopenharmony_ci#define REPORT_TARGET_PORT_GROUPS 0x0A 95f9f848faSopenharmony_ci#define REPORT_ALIASES 0x0B 96f9f848faSopenharmony_ci#define REPORT_SUPPORTED_OPERATION_CODES 0x0C 97f9f848faSopenharmony_ci#define REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0D 98f9f848faSopenharmony_ci#define REPORT_PRIORITY 0x0E 99f9f848faSopenharmony_ci#define REPORT_TIMESTAMP 0x0F 100f9f848faSopenharmony_ci#define MANAGEMENT_PROTOCOL_IN 0x10 101f9f848faSopenharmony_ci/* Maintenance Out Service Action Codes */ 102f9f848faSopenharmony_ci#define SET_IDENTIFY_INFORMATION 0x06 103f9f848faSopenharmony_ci#define SET_TARGET_PORT_GROUPS 0x0A 104f9f848faSopenharmony_ci#define CHANGE_ALIASES 0x0B 105f9f848faSopenharmony_ci#define SET_PRIORITY 0x0E 106f9f848faSopenharmony_ci#define SET_TIMESTAMP 0x0F 107f9f848faSopenharmony_ci#define MANGAEMENT_PROTOCOL_OUT 0x10 108f9f848faSopenharmony_ci 109f9f848faSopenharmony_ci/* 110f9f848faSopenharmony_ci * Device Types 111f9f848faSopenharmony_ci */ 112f9f848faSopenharmony_ci#define T_DIRECT 0x00 113f9f848faSopenharmony_ci#define T_SEQUENTIAL 0x01 114f9f848faSopenharmony_ci#define T_PRINTER 0x02 115f9f848faSopenharmony_ci#define T_PROCESSOR 0x03 116f9f848faSopenharmony_ci#define T_WORM 0x04 117f9f848faSopenharmony_ci#define T_CDROM 0x05 118f9f848faSopenharmony_ci#define T_SCANNER 0x06 119f9f848faSopenharmony_ci#define T_OPTICAL 0x07 120f9f848faSopenharmony_ci#define T_CHANGER 0x08 121f9f848faSopenharmony_ci#define T_COMM 0x09 122f9f848faSopenharmony_ci#define T_ASC0 0x0a 123f9f848faSopenharmony_ci#define T_ASC1 0x0b 124f9f848faSopenharmony_ci#define T_STORARRAY 0x0c 125f9f848faSopenharmony_ci#define T_ENCLOSURE 0x0d 126f9f848faSopenharmony_ci#define T_RBC 0x0e 127f9f848faSopenharmony_ci#define T_OCRW 0x0f 128f9f848faSopenharmony_ci#define T_OSD 0x11 129f9f848faSopenharmony_ci#define T_ADC 0x12 130f9f848faSopenharmony_ci#define T_NODEVICE 0x1f 131f9f848faSopenharmony_ci#define T_ANY 0xff /* Used in Quirk table matches */ 132f9f848faSopenharmony_ci 133f9f848faSopenharmony_ci#define T_REMOV 1 134f9f848faSopenharmony_ci#define T_FIXED 0 135f9f848faSopenharmony_ci 136f9f848faSopenharmony_ci/* 137f9f848faSopenharmony_ci * This length is the initial inquiry length used by the probe code, as 138f9f848faSopenharmony_ci * well as the length necessary for scsi_print_inquiry() to function 139f9f848faSopenharmony_ci * correctly. If either use requires a different length in the future, 140f9f848faSopenharmony_ci * the two values should be de-coupled. 141f9f848faSopenharmony_ci */ 142f9f848faSopenharmony_ci#define SHORT_INQUIRY_LENGTH 36 143f9f848faSopenharmony_ci 144f9f848faSopenharmony_cistruct scsi_test_unit_ready 145f9f848faSopenharmony_ci{ 146f9f848faSopenharmony_ci uint8_t opcode; 147f9f848faSopenharmony_ci uint8_t byte2; 148f9f848faSopenharmony_ci uint8_t unused[3]; 149f9f848faSopenharmony_ci uint8_t control; 150f9f848faSopenharmony_ci}; 151f9f848faSopenharmony_ci 152f9f848faSopenharmony_cistruct scsi_sense 153f9f848faSopenharmony_ci{ 154f9f848faSopenharmony_ci uint8_t opcode; 155f9f848faSopenharmony_ci uint8_t byte2; 156f9f848faSopenharmony_ci uint8_t unused[2]; 157f9f848faSopenharmony_ci uint8_t length; 158f9f848faSopenharmony_ci uint8_t control; 159f9f848faSopenharmony_ci}; 160f9f848faSopenharmony_ci 161f9f848faSopenharmony_cistruct scsi_inquiry 162f9f848faSopenharmony_ci{ 163f9f848faSopenharmony_ci uint8_t opcode; 164f9f848faSopenharmony_ci uint8_t byte2; 165f9f848faSopenharmony_ci#define SI_EVPD 0x01 166f9f848faSopenharmony_ci#define SI_CMDDT 0x02 167f9f848faSopenharmony_ci uint8_t page_code; 168f9f848faSopenharmony_ci uint8_t length[2]; 169f9f848faSopenharmony_ci uint8_t control; 170f9f848faSopenharmony_ci}; 171f9f848faSopenharmony_ci 172f9f848faSopenharmony_cistruct scsi_sense_data 173f9f848faSopenharmony_ci{ 174f9f848faSopenharmony_ci uint8_t error_code; 175f9f848faSopenharmony_ci /* 176f9f848faSopenharmony_ci * SPC-4 says that the maximum length of sense data is 252 bytes. 177f9f848faSopenharmony_ci * So this structure is exactly 252 bytes log. 178f9f848faSopenharmony_ci */ 179f9f848faSopenharmony_ci#define SSD_FULL_SIZE 252 180f9f848faSopenharmony_ci uint8_t sense_buf[SSD_FULL_SIZE - 1]; 181f9f848faSopenharmony_ci /* 182f9f848faSopenharmony_ci * XXX KDM is this still a reasonable minimum size? 183f9f848faSopenharmony_ci */ 184f9f848faSopenharmony_ci#define SSD_MIN_SIZE 18 185f9f848faSopenharmony_ci /* 186f9f848faSopenharmony_ci * Maximum value for the extra_len field in the sense data. 187f9f848faSopenharmony_ci */ 188f9f848faSopenharmony_ci#define SSD_EXTRA_MAX 244 189f9f848faSopenharmony_ci}; 190f9f848faSopenharmony_ci 191f9f848faSopenharmony_cistruct scsi_start_stop_unit 192f9f848faSopenharmony_ci{ 193f9f848faSopenharmony_ci uint8_t opcode; 194f9f848faSopenharmony_ci uint8_t byte2; 195f9f848faSopenharmony_ci#define SSS_IMMED 0x01 196f9f848faSopenharmony_ci uint8_t reserved[2]; 197f9f848faSopenharmony_ci uint8_t how; 198f9f848faSopenharmony_ci#define SSS_START 0x01 199f9f848faSopenharmony_ci#define SSS_LOEJ 0x02 200f9f848faSopenharmony_ci#define SSS_PC_MASK 0xf0 201f9f848faSopenharmony_ci#define SSS_PC_START_VALID 0x00 202f9f848faSopenharmony_ci#define SSS_PC_ACTIVE 0x10 203f9f848faSopenharmony_ci#define SSS_PC_IDLE 0x20 204f9f848faSopenharmony_ci#define SSS_PC_STANDBY 0x30 205f9f848faSopenharmony_ci#define SSS_PC_LU_CONTROL 0x70 206f9f848faSopenharmony_ci#define SSS_PC_FORCE_IDLE_0 0xa0 207f9f848faSopenharmony_ci#define SSS_PC_FORCE_STANDBY_0 0xb0 208f9f848faSopenharmony_ci uint8_t control; 209f9f848faSopenharmony_ci}; 210f9f848faSopenharmony_ci 211f9f848faSopenharmony_ci/* 212f9f848faSopenharmony_ci * Opcodes 213f9f848faSopenharmony_ci */ 214f9f848faSopenharmony_ci#define VERIFIED 0x2f 215f9f848faSopenharmony_ci#define REZERO_UNIT 0x01 216f9f848faSopenharmony_ci#define FORMAT_UNIT 0x04 217f9f848faSopenharmony_ci#define REASSIGN_BLOCKS 0x07 218f9f848faSopenharmony_ci#define MODE_SELECT 0x15 219f9f848faSopenharmony_ci#define MODE_SENSE 0x1a 220f9f848faSopenharmony_ci#define READ_FORMAT_CAPACITIES 0x23 221f9f848faSopenharmony_ci#define WRITE_AND_VERIFY 0x2e 222f9f848faSopenharmony_ci#define READ_DEFECT_DATA_10 0x37 223f9f848faSopenharmony_ci#define SANITIZE 0x48 224f9f848faSopenharmony_ci#define READ_DEFECT_DATA_12 0xb7 225f9f848faSopenharmony_ci 226f9f848faSopenharmony_ci#endif 227