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