xref: /titanic_44/usr/src/lib/libbc/inc/include/sun/dkio.h (revision 0cd13cbfb4270b840b4bd22ec5f673b2b6a2c02b)
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 _sun_dkio_h
28 #define	_sun_dkio_h
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /* #include <sys/ioctl.h> not needed? */
33 #include <sun/dklabel.h>
34 
35 /*
36  * Structures and definitions for disk io control commands
37  */
38 
39 /*
40  * Structures used as data by ioctl calls.
41  */
42 
43 /*
44  * Used for controller info
45  */
46 struct dk_info {
47 	int	dki_ctlr;		/* controller address */
48 	short	dki_unit;		/* unit (slave) address */
49 	short	dki_ctype;		/* controller type */
50 	short	dki_flags;		/* flags */
51 };
52 
53 #define	DK_DEVLEN	16		/* device name max length, including */
54 					/* unit # & NULL (ie - "xyc1") */
55 /*
56  * Used for configuration info
57  */
58 struct dk_conf {
59 	char	dkc_cname[DK_DEVLEN];	/* controller name (no unit #) */
60 	u_short	dkc_ctype;		/* controller type */
61 	u_short	dkc_flags;		/* flags */
62 	short	dkc_cnum;		/* controller number */
63 	int	dkc_addr;		/* controller address */
64 	u_int	dkc_space;		/* controller bus type */
65 	int	dkc_prio;		/* interrupt priority */
66 	int	dkc_vec;		/* interrupt vector */
67 	char	dkc_dname[DK_DEVLEN];	/* drive name (no unit #) */
68 	short	dkc_unit;		/* unit number */
69 	short	dkc_slave;		/* slave number */
70 };
71 
72 /*
73  * Controller types
74  */
75 #define	DKC_UNKNOWN	0
76 /* 1 used to be Interphase 2180 */
77 #define	DKC_WDC2880	2
78 /* 3 used to be Interphase 2181 */
79 /* 4 used to be Xylogics 440 */
80 #define	DKC_DSD5215	5
81 #define	DKC_XY450	6
82 #define	DKC_ACB4000	7
83 #define	DKC_MD21	8
84 /* 9 used to be Xylogics 751 */
85 #define	DKC_NCRFLOPPY	10
86 /* #define	DKC_XB1401	10 does not match dkinfo.c*/
87 #define	DKC_XD7053	11
88 #define	DKC_SMSFLOPPY	12
89 #define	DKC_SCSI_CCS	13
90 #define	DKC_INTEL82072	14	/* floppy ctlr on campus and hydra */
91 #define	DKC_PANTHER	15
92 #define DKC_SUN_IPI1	DKC_PANTHER	/* Sun Panther VME/IPI controller */
93 #define	DKC_MD		16	/* meta-disk (virtual-disk) driver */
94 #define DKC_CDC_9057	17	/* CDC 9057-321 (CM-3) IPI String Controller */
95 #define DKC_FJ_M1060	18	/* Fujitsu/Intellistor M1060 IPI-3 SC */
96 
97 /*
98  * Flags
99  */
100 #define	DKI_BAD144	0x01	/* use DEC std 144 bad sector fwding */
101 #define	DKI_MAPTRK	0x02	/* controller does track mapping */
102 #define	DKI_FMTTRK	0x04	/* formats only full track at a time */
103 #define	DKI_FMTVOL	0x08	/* formats only full volume at a time */
104 #define	DKI_FMTCYL	0x10	/* formats only full cylinders at a time */
105 #define DKI_HEXUNIT	0x20	/* unit number is printed as 3 hex digits */
106 
107 /*
108  * Used for drive info
109  */
110 struct dk_type {
111 	u_short dkt_hsect;		/* hard sector count (read only) */
112 	u_short dkt_promrev;		/* prom revision (read only) */
113 	u_char	dkt_drtype;		/* drive type (ctlr specific) */
114 	u_char	dkt_drstat;		/* drive status (ctlr specific, ro) */
115 };
116 
117 /*
118  * Used for all partitions
119  */
120 struct dk_allmap {
121 	struct dk_map	dka_map[NDKMAP];
122 };
123 
124 /*
125  * Used for bad sector map
126  */
127 struct dk_badmap {
128 	caddr_t dkb_bufaddr;		/* address of user's map buffer */
129 };
130 
131 /*
132  * Definition of a disk's geometry
133  */
134 struct dk_geom {
135 	unsigned short	dkg_ncyl;	/* # of data cylinders */
136 	unsigned short	dkg_acyl;	/* # of alternate cylinders */
137 	unsigned short	dkg_bcyl;	/* cyl offset (for fixed head area) */
138 	unsigned short	dkg_nhead;	/* # of heads */
139 	unsigned short	dkg_obs1;	/* obsolete */
140 	unsigned short	dkg_nsect;	/* # of data sectors per track */
141 	unsigned short	dkg_intrlv;	/* interleave factor */
142 	unsigned short	dkg_obs2;	/* obsolete */
143 	unsigned short	dkg_obs3;	/* obsolete */
144 	unsigned short	dkg_apc;	/* alternates per cyl (SCSI only) */
145 	unsigned short	dkg_rpm;	/* revolutions per minute */
146 	unsigned short	dkg_pcyl;	/* # of physical cylinders */
147 	unsigned short	dkg_extra[7];	/* for compatible expansion */
148 };
149 /*
150  * These defines are for historic compatibility with old drivers.
151  */
152 #define	dkg_bhead	dkg_obs1	/* used to be head offset */
153 #define	dkg_gap1	dkg_obs2	/* used to be gap1 */
154 #define	dkg_gap2	dkg_obs3	/* used to be gap2 */
155 
156 /*
157  * Used for generic commands
158  */
159 struct dk_cmd {
160 	u_short	dkc_cmd;		/* command to be executed */
161 	int	dkc_flags;		/* execution flags */
162 	daddr_t	dkc_blkno;		/* disk address for command */
163 	int	dkc_secnt;		/* sector count for command */
164 	caddr_t	dkc_bufaddr;		/* user's buffer address */
165 	u_int	dkc_buflen;		/* size of user's buffer */
166 };
167 
168 /*
169  * Execution flags.
170  */
171 #define	DK_SILENT	0x01		/* no error messages */
172 #define	DK_DIAGNOSE	0x02		/* fail if any error occurs */
173 #define	DK_ISOLATE	0x04		/* isolate from normal commands */
174 #define	DK_READ		0x08		/* read from device */
175 #define	DK_WRITE	0x10		/* write to device */
176 
177 /*
178  * Used for disk diagnostics
179  */
180 struct dk_diag {
181 	u_short	dkd_errcmd;		/* most recent command in error */
182 	daddr_t	dkd_errsect;		/* most recent sector in error */
183 	u_char	dkd_errno;		/* most recent error number */
184 	u_char	dkd_severe;		/* severity of most recent error */
185 };
186 
187 /*
188  * Used for getting disk error log.
189  */
190 struct dk_loghdr {
191 	long	dkl_entries;		/* number of dk_log entries */
192 	long	dkl_max_size;		/* max. size of dk_log table */
193 	caddr_t	dkl_logbfr;		/* pointer to dk_log table */
194 };
195 
196 /*
197  * Disk error log table entry.
198  */
199 struct dk_log {
200 	daddr_t	block;			/* location of block in error */
201 	u_long	count;			/* number of failures */
202 	short	type;			/* type of error (e.g. soft error) */
203 	short	err1;			/* primary error code (e.g sense key) */
204 	short	err2;			/* secondary error code */
205 };
206 
207 /*
208  * Dk_log type flags.
209  *
210  * FIXME:  Really should specify dkd_errno error codes.
211  *	For some reason they're specified in the drivers
212  *	instead of here??  Should also use those here for
213  *	dk_log.type too.
214  */
215 #define	DKL_SOFT	0x01		/* recoverable erro */
216 #define	DKL_HARD	0x02		/* unrecoverable error */
217 
218 /*
219  * Used for floppies
220  */
221 struct fdk_char{
222 	u_char medium;		/* medium type. Unused, why have it? history! */
223 	int transfer_rate;	/* transfer rate */
224 	int ncyl;		/* number of cylinders */
225 	int nhead;		/* number of heads */
226 	int sec_size;		/* sector size */
227 	int secptrack;		/* sectors per track */
228 	int steps;		/* number of steps per  */
229 };
230 
231 struct fdk_state {
232 	int	fkc_bsec;		/* bytes per sector */
233 	int 	fkc_strack;		/* sectors per track */
234 	int	fkc_step;		/* step rate */
235 	int	fkc_rate;		/* data rate */
236 	int	fkc_error;		/* error returned by controller */
237 };
238 
239 struct fdk_cmd {		/* used by generic command */
240 	struct dk_cmd dcmd;	/* disk command info */
241 	struct fdk_state fstate; /* floppy state info */
242 };
243 
244 /*
245  * Floppy commands
246  */
247 #define	FKWRITE 	1
248 #define	FKREAD  	2
249 #define	FKSEEK		3
250 #define	FKREZERO 	4
251 #define	FKFORMAT_UNIT 	5
252 #define	FKFORMAT_TRACK 	6
253 
254 /*
255  * Used by FDKGETCHANGE, return state of the sense disk change bit.
256  */
257 #define	FDKGC_HISTORY	0x01	/* disk has changed since last call */
258 #define	FDKGC_CURRENT	0x02	/* current state of disk change */
259 
260 /*
261  * Used by FDK{G, S}ETDRIVECHAR
262  */
263 struct fdk_drive {
264 	int fdd_ejectable;	/* does the drive support eject? */
265 	int fdd_maxsearch;	/* size of per-unit search table */
266 
267 	int fdd_writeprecomp;	/* cyl to start write prcompensation */
268 	int fdd_writereduce;	/* cyl to start recucing write current */
269 	int fdd_stepwidth;	/* width of step pulse in 1 us units */
270 	int fdd_steprate;	/* step rate in 100 us units */
271 	int fdd_headsettle;	/* delay, in 100 us units */
272 	int fdd_headload;	/* delay, in 100 us units */
273 	int fdd_headunload;	/* delay, in 100 us units */
274 	int fdd_motoron;	/* delay, in 100 ms units */
275 	int fdd_motoroff;	/* delay, in 100 ms units */
276 	int fdd_precomplevel;	/* bit shift, in nano-secs */
277 	int fdd_pins;		/* defines meaning of pin 1, 2, 4, and 34 */
278 	int fdd_flags;		/* TRUE READY, Starting Sector #, & Motor On */
279 };
280 
281 /*
282  * Used by FDK{G, S}ETSEARCH
283  */
284 struct fdk_search {
285 	int	fdk_numentries; /* number of elements in the table */
286 	struct fdk_char *fdk_search;
287 };
288 
289 /*
290  * Used by F_RAW
291  */
292 struct fdraw {
293 	char	fr_cmd[10];	/* user-supplied command bytes */
294 	short   fr_cnum;	/* number of command bytes */
295 	char    fr_result[10];  /* controller-supplied result bytes */
296 	short	fr_nbytes;	/* number to transfer if read/write command */
297 	char	*fr_addr;	/* where to transfer if read/write command */
298 };
299 
300 /*
301  * Floppy raw commands
302  */
303 #define	FRAW_SPECIFY	0x03
304 #define	FRAW_READID	0x0a
305 #define	FRAW_SENSE_DRV	0x04
306 #define	FRAW_REZERO	0x07
307 #define	FRAW_SEEK	0x0f
308 #define	FRAW_SENSE_INT	0x08
309 #define	FRAW_FORMAT	0x0d
310 #define	FRAW_READTRACK	0x02
311 #define	FRAW_WRCMD	0x05
312 #define	FRAW_RDCMD	0x06
313 #define	FRAW_WRITEDEL	0x09
314 #define	FRAW_READDEL	0x0c
315 
316 /*
317  * Severity values
318  */
319 #define	DK_NOERROR	0
320 #define	DK_CORRECTED	1
321 #define	DK_RECOVERED	2
322 #define	DK_FATAL	3
323 
324 /*
325  * Error types
326  */
327 #define	DK_NONMEDIA	0		/* not caused by a media defect */
328 #define	DK_ISMEDIA	1		/* caused by a media defect */
329 
330 
331 /*
332  * Disk io control commands
333  */
334 #define	DKIOCGGEOM	_IOR('d', 2, struct dk_geom)	/* Get geometry */
335 #define	DKIOCSGEOM	_IOW('d', 3, struct dk_geom)	/* Set geometry */
336 #define	DKIOCGPART	_IOR('d', 4, struct dk_map)	/* Get partition info */
337 #define	DKIOCSPART	_IOW('d', 5, struct dk_map)	/* Set partition info */
338 #define	DKIOCINFO	_IOR('d', 8, struct dk_info)	/* Get info */
339 #define	DKIOCGCONF	_IOR('d', 126, struct dk_conf)	/* Get conf info */
340 #define	DKIOCSTYPE	_IOW('d', 125, struct dk_type)	/* Set drive info */
341 #define	DKIOCGTYPE	_IOR('d', 124, struct dk_type)	/* Get drive info */
342 #define	DKIOCSAPART	_IOW('d', 123, struct dk_allmap)	/* Set all partitions */
343 #define	DKIOCGAPART	_IOR('d', 122, struct dk_allmap)	/* Get all partitions */
344 #define	DKIOCSBAD	_IOW('d', 121, struct dk_badmap)	/* Set bad sector map */
345 #define	DKIOCGBAD	_IOW('d', 120, struct dk_badmap)	/* Get bad sector map */
346 #define	DKIOCSCMD	_IOW('d', 119, struct dk_cmd)	/* Set generic cmd */
347 #define	DKIOCGLOG	_IOR('d', 118, struct dk_loghdr)	/* Get error log */
348 #define	DKIOCGDIAG	_IOR('d', 116, struct dk_diag)	/* Get diagnostics */
349 #define	DKIOCWCHK	_IOWR('d', 115, int)		/* Toggle write check */
350 #define	FDKIOGCHAR	_IOR('d', 114, struct fdk_char)	/* GetCharacteristics */
351 #define	FDKIOSCHAR	_IOW('d', 113, struct fdk_char)	/* SetCharacteristics */
352 #define	FDKEJECT	_IO('d', 112)			/* Eject floppy disk */
353 #define	FDKGETCHANGE	_IOR('d', 111, int)		/* Get diskchng stat */
354 #define	FDKGETDRIVECHAR	_IOR('d', 110, struct fdk_drive)	/* Get drivechar */
355 #define	FDKSETDRIVECHAR	_IOW('d', 109, struct fdk_drive)	/* Set drivechar */
356 #define	FDKGETSEARCH	_IOR('d', 108, struct fdk_search)	/* Get search tbl */
357 #define	FDKSETSEARCH	_IOW('d', 107, struct fdk_search)	/* Set search tbl */
358 #define	FDKIOCSCMD	_IOWR('d', 106, struct fdk_cmd)	/* Floppy command */
359 #define	F_RAW		_IOWR('d', 105, struct fdraw)	/* ECDstyle genericcmd*/
360 
361 #endif /* !_sun_dkio_h */
362