xref: /titanic_51/usr/src/uts/common/sys/scsi/impl/commands.h (revision 749f21d359d8fbd020c974a1a5227316221bfc9c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SCSI_IMPL_COMMANDS_H
28 #define	_SYS_SCSI_IMPL_COMMANDS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Implementation dependent command definitions.
38  * This file is included by <sys/scsi/generic/commands.h>
39  */
40 
41 /*
42  * Implementation dependent view of a SCSI command descriptor block
43  */
44 
45 /*
46  * Standard SCSI control blocks definitions.
47  *
48  * These go in or out over the SCSI bus.
49  *
50  * The first 8 bits of the command block are the same for all
51  * defined command groups.  The first byte is an operation which consists
52  * of a command code component and a group code component.
53  *
54  * The group code determines the length of the rest of the command.
55  * Group 0 commands are 6 bytes, Group 1 and 2  are 10 bytes, Group 4
56  * are 16 bytes, and Group 5 are 12 bytes. Groups 3 is Reserved.
57  * Groups 6 and 7 are Vendor Unique.
58  *
59  */
60 #define	CDB_SIZE	CDB_GROUP5	/* deprecated, do not use */
61 #define	SCSI_CDB_SIZE	CDB_GROUP4	/* sizeof (union scsi_cdb) */
62 
63 union scsi_cdb {		/* scsi command description block */
64 	struct {
65 		uchar_t	cmd;		/* cmd code (byte 0) */
66 #if defined(_BIT_FIELDS_LTOH)
67 		uchar_t tag	:5;	/* rest of byte 1 */
68 		uchar_t lun	:3;	/* lun (byte 1) (reserved in SCSI-3) */
69 #elif defined(_BIT_FIELDS_HTOL)
70 		uchar_t	lun	:3,	/* lun (byte 1) (reserved in SCSI-3) */
71 			tag	:5;	/* rest of byte 1 */
72 #else
73 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
74 #endif	/* _BIT_FIELDS_LTOH */
75 		union {
76 
77 		uchar_t	scsi[SCSI_CDB_SIZE-2];
78 		/*
79 		 *	G R O U P   0   F O R M A T (6 bytes)
80 		 */
81 #define		scc_cmd		cdb_un.cmd
82 #define		scc_lun		cdb_un.lun
83 #define		g0_addr2	cdb_un.tag
84 #define		g0_addr1	cdb_un.sg.g0.addr1
85 #define		g0_addr0	cdb_un.sg.g0.addr0
86 #define		g0_count0	cdb_un.sg.g0.count0
87 #define		g0_vu_1		cdb_un.sg.g0.vu_57
88 #define		g0_vu_0		cdb_un.sg.g0.vu_56
89 #define		g0_naca		cdb_un.sg.g0.naca
90 #define		g0_flag		cdb_un.sg.g0.flag
91 #define		g0_link		cdb_un.sg.g0.link
92 	/*
93 	 * defines for SCSI tape cdb.
94 	 */
95 #define		t_code		cdb_un.tag
96 #define		high_count	cdb_un.sg.g0.addr1
97 #define		mid_count	cdb_un.sg.g0.addr0
98 #define		low_count	cdb_un.sg.g0.count0
99 		struct scsi_g0 {
100 			uchar_t addr1;	/* middle part of address */
101 			uchar_t addr0;	/* low part of address */
102 			uchar_t count0;	/* usually block count */
103 #if defined(_BIT_FIELDS_LTOH)
104 			uchar_t link	:1; /* another command follows 	*/
105 			uchar_t flag	:1; /* interrupt when done 	*/
106 			uchar_t naca	:1; /* normal ACA  		*/
107 			uchar_t rsvd	:3; /* reserved 		*/
108 			uchar_t vu_56	:1; /* vendor unique (byte 5 bit6) */
109 			uchar_t vu_57	:1; /* vendor unique (byte 5 bit7) */
110 #elif defined(_BIT_FIELDS_HTOL)
111 			uchar_t vu_57	:1; /* vendor unique (byte 5 bit 7) */
112 			uchar_t vu_56	:1; /* vendor unique (byte 5 bit 6) */
113 			uchar_t rsvd	:3; /* reserved */
114 			uchar_t naca	:1; /* normal ACA  		*/
115 			uchar_t flag	:1; /* interrupt when done */
116 			uchar_t link	:1; /* another command follows */
117 #else
118 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
119 #endif	/* _BIT_FIELDS_LTOH */
120 		} g0;
121 
122 
123 		/*
124 		 *	G R O U P   1, 2   F O R M A T  (10 byte)
125 		 */
126 #define		g1_reladdr	cdb_un.tag
127 #define		g1_rsvd0	cdb_un.sg.g1.rsvd1
128 #define		g1_addr3	cdb_un.sg.g1.addr3	/* msb */
129 #define		g1_addr2	cdb_un.sg.g1.addr2
130 #define		g1_addr1	cdb_un.sg.g1.addr1
131 #define		g1_addr0	cdb_un.sg.g1.addr0	/* lsb */
132 #define		g1_count1	cdb_un.sg.g1.count1	/* msb */
133 #define		g1_count0	cdb_un.sg.g1.count0	/* lsb */
134 #define		g1_vu_1		cdb_un.sg.g1.vu_97
135 #define		g1_vu_0		cdb_un.sg.g1.vu_96
136 #define		g1_naca		cdb_un.sg.g1.naca
137 #define		g1_flag		cdb_un.sg.g1.flag
138 #define		g1_link		cdb_un.sg.g1.link
139 		struct scsi_g1 {
140 			uchar_t addr3;	/* most sig. byte of address */
141 			uchar_t addr2;
142 			uchar_t addr1;
143 			uchar_t addr0;
144 			uchar_t rsvd1;	/* reserved (byte 6) */
145 			uchar_t count1;	/* transfer length (msb) */
146 			uchar_t count0;	/* transfer length (lsb) */
147 #if defined(_BIT_FIELDS_LTOH)
148 			uchar_t link	:1; /* another command follows 	*/
149 			uchar_t flag	:1; /* interrupt when done 	*/
150 			uchar_t naca	:1; /* normal ACA		*/
151 			uchar_t rsvd0	:3; /* reserved 		*/
152 			uchar_t vu_96	:1; /* vendor unique (byte 9 bit6) */
153 			uchar_t vu_97	:1; /* vendor unique (byte 9 bit7) */
154 #elif defined(_BIT_FIELDS_HTOL)
155 			uchar_t vu_97	:1; /* vendor unique (byte 9 bit 7) */
156 			uchar_t vu_96	:1; /* vendor unique (byte 9 bit 6) */
157 			uchar_t rsvd0	:3; /* reserved */
158 			uchar_t naca	:1; /* normal ACA		*/
159 			uchar_t flag	:1; /* interrupt when done */
160 			uchar_t link	:1; /* another command follows */
161 #else
162 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
163 #endif	/* _BIT_FIELDS_LTOH */
164 		} g1;
165 
166 		/*
167 		 *	G R O U P   4   F O R M A T  (16 byte)
168 		 */
169 #define		g4_reladdr		cdb_un.tag
170 #define		g4_addr3		cdb_un.sg.g4.addr3	/* msb */
171 #define		g4_addr2		cdb_un.sg.g4.addr2
172 #define		g4_addr1		cdb_un.sg.g4.addr1
173 #define		g4_addr0		cdb_un.sg.g4.addr0	/* lsb */
174 #define		g4_addtl_cdb_data3	cdb_un.sg.g4.addtl_cdb_data3
175 #define		g4_addtl_cdb_data2	cdb_un.sg.g4.addtl_cdb_data2
176 #define		g4_addtl_cdb_data1	cdb_un.sg.g4.addtl_cdb_data1
177 #define		g4_addtl_cdb_data0	cdb_un.sg.g4.addtl_cdb_data0
178 #define		g4_count3		cdb_un.sg.g4.count3	/* msb */
179 #define		g4_count2		cdb_un.sg.g4.count2
180 #define		g4_count1		cdb_un.sg.g4.count1
181 #define		g4_count0		cdb_un.sg.g4.count0	/* lsb */
182 #define		g4_rsvd0		cdb_un.sg.g4.rsvd1
183 #define		g4_vu_1			cdb_un.sg.g4.vu_157
184 #define		g4_vu_0			cdb_un.sg.g4.vu_156
185 #define		g4_naca			cdb_un.sg.g4.naca
186 #define		g4_flag			cdb_un.sg.g4.flag
187 #define		g4_link			cdb_un.sg.g4.link
188 		struct scsi_g4 {
189 			uchar_t addr3;	/* most sig. byte of address */
190 			uchar_t addr2;
191 			uchar_t addr1;
192 			uchar_t addr0;
193 			uchar_t addtl_cdb_data3;
194 			uchar_t addtl_cdb_data2;
195 			uchar_t addtl_cdb_data1;
196 			uchar_t addtl_cdb_data0;
197 			uchar_t count3;	/* transfer length (msb) */
198 			uchar_t count2;
199 			uchar_t count1;
200 			uchar_t count0;	/* transfer length (lsb) */
201 			uchar_t rsvd1;	/* reserved */
202 #if defined(_BIT_FIELDS_LTOH)
203 			uchar_t link	:1; /* another command follows 	*/
204 			uchar_t flag	:1; /* interrupt when done 	*/
205 			uchar_t naca	:1; /* normal ACA		*/
206 			uchar_t rsvd0	:3; /* reserved 		*/
207 			uchar_t vu_156	:1; /* vendor unique (byte 15 bit6) */
208 			uchar_t vu_157	:1; /* vendor unique (byte 15 bit7) */
209 #elif defined(_BIT_FIELDS_HTOL)
210 			uchar_t vu_157	:1; /* vendor unique (byte 15 bit 7) */
211 			uchar_t vu_156	:1; /* vendor unique (byte 15 bit 6) */
212 			uchar_t rsvd0	:3; /* reserved */
213 			uchar_t naca	:1; /* normal ACA		*/
214 			uchar_t flag	:1; /* interrupt when done */
215 			uchar_t link	:1; /* another command follows */
216 #else
217 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
218 #endif	/* _BIT_FIELDS_LTOH */
219 		} g4;
220 
221 		/*
222 		 *	G R O U P   5   F O R M A T  (12 byte)
223 		 */
224 #define		scc5_reladdr	cdb_un.tag
225 #define		scc5_addr3	cdb_un.sg.g5.addr3	/* msb */
226 #define		scc5_addr2	cdb_un.sg.g5.addr2
227 #define		scc5_addr1	cdb_un.sg.g5.addr1
228 #define		scc5_addr0	cdb_un.sg.g5.addr0	/* lsb */
229 #define		scc5_count3	cdb_un.sg.g5.count3	/* msb */
230 #define		scc5_count2	cdb_un.sg.g5.count2
231 #define		scc5_count1	cdb_un.sg.g5.count1
232 #define		scc5_count0	cdb_un.sg.g5.count0	/* lsb */
233 #define		scc5_rsvd0	cdb_un.sg.g5.rsvd1
234 #define		scc5_vu_1	cdb_un.sg.g5.v117
235 #define		scc5_vu_0	cdb_un.sg.g5.v116
236 #define		scc5_naca	cdb_un.sg.g5.naca
237 #define		scc5_flag	cdb_un.sg.g5.flag
238 #define		scc5_link	cdb_un.sg.g5.link
239 		struct scsi_g5 {
240 			uchar_t addr3;	/* most sig. byte of address */
241 			uchar_t addr2;
242 			uchar_t addr1;
243 			uchar_t addr0;
244 			uchar_t count3;	/* most sig. byte of count */
245 			uchar_t count2;
246 			uchar_t count1;
247 			uchar_t count0;
248 			uchar_t rsvd1;	/* reserved */
249 #if defined(_BIT_FIELDS_LTOH)
250 			uchar_t link	:1; /* another command follows 	*/
251 			uchar_t flag	:1; /* interrupt when done 	*/
252 			uchar_t naca	:1; /* normal ACA		*/
253 			uchar_t rsvd0	:3; /* reserved 		*/
254 			uchar_t vu_116	:1; /* vendor unique (byte 11 bit6) */
255 			uchar_t vu_117	:1; /* vendor unique (byte 11 bit7) */
256 #elif defined(_BIT_FIELDS_HTOL)
257 			uchar_t vu_117	:1; /* vendor unique (byte 11 bit 7) */
258 			uchar_t vu_116	:1; /* vendor unique (byte 11 bit 6) */
259 			uchar_t rsvd0	:3; /* reserved */
260 			uchar_t naca	:1; /* normal ACA		*/
261 			uchar_t flag	:1; /* interrupt when done */
262 			uchar_t link	:1; /* another command follows */
263 #else
264 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
265 #endif	/* _BIT_FIELDS_LTOH */
266 		} g5;
267 		}sg;
268 	} cdb_un;
269 	uchar_t cdb_opaque[SCSI_CDB_SIZE]; /* addressed as opaque char array */
270 	uint_t cdb_long[SCSI_CDB_SIZE / sizeof (uint_t)]; /* as a word array */
271 };
272 
273 
274 /*
275  *	Various useful Macros for SCSI commands
276  */
277 
278 /*
279  * defines for getting/setting fields within the various command groups
280  */
281 
282 #define	GETCMD(cdb)		((cdb)->scc_cmd & 0x1F)
283 #define	GETGROUP(cdb)		(CDB_GROUPID((cdb)->scc_cmd))
284 
285 #define	FORMG0COUNT(cdb, cnt)	(cdb)->g0_count0  = (cnt)
286 
287 #define	FORMG0ADDR(cdb, addr) 	(cdb)->g0_addr2  = (addr) >> 16; \
288 				(cdb)->g0_addr1  = ((addr) >> 8) & 0xFF; \
289 				(cdb)->g0_addr0  = (addr) & 0xFF
290 
291 #define	GETG0ADDR(cdb)		(((cdb)->g0_addr2 & 0x1F) << 16) + \
292 				((cdb)->g0_addr1 << 8) + ((cdb)->g0_addr0)
293 
294 #define	GETG0TAG(cdb)		((cdb)->g0_addr2)
295 
296 #define	FORMG0COUNT_S(cdb, cnt)	(cdb)->high_count  = (cnt) >> 16; \
297 				(cdb)->mid_count = ((cnt) >> 8) & 0xFF; \
298 				(cdb)->low_count = (cnt) & 0xFF
299 
300 #define	FORMG1COUNT(cdb, cnt)	(cdb)->g1_count1 = ((cnt) >> 8); \
301 				(cdb)->g1_count0 = (cnt) & 0xFF
302 
303 #define	FORMG1ADDR(cdb, addr)	(cdb)->g1_addr3  = (addr) >> 24; \
304 				(cdb)->g1_addr2  = ((addr) >> 16) & 0xFF; \
305 				(cdb)->g1_addr1  = ((addr) >> 8) & 0xFF; \
306 				(cdb)->g1_addr0  = (addr) & 0xFF
307 
308 #define	GETG1ADDR(cdb)		((cdb)->g1_addr3 << 24) + \
309 				((cdb)->g1_addr2 << 16) + \
310 				((cdb)->g1_addr1 << 8)  + \
311 				((cdb)->g1_addr0)
312 
313 #define	GETG1TAG(cdb)		(cdb)->g1_reladdr
314 
315 #define	FORMG4COUNT(cdb, cnt)	(cdb)->g4_count3 = ((cnt) >> 24); \
316 				(cdb)->g4_count2 = ((cnt) >> 16) & 0xFF; \
317 				(cdb)->g4_count1 = ((cnt) >> 8) & 0xFF; \
318 				(cdb)->g4_count0 = (cnt) & 0xFF
319 
320 #define	FORMG4LONGADDR(cdb, addr)	(cdb)->g4_addr3 = (addr) >> 56; \
321 					(cdb)->g4_addr2 = \
322 						((addr) >> 48) & 0xFF; \
323 					(cdb)->g4_addr1 = \
324 						((addr) >> 40) & 0xFF; \
325 					(cdb)->g4_addr0 = \
326 						((addr) >> 32) & 0xFF; \
327 					(cdb)->g4_addtl_cdb_data3 = \
328 						((addr) >> 24) & 0xFF; \
329 					(cdb)->g4_addtl_cdb_data2 = \
330 						((addr) >> 16) & 0xFF; \
331 					(cdb)->g4_addtl_cdb_data1 = \
332 						((addr) >> 8) & 0xFF; \
333 					(cdb)->g4_addtl_cdb_data0 = \
334 						(addr) & 0xFF
335 
336 #define	FORMG4ADDR(cdb, addr)	(cdb)->g4_addr3 = (addr) >> 24; \
337 				(cdb)->g4_addr2 = ((addr) >> 16) & 0xFF; \
338 				(cdb)->g4_addr1 = ((addr) >> 8) & 0xFF; \
339 				(cdb)->g4_addr0 = (addr) & 0xFF
340 
341 #define	FORMG4ADDTL(cdb, addtl_cdb_data) (cdb)->g4_addtl_cdb_data3 = \
342 					(addtl_cdb_data) >> 24; \
343 				(cdb)->g4_addtl_cdb_data2 = \
344 					((addtl_cdb_data) >> 16) & 0xFF; \
345 				(cdb)->g4_addtl_cdb_data1 = \
346 					((addtl_cdb_data) >> 8) & 0xFF; \
347 				(cdb)->g4_addtl_cdb_data0 = \
348 					(addtl_cdb_data) & 0xFF
349 
350 #define	GETG4ADDR(cdb)		((cdb)->g4_addr3 << 24) + \
351 				((cdb)->g4_addr2 << 16) + \
352 				((cdb)->g4_addr1 << 8)  + \
353 				((cdb)->g4_addr0)
354 
355 #define	GETG4ADDRTL(cdb)	(((cdb)->g4_addtl_cdb_data3 << 24) + \
356 				((cdb)->g4_addtl_cdb_data2 << 16) + \
357 				((cdb)->g4_addtl_cdb_data1 << 8) + \
358 				(cdb)->g4_addtl_cdb_data0)
359 
360 #define	GETG4TAG(cdb)		(cdb)->g4_reladdr
361 
362 #define	FORMG5COUNT(cdb, cnt)	(cdb)->scc5_count3 = ((cnt) >> 24); \
363 				(cdb)->scc5_count2 = ((cnt) >> 16) & 0xFF; \
364 				(cdb)->scc5_count1 = ((cnt) >> 8) & 0xFF; \
365 				(cdb)->scc5_count0 = (cnt) & 0xFF
366 
367 #define	FORMG5ADDR(cdb, addr)	(cdb)->scc5_addr3  = (addr) >> 24; \
368 				(cdb)->scc5_addr2  = ((addr) >> 16) & 0xFF; \
369 				(cdb)->scc5_addr1  = ((addr) >> 8) & 0xFF; \
370 				(cdb)->scc5_addr0  = (addr) & 0xFF
371 
372 #define	GETG5ADDR(cdb)		((cdb)->scc5_addr3 << 24) + \
373 				((cdb)->scc5_addr2 << 16) + \
374 				((cdb)->scc5_addr1 << 8)  + \
375 				((cdb)->scc5_addr0)
376 
377 #define	GETG5TAG(cdb)		(cdb)->scc5_reladdr
378 
379 
380 /*
381  * Shorthand macros for forming commands
382  *
383  * Works only with pre-SCSI-3 because they put lun as part of CDB.
384  * scsi_setup_cdb() is the recommended interface.
385  */
386 
387 #define	MAKECOM_COMMON(pktp, devp, flag, cmd)	\
388 	(pktp)->pkt_address = (devp)->sd_address, \
389 	(pktp)->pkt_flags = (flag), \
390 	((union scsi_cdb *)(pktp)->pkt_cdbp)->scc_cmd = (cmd), \
391 	((union scsi_cdb *)(pktp)->pkt_cdbp)->scc_lun = \
392 	    (pktp)->pkt_address.a_lun
393 
394 #define	MAKECOM_G0(pktp, devp, flag, cmd, addr, cnt)	\
395 	MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \
396 	FORMG0ADDR(((union scsi_cdb *)(pktp)->pkt_cdbp), (addr)), \
397 	FORMG0COUNT(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt))
398 
399 #define	MAKECOM_G0_S(pktp, devp, flag, cmd, cnt, fixbit)	\
400 	MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \
401 	FORMG0COUNT_S(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt)), \
402 	((union scsi_cdb *)(pktp)->pkt_cdbp)->t_code = (fixbit)
403 
404 #define	MAKECOM_G1(pktp, devp, flag, cmd, addr, cnt)	\
405 	MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \
406 	FORMG1ADDR(((union scsi_cdb *)(pktp)->pkt_cdbp), (addr)), \
407 	FORMG1COUNT(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt))
408 
409 #define	MAKECOM_G5(pktp, devp, flag, cmd, addr, cnt)	\
410 	MAKECOM_COMMON((pktp), (devp), (flag), (cmd)), \
411 	FORMG5ADDR(((union scsi_cdb *)(pktp)->pkt_cdbp), (addr)), \
412 	FORMG5COUNT(((union scsi_cdb *)(pktp)->pkt_cdbp), (cnt))
413 
414 
415 /*
416  * Direct access disk format defines and parameters.
417  *
418  * This is still pretty ugly and is mostly derived
419  * from Emulex MD21 specific formatting.
420  */
421 
422 #define	fmt_parm_bits		g0_addr2	/* for format options */
423 #define	fmt_interleave		g0_count0	/* for encode interleave */
424 #define	defect_list_descrip	g1_addr3	/* list description bits */
425 
426 /*
427  * defines for value of fmt_parm_bits.
428  */
429 
430 #define	FPB_BFI			0x04	/* bytes-from-index fmt */
431 #define	FPB_CMPLT		0x08	/* full defect list provided */
432 #define	FPB_DATA		0x10	/* defect list data provided */
433 
434 /*
435  * Defines for value of defect_list_descrip.
436  */
437 
438 #define	DLD_MAN_DEF_LIST	0x10	/* manufacturer's defect list */
439 #define	DLD_GROWN_DEF_LIST	0x08	/* grown defect list */
440 #define	DLD_BLOCK_FORMAT	0x00	/* block format */
441 #define	DLD_BFI_FORMAT		0x04	/* bytes-from-index format */
442 #define	DLD_PS_FORMAT		0x05	/* physical sector format */
443 
444 
445 /*
446  * Disk defect list - used by format command.
447  */
448 #define	RDEF_ALL	0	/* read all defects */
449 #define	RDEF_MANUF	1	/* read manufacturer's defects */
450 #define	RDEF_CKLEN	2	/* check length of manufacturer's list */
451 #define	ST506_NDEFECT	127	/* must fit in 1K controller buffer... */
452 #define	ESDI_NDEFECT	ST506_NDEFECT
453 
454 struct scsi_bfi_defect {	/* defect in bytes from index format */
455 	unsigned cyl  : 24;
456 	unsigned head : 8;
457 	int	bytes_from_index;
458 };
459 
460 struct scsi_format_params {	/* BFI format list */
461 	ushort_t reserved;
462 	ushort_t length;
463 	struct  scsi_bfi_defect list[ESDI_NDEFECT];
464 };
465 
466 /*
467  * Defect list returned by READ_DEFECT_LIST command.
468  */
469 struct scsi_defect_hdr {	/* For getting defect list size */
470 	uchar_t	reserved;
471 	uchar_t	descriptor;
472 	ushort_t length;
473 };
474 
475 struct scsi_defect_list {	/* BFI format list */
476 	uchar_t	reserved;
477 	uchar_t	descriptor;
478 	ushort_t length;
479 	struct	scsi_bfi_defect list[ESDI_NDEFECT];
480 };
481 
482 /*
483  *
484  * Direct Access device Reassign Block parameter
485  *
486  * Defect list format used by reassign block command (logical block format).
487  *
488  * This defect list is limited to 1 defect, as that is the only way we use it.
489  *
490  */
491 
492 struct scsi_reassign_blk {
493 	ushort_t reserved;
494 	ushort_t length;	/* defect length in bytes (defects * 4) */
495 	uint_t 	defect;		/* Logical block address of defect */
496 };
497 
498 /*
499  * Direct Access Device Capacity Structure -- 8 byte version
500  */
501 
502 struct scsi_capacity {
503 	uint_t	capacity;
504 	uint_t	lbasize;
505 };
506 
507 /*
508  * Direct Access Device Capacity Structure -- 16 byte version
509  */
510 
511 struct scsi_capacity_16 {
512 	uint64_t	sc_capacity;
513 	uint_t		sc_lbasize;
514 #if defined(_BIT_FIELDS_LTOH)
515 	uchar_t 	sc_rto_en	:1;
516 	uchar_t 	sc_prot_en	:1;
517 	uchar_t 	sc_rsvd0	:6;
518 #elif defined(_BIT_FIELDS_HTOL)
519 	uchar_t 	sc_rsvd0	:6;
520 	uchar_t 	sc_prot_en	:1;
521 	uchar_t 	sc_rto_en	:1;
522 #else
523 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
524 #endif	/* _BIT_FIELDS_LTOH */
525 	uchar_t 	sc_rsvd1[19];
526 };
527 
528 #ifdef	_KERNEL
529 
530 /*
531  * Functional versions of the above macros, and other functions.
532  * the makecom functions have been deprecated. Please use
533  * scsi_setup_cdb()
534  */
535 
536 #ifdef  __STDC__
537 extern void 	makecom_g0(struct scsi_pkt *pkt, struct scsi_device *devp,
538 				int flag, int cmd, int addr, int cnt);
539 extern void 	makecom_g0_s(struct scsi_pkt *pkt, struct scsi_device *devp,
540 				int flag, int cmd, int cnt, int fixbit);
541 extern void 	makecom_g1(struct scsi_pkt *pkt, struct scsi_device *devp,
542 				int flag, int cmd, int addr, int cnt);
543 extern void 	makecom_g5(struct scsi_pkt *pkt, struct scsi_device *devp,
544 				int flag, int cmd, int addr, int cnt);
545 extern int	scsi_setup_cdb(union scsi_cdb *cdbp, uchar_t cmd, uint_t addr,
546 				uint_t cnt, uint_t addtl_cdb_data);
547 
548 #else   /* __STDC__ */
549 
550 extern void 	makecom_g0();
551 extern void 	makecom_g0_s();
552 extern void 	makecom_g1();
553 extern void 	makecom_g5();
554 extern int	scsi_setup_cdb();
555 
556 #endif  /* __STDC__ */
557 
558 #endif /* _KERNEL */
559 
560 #ifdef	__cplusplus
561 }
562 #endif
563 
564 #endif	/* _SYS_SCSI_IMPL_COMMANDS_H */
565