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