xref: /titanic_44/usr/src/uts/common/sys/scsi/impl/mode.h (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
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 (c) 1996-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_SCSI_IMPL_MODE_H
28 #define	_SYS_SCSI_IMPL_MODE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Defines and Structures for SCSI Mode Sense/Select data
38  *
39  * Implementation Specific variations
40  */
41 
42 /*
43  * Variations to Sequential Access device mode header
44  */
45 struct 	modeheader_seq {
46 	uchar_t	datalen;	/* sense data length */
47 	uchar_t	mediumtype;	/* medium type */
48 #if defined(_BIT_FIELDS_LTOH)
49 	uchar_t	speed	:4,	/* speed */
50 		bufm	:3,	/* buffered mode */
51 		wp	:1;	/* write protected */
52 #elif defined(_BIT_FIELDS_HTOL)
53 	uchar_t	wp	:1,	/* write protected */
54 		bufm	:3,	/* buffered mode */
55 		speed	:4;	/* speed */
56 #else
57 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
58 #endif	/* _BIT_FIELDS_LTOH */
59 	uchar_t	bd_len;		/* block length in bytes */
60 	struct  block_descriptor blk_desc;
61 };
62 
63 /*
64  * Variations to Direct Access device pages
65  */
66 
67 /*
68  * Page 1: CCS error recovery page was a little different than SCSI-2/3
69  */
70 
71 #define	PAGELENGTH_DAD_MODE_ERR_RECOV_CCS	0x06
72 
73 struct mode_err_recov_ccs {
74 	struct	mode_page mode_page;	/* common mode page header */
75 #if defined(_BIT_FIELDS_LTOH)
76 	uchar_t		dcr	: 1,	/* disable correction */
77 			dte	: 1,	/* disable transfer on error */
78 			per	: 1,	/* post error */
79 			eec	: 1,	/* enable early correction */
80 			rc	: 1,	/* read continuous */
81 			tb	: 1,	/* transfer block */
82 			arre	: 1,	/* auto read realloc enabled */
83 			awre	: 1;	/* auto write realloc enabled */
84 #elif defined(_BIT_FIELDS_HTOL)
85 	uchar_t		awre	: 1,	/* auto write realloc enabled */
86 			arre	: 1,	/* auto read realloc enabled */
87 			tb	: 1,	/* transfer block */
88 			rc	: 1,	/* read continuous */
89 			eec	: 1,	/* enable early correction */
90 			per	: 1,	/* post error */
91 			dte	: 1,	/* disable transfer on error */
92 			dcr	: 1;	/* disable correction */
93 #else
94 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
95 #endif	/* _BIT_FIELDS_LTOH */
96 	uchar_t	retry_count;
97 	uchar_t	correction_span;
98 	uchar_t	head_offset_count;
99 	uchar_t	strobe_offset_count;
100 	uchar_t	recovery_time_limit;
101 };
102 
103 /*
104  * Page 3: CCS Direct Access Device Format Parameters
105  *
106  * The 0x8 bit in the Drive Type byte is used in CCS
107  * as an INHIBIT SAVE bit. This bit is not in SCSI-2/3.
108  */
109 
110 #define	_reserved_ins	ins
111 
112 /*
113  * Page 8: SCSI-2 Cache page was a little different than SCSI-3
114  */
115 
116 #define	PAGELENGTH_DAD_MODE_CACHE	0x0A
117 
118 struct mode_cache {
119 	struct	mode_page mode_page;	/* common mode page header */
120 #if defined(_BIT_FIELDS_LTOH)
121 	uchar_t		rcd	: 1,	/* Read Cache Disable */
122 			mf	: 1,	/* Multiplication Factor */
123 			wce	: 1,	/* Write Cache Enable */
124 				: 5;
125 	uchar_t	write_reten_pri	: 4,	/* Write Retention Priority */
126 		read_reten_pri	: 4;	/* Demand Read Retention Priority */
127 #elif defined(_BIT_FIELDS_HTOL)
128 	uchar_t			: 5,
129 			wce	: 1,	/* Write Cache Enable */
130 			mf	: 1,	/* Multiplication Factor */
131 			rcd	: 1;	/* Read Cache Disable */
132 	uchar_t	read_reten_pri	: 4,	/* Demand Read Retention Priority */
133 		write_reten_pri	: 4;	/* Write Retention Priority */
134 #else
135 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
136 #endif	/* _BIT_FIELDS_LTOH */
137 	ushort_t dis_prefetch_len;	/* Disable prefetch xfer length */
138 	ushort_t min_prefetch;		/* minimum prefetch length */
139 	ushort_t max_prefetch;		/* maximum prefetch length */
140 	ushort_t prefetch_ceiling;	/* max prefetch ceiling */
141 };
142 
143 /*
144  * Page 0x38 - This is the CCS Cache Page
145  */
146 
147 struct mode_cache_ccs {
148 	struct	mode_page mode_page;	/* common mode page header */
149 	uchar_t	mode;			/* Cache control and size */
150 	uchar_t	threshold;		/* Prefetch threshold */
151 	uchar_t	max_prefetch;		/* Max. prefetch */
152 	uchar_t	max_multiplier;		/* Max. prefetch multiplier */
153 	uchar_t	min_prefetch;		/* Min. prefetch */
154 	uchar_t	min_multiplier;		/* Min. prefetch multiplier */
155 	uchar_t	rsvd2[8];
156 };
157 
158 /*
159  * Page A: SCSI-2 control page was a little different than SCSI-3
160  */
161 
162 #define	PAGELENGTH_MODE_CONTROL		0x06
163 
164 struct mode_control {
165 	struct	mode_page mode_page;	/* common mode page header */
166 #if defined(_BIT_FIELDS_LTOH)
167 	uchar_t		rlec	: 1,	/* Report Log Exception bit */
168 				: 7;
169 	uchar_t		qdisable: 1,	/* Queue disable */
170 			que_err	: 1,	/* Queue error */
171 				: 2,
172 			que_mod : 4;    /* Queue algorithm modifier */
173 	uchar_t		eanp	: 1,
174 			uaaenp  : 1,
175 			raenp   : 1,
176 				: 4,
177 			eeca	: 1;
178 #elif defined(_BIT_FIELDS_HTOL)
179 	uchar_t			: 7,
180 			rlec	: 1;	/* Report Log Exception bit */
181 	uchar_t		que_mod	: 4,	/* Queue algorithm modifier */
182 				: 2,
183 			que_err	: 1,	/* Queue error */
184 			qdisable: 1;	/* Queue disable */
185 	uchar_t		eeca	: 1,
186 				: 4,
187 			raenp	: 1,
188 			uaaenp	: 1,
189 			eanp	: 1;
190 #else
191 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
192 #endif	/* _BIT_FIELDS_LTOH */
193 	uchar_t	reserved;
194 	ushort_t ready_aen_holdoff;
195 };
196 
197 
198 /*
199  * Emulex MD21 Unique Mode Select/Sense structure.
200  * This is apparently not used, although the MD21
201  * documentation refers to it.
202  *
203  * The medium_type in the mode header must be 0x80
204  * to indicate a vendor unique format. There is then
205  * a standard block descriptor page, which must be
206  * zeros (although the block descriptor length is set
207  * appropriately in the mode header).
208  *
209  * After this stuff, comes the vendor unique ESDI
210  * format parameters for the MD21.
211  *
212  * Notes:
213  *
214  *	1) The logical number of sectors/track should be the
215  *	number of physical sectors/track less the number spare
216  *	sectors/track.
217  *
218  *	2) The logical number of cylinders should be the
219  *	number of physical cylinders less three (3) reserved
220  *	for use by the drive, and less any alternate cylinders
221  *	allocated.
222  *
223  *	3) head skew- see MD21 manual.
224  */
225 
226 struct emulex_format_params {
227 	uchar_t	alt_cyl;	/* number of alternate cylinders */
228 #if defined(_BIT_FIELDS_LTOH)
229 	uchar_t		: 1,
230 		sst	: 2,	/* spare sectors per track */
231 		ssz	: 1,	/* sector size. 1 == 256 bps, 0 == 512 bps */
232 		nheads	: 4;	/* number of heads */
233 #elif defined(_BIT_FIELDS_HTOL)
234 	uchar_t	nheads	: 4,	/* number of heads */
235 		ssz	: 1,	/* sector size. 1 == 256 bps, 0 == 512 bps */
236 		sst	: 2,	/* spare sectors per track */
237 			: 1;
238 #else
239 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
240 #endif	/* _BIT_FIELDS_LTOH */
241 	uchar_t	nsect;		/* logical sectors/track */
242 	uchar_t	ncyl_hi;	/* logical number of cylinders, msb */
243 	uchar_t	ncyl_lo;	/* logical number of cylinders, lsb */
244 	uchar_t	head_skew;	/* head skew */
245 	uchar_t	reserved[3];
246 };
247 
248 /*
249  * Page 0x31: CD-ROM speed page
250  */
251 
252 #define	CDROM_MODE_SPEED	0x31
253 
254 struct mode_speed {
255 	struct	mode_page mode_page;	/* common mode page header */
256 	uchar_t	speed;			/* drive speed */
257 	uchar_t	reserved;
258 };
259 
260 /*
261  * Definitions for drive speed supported are in cdio.h
262  */
263 
264 #ifdef	__cplusplus
265 }
266 #endif
267 
268 #endif	/* _SYS_SCSI_IMPL_MODE_H */
269