xref: /titanic_51/usr/src/uts/common/sys/dkio.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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_DKIO_H
28 #define	_SYS_DKIO_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS-4.0 5.19 */
31 
32 #include <sys/dklabel.h>	/* Needed for NDKMAP define */
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Structures and definitions for disk io control commands
40  */
41 
42 /*
43  * Structures used as data by ioctl calls.
44  */
45 
46 #define	DK_DEVLEN	16		/* device name max length, including */
47 					/* unit # & NULL (ie - "xyc1") */
48 
49 /*
50  * Used for controller info
51  */
52 struct dk_cinfo {
53 	char	dki_cname[DK_DEVLEN];	/* controller name (no unit #) */
54 	ushort_t dki_ctype;		/* controller type */
55 	ushort_t dki_flags;		/* flags */
56 	ushort_t dki_cnum;		/* controller number */
57 	uint_t	dki_addr;		/* controller address */
58 	uint_t	dki_space;		/* controller bus type */
59 	uint_t	dki_prio;		/* interrupt priority */
60 	uint_t	dki_vec;		/* interrupt vector */
61 	char	dki_dname[DK_DEVLEN];	/* drive name (no unit #) */
62 	uint_t	dki_unit;		/* unit number */
63 	uint_t	dki_slave;		/* slave number */
64 	ushort_t dki_partition;		/* partition number */
65 	ushort_t dki_maxtransfer;	/* max. transfer size in DEV_BSIZE */
66 };
67 
68 /*
69  * Controller types
70  */
71 #define	DKC_UNKNOWN	0
72 #define	DKC_CDROM	1	/* CD-ROM, SCSI or otherwise */
73 #define	DKC_WDC2880	2
74 #define	DKC_XXX_0	3	/* unassigned */
75 #define	DKC_XXX_1	4	/* unassigned */
76 #define	DKC_DSD5215	5
77 #define	DKC_ACB4000	7
78 #define	DKC_MD21	8
79 #define	DKC_XXX_2	9	/* unassigned */
80 #define	DKC_NCRFLOPPY	10
81 #define	DKC_SMSFLOPPY	12
82 #define	DKC_SCSI_CCS	13	/* SCSI CCS compatible */
83 #define	DKC_INTEL82072	14	/* native floppy chip */
84 #define	DKC_MD		16	/* meta-disk (virtual-disk) driver */
85 #define	DKC_INTEL82077	19	/* 82077 floppy disk controller */
86 #define	DKC_DIRECT	20	/* Intel direct attached device i.e. IDE */
87 #define	DKC_PCMCIA_MEM	21	/* PCMCIA memory disk-like type */
88 #define	DKC_PCMCIA_ATA	22	/* PCMCIA AT Attached type */
89 
90 /*
91  * Sun reserves up through 1023
92  */
93 
94 #define	DKC_CUSTOMER_BASE	1024
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 #define	DKI_PCMCIA_PFD	0x40	/* PCMCIA pseudo-floppy memory card */
106 
107 /*
108  * Used for all partitions
109  */
110 struct dk_allmap {
111 	struct dk_map	dka_map[NDKMAP];
112 };
113 
114 #if defined(_SYSCALL32)
115 struct dk_allmap32 {
116 	struct dk_map32	dka_map[NDKMAP];
117 };
118 #endif /* _SYSCALL32 */
119 
120 /*
121  * Definition of a disk's geometry
122  */
123 struct dk_geom {
124 	unsigned short	dkg_ncyl;	/* # of data cylinders */
125 	unsigned short	dkg_acyl;	/* # of alternate cylinders */
126 	unsigned short	dkg_bcyl;	/* cyl offset (for fixed head area) */
127 	unsigned short	dkg_nhead;	/* # of heads */
128 	unsigned short	dkg_obs1;	/* obsolete */
129 	unsigned short	dkg_nsect;	/* # of data sectors per track */
130 	unsigned short	dkg_intrlv;	/* interleave factor */
131 	unsigned short	dkg_obs2;	/* obsolete */
132 	unsigned short	dkg_obs3;	/* obsolete */
133 	unsigned short	dkg_apc;	/* alternates per cyl (SCSI only) */
134 	unsigned short	dkg_rpm;	/* revolutions per minute */
135 	unsigned short	dkg_pcyl;	/* # of physical cylinders */
136 	unsigned short	dkg_write_reinstruct;	/* # sectors to skip, writes */
137 	unsigned short	dkg_read_reinstruct;	/* # sectors to skip, reads */
138 	unsigned short	dkg_extra[7];	/* for compatible expansion */
139 };
140 
141 /*
142  * These defines are for historic compatibility with old drivers.
143  */
144 #define	dkg_bhead	dkg_obs1	/* used to be head offset */
145 #define	dkg_gap1	dkg_obs2	/* used to be gap1 */
146 #define	dkg_gap2	dkg_obs3	/* used to be gap2 */
147 
148 /*
149  * Disk io control commands
150  * Warning: some other ioctls with the DIOC prefix exist elsewhere.
151  * The Generic DKIOC numbers are from	0   -  50.
152  *	The Floppy Driver uses		51  - 100.
153  *	The Hard Disk (except SCSI)	101 - 106.	(these are obsolete)
154  *	The CDROM Driver		151 - 200.
155  *	The USCSI ioctl			201 - 250.
156  */
157 #define	DKIOC		(0x04 << 8)
158 
159 /*
160  * The following ioctls are generic in nature and need to be
161  * suported as appropriate by all disk drivers
162  */
163 #define	DKIOCGGEOM	(DKIOC|1)		/* Get geometry */
164 #define	DKIOCINFO	(DKIOC|3)		/* Get info */
165 #define	DKIOCEJECT	(DKIOC|6)		/* Generic 'eject' */
166 #define	DKIOCGVTOC	(DKIOC|11)		/* Get VTOC */
167 #define	DKIOCSVTOC	(DKIOC|12)		/* Set VTOC & Write to Disk */
168 
169 /*
170  * The following ioctls are used by Sun drivers to communicate
171  * with their associated format routines. Support of these ioctls
172  * is not required of foreign drivers
173  */
174 #define	DKIOCSGEOM	(DKIOC|2)		/* Set geometry */
175 #define	DKIOCSAPART	(DKIOC|4)		/* Set all partitions */
176 #define	DKIOCGAPART	(DKIOC|5)		/* Get all partitions */
177 #define	DKIOCG_PHYGEOM	(DKIOC|32)		/* get physical geometry */
178 #define	DKIOCG_VIRTGEOM	(DKIOC|33)		/* get virtual geometry */
179 
180 /*
181  * The following ioctl's are removable media support
182  */
183 #define	DKIOCLOCK	(DKIOC|7)	/* Generic 'lock' */
184 #define	DKIOCUNLOCK	(DKIOC|8)	/* Generic 'unlock' */
185 #define	DKIOCSTATE	(DKIOC|13)	/* Inquire insert/eject state */
186 #define	DKIOCREMOVABLE	(DKIOC|16)	/* is media removable */
187 
188 /*
189  * Ioctl to force driver to re-read the alternate partition and rebuild
190  * the internal defect map.
191  */
192 #define	DKIOCADDBAD	(DKIOC|20)	/* Re-read the alternate map (IDE) */
193 #define	DKIOCGETDEF	(DKIOC|21)	/* read defect list (IDE)	   */
194 
195 /*
196  * Used by applications to get disk defect information from IDE
197  * drives.
198  */
199 #ifdef _SYSCALL32
200 struct defect_header32 {
201 	int		head;
202 	caddr32_t	buffer;
203 };
204 #endif /* _SYSCALL32 */
205 
206 struct defect_header {
207 	int		head;
208 	caddr_t		buffer;
209 };
210 
211 #define	DKIOCPARTINFO	(DKIOC|22)	/* Get partition or slice parameters */
212 
213 /*
214  * Used by applications to get partition or slice information
215  */
216 #ifdef _SYSCALL32
217 struct part_info32 {
218 	daddr32_t	p_start;
219 	int		p_length;
220 };
221 #endif /* _SYSCALL32 */
222 
223 struct part_info {
224 	daddr_t		p_start;
225 	int		p_length;
226 };
227 
228 /* The following ioctls are for Optical Memory Device */
229 #define	DKIOC_EBP_ENABLE  (DKIOC|40)	/* enable by pass erase on write */
230 #define	DKIOC_EBP_DISABLE (DKIOC|41)	/* disable by pass erase on write */
231 
232 /*
233  * This state enum is the argument passed to the DKIOCSTATE ioctl.
234  */
235 enum dkio_state { DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED, DKIO_DEV_GONE };
236 
237 #define	DKIOCGMEDIAINFO	(DKIOC|42)	/* get information about the media */
238 
239 /*
240  * ioctls to read/write mboot info.
241  */
242 #define	DKIOCGMBOOT	(DKIOC|43)	/* get mboot info */
243 #define	DKIOCSMBOOT	(DKIOC|44)	/* set mboot info */
244 
245 /*
246  * ioctl to get the device temperature.
247  */
248 #define	DKIOCGTEMPERATURE	(DKIOC|45)	/* get temperature */
249 
250 /*
251  * Used for providing the temperature.
252  */
253 
254 struct	dk_temperature	{
255 	uint_t		dkt_flags;	/* Flags */
256 	short		dkt_cur_temp;	/* Current disk temperature */
257 	short		dkt_ref_temp;	/* reference disk temperature */
258 };
259 
260 #define	DKT_BYPASS_PM		0x1
261 #define	DKT_INVALID_TEMP	0xFFFF
262 
263 
264 /*
265  * Used for Media info or the current profile info
266  */
267 struct dk_minfo {
268 	uint_t		dki_media_type;	/* Media type or profile info */
269 	uint_t		dki_lbsize;	/* Logical blocksize of media */
270 	diskaddr_t	dki_capacity;	/* Capacity as # of dki_lbsize blks */
271 };
272 
273 /*
274  * Media types or profiles known
275  */
276 #define	DK_UNKNOWN		0x00	/* Media inserted - type unknown */
277 
278 
279 /*
280  * SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are retained to
281  * maintain compatibility with SFF8090.  The following define the
282  * optical media type.
283  */
284 #define	DK_MO_ERASABLE		0x03 /* MO Erasable */
285 #define	DK_MO_WRITEONCE		0x04 /* MO Write once */
286 #define	DK_AS_MO		0x05 /* AS MO */
287 #define	DK_CDROM		0x08 /* CDROM */
288 #define	DK_CDR			0x09 /* CD-R */
289 #define	DK_CDRW			0x0A /* CD-RW */
290 #define	DK_DVDROM		0x10 /* DVD-ROM */
291 #define	DK_DVDR			0x11 /* DVD-R */
292 #define	DK_DVDRAM		0x12 /* DVD_RAM or DVD-RW */
293 
294 /*
295  * Media types for other rewritable magnetic media
296  */
297 #define	DK_FIXED_DISK		0x10001	/* Fixed disk SCSI or otherwise */
298 #define	DK_FLOPPY		0x10002 /* Floppy media */
299 #define	DK_ZIP			0x10003 /* IOMEGA ZIP media */
300 #define	DK_JAZ			0x10004 /* IOMEGA JAZ media */
301 
302 #define	DKIOCSETEFI	(DKIOC|17)		/* Set EFI info */
303 #define	DKIOCGETEFI	(DKIOC|18)		/* Get EFI info */
304 
305 #define	DKIOCPARTITION	(DKIOC|9)		/* Get partition info */
306 
307 /*
308  * Ioctls to get/set volume capabilities related to Logical Volume Managers.
309  * They include the ability to get/set capabilities and to issue a read to a
310  * specific underlying device of a replicated device.
311  */
312 
313 #define	DKIOCGETVOLCAP	(DKIOC | 25)	/* Get volume capabilities */
314 #define	DKIOCSETVOLCAP	(DKIOC | 26)	/* Set volume capabilities */
315 #define	DKIOCDMR	(DKIOC | 27)	/* Issue a directed read */
316 
317 typedef uint_t volcapinfo_t;
318 
319 typedef uint_t volcapset_t;
320 
321 #define	DKV_ABR_CAP 0x00000001		/* Support Appl.Based Recovery */
322 #define	DKV_DMR_CAP 0x00000002		/* Support Directed  Mirror Read */
323 
324 typedef struct volcap {
325 	volcapinfo_t vc_info;	/* Capabilities available */
326 	volcapset_t vc_set;	/* Capabilities set */
327 } volcap_t;
328 
329 #define	VOL_SIDENAME 256
330 
331 typedef struct vol_directed_rd {
332 	int		vdr_flags;
333 	offset_t	vdr_offset;
334 	size_t		vdr_nbytes;
335 	size_t		vdr_bytesread;
336 	void		*vdr_data;
337 	int		vdr_side;
338 	char		vdr_side_name[VOL_SIDENAME];
339 } vol_directed_rd_t;
340 
341 #define	DKV_SIDE_INIT		(-1)
342 #define	DKV_DMR_NEXT_SIDE	0x00000001
343 #define	DKV_DMR_DONE		0x00000002
344 #define	DKV_DMR_ERROR		0x00000004
345 #define	DKV_DMR_SUCCESS		0x00000008
346 #define	DKV_DMR_SHORT		0x00000010
347 
348 #ifdef _MULTI_DATAMODEL
349 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
350 #pragma pack(4)
351 #endif
352 typedef struct vol_directed_rd32 {
353 	int32_t		vdr_flags;
354 	offset_t	vdr_offset;	/* 64-bit element on 32-bit alignment */
355 	size32_t	vdr_nbytes;
356 	size32_t	vdr_bytesread;
357 	caddr32_t	vdr_data;
358 	int32_t		vdr_side;
359 	char		vdr_side_name[VOL_SIDENAME];
360 } vol_directed_rd32_t;
361 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
362 #pragma pack()
363 #endif
364 #endif	/* _MULTI_DATAMODEL */
365 
366 #ifdef	__cplusplus
367 }
368 #endif
369 
370 #endif /* _SYS_DKIO_H */
371