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