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