1*eda14cbcSMatt Macy /*
2*eda14cbcSMatt Macy  * CDDL HEADER START
3*eda14cbcSMatt Macy  *
4*eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5*eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6*eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7*eda14cbcSMatt Macy  *
8*eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*eda14cbcSMatt Macy  * or http://www.opensolaris.org/os/licensing.
10*eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11*eda14cbcSMatt Macy  * and limitations under the License.
12*eda14cbcSMatt Macy  *
13*eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14*eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16*eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17*eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18*eda14cbcSMatt Macy  *
19*eda14cbcSMatt Macy  * CDDL HEADER END
20*eda14cbcSMatt Macy  */
21*eda14cbcSMatt Macy /*
22*eda14cbcSMatt Macy  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*eda14cbcSMatt Macy  * Use is subject to license terms.
24*eda14cbcSMatt Macy  */
25*eda14cbcSMatt Macy 
26*eda14cbcSMatt Macy #ifndef _SYS_DKIO_H
27*eda14cbcSMatt Macy #define	_SYS_DKIO_H
28*eda14cbcSMatt Macy 
29*eda14cbcSMatt Macy 
30*eda14cbcSMatt Macy 
31*eda14cbcSMatt Macy #include <sys/dklabel.h>	/* Needed for NDKMAP define */
32*eda14cbcSMatt Macy 
33*eda14cbcSMatt Macy #ifdef	__cplusplus
34*eda14cbcSMatt Macy extern "C" {
35*eda14cbcSMatt Macy #endif
36*eda14cbcSMatt Macy 
37*eda14cbcSMatt Macy /*
38*eda14cbcSMatt Macy  * Structures and definitions for disk io control commands
39*eda14cbcSMatt Macy  */
40*eda14cbcSMatt Macy 
41*eda14cbcSMatt Macy /*
42*eda14cbcSMatt Macy  * Structures used as data by ioctl calls.
43*eda14cbcSMatt Macy  */
44*eda14cbcSMatt Macy 
45*eda14cbcSMatt Macy #define	DK_DEVLEN	16		/* device name max length, including */
46*eda14cbcSMatt Macy 					/* unit # & NULL (ie - "xyc1") */
47*eda14cbcSMatt Macy 
48*eda14cbcSMatt Macy /*
49*eda14cbcSMatt Macy  * Used for controller info
50*eda14cbcSMatt Macy  */
51*eda14cbcSMatt Macy struct dk_cinfo {
52*eda14cbcSMatt Macy 	char	dki_cname[DK_DEVLEN];	/* controller name (no unit #) */
53*eda14cbcSMatt Macy 	ushort_t dki_ctype;		/* controller type */
54*eda14cbcSMatt Macy 	ushort_t dki_flags;		/* flags */
55*eda14cbcSMatt Macy 	ushort_t dki_cnum;		/* controller number */
56*eda14cbcSMatt Macy 	uint_t	dki_addr;		/* controller address */
57*eda14cbcSMatt Macy 	uint_t	dki_space;		/* controller bus type */
58*eda14cbcSMatt Macy 	uint_t	dki_prio;		/* interrupt priority */
59*eda14cbcSMatt Macy 	uint_t	dki_vec;		/* interrupt vector */
60*eda14cbcSMatt Macy 	char	dki_dname[DK_DEVLEN];	/* drive name (no unit #) */
61*eda14cbcSMatt Macy 	uint_t	dki_unit;		/* unit number */
62*eda14cbcSMatt Macy 	ushort_t dki_partition;		/* partition number */
63*eda14cbcSMatt Macy 	ushort_t dki_maxtransfer;	/* max. transfer size in DEV_BSIZE */
64*eda14cbcSMatt Macy };
65*eda14cbcSMatt Macy 
66*eda14cbcSMatt Macy /*
67*eda14cbcSMatt Macy  * Controller types
68*eda14cbcSMatt Macy  */
69*eda14cbcSMatt Macy #define	DKC_UNKNOWN	0
70*eda14cbcSMatt Macy #define	DKC_CDROM	1	/* CD-ROM, SCSI or otherwise */
71*eda14cbcSMatt Macy #define	DKC_WDC2880	2
72*eda14cbcSMatt Macy #define	DKC_XXX_0	3	/* unassigned */
73*eda14cbcSMatt Macy #define	DKC_XXX_1	4	/* unassigned */
74*eda14cbcSMatt Macy #define	DKC_DSD5215	5
75*eda14cbcSMatt Macy #define	DKC_ACB4000	7
76*eda14cbcSMatt Macy #define	DKC_MD21	8
77*eda14cbcSMatt Macy #define	DKC_XXX_2	9	/* unassigned */
78*eda14cbcSMatt Macy #define	DKC_NCRFLOPPY	10
79*eda14cbcSMatt Macy #define	DKC_SMSFLOPPY	12
80*eda14cbcSMatt Macy #define	DKC_SCSI_CCS	13	/* SCSI CCS compatible */
81*eda14cbcSMatt Macy #define	DKC_INTEL82072	14	/* native floppy chip */
82*eda14cbcSMatt Macy #define	DKC_MD		16	/* meta-disk (virtual-disk) driver */
83*eda14cbcSMatt Macy #define	DKC_INTEL82077	19	/* 82077 floppy disk controller */
84*eda14cbcSMatt Macy #define	DKC_DIRECT	20	/* Intel direct attached device i.e. IDE */
85*eda14cbcSMatt Macy #define	DKC_PCMCIA_MEM	21	/* PCMCIA memory disk-like type */
86*eda14cbcSMatt Macy #define	DKC_PCMCIA_ATA	22	/* PCMCIA AT Attached type */
87*eda14cbcSMatt Macy #define	DKC_VBD		23	/* virtual block device */
88*eda14cbcSMatt Macy 
89*eda14cbcSMatt Macy /*
90*eda14cbcSMatt Macy  * Sun reserves up through 1023
91*eda14cbcSMatt Macy  */
92*eda14cbcSMatt Macy 
93*eda14cbcSMatt Macy #define	DKC_CUSTOMER_BASE	1024
94*eda14cbcSMatt Macy 
95*eda14cbcSMatt Macy /*
96*eda14cbcSMatt Macy  * Flags
97*eda14cbcSMatt Macy  */
98*eda14cbcSMatt Macy #define	DKI_BAD144	0x01	/* use DEC std 144 bad sector fwding */
99*eda14cbcSMatt Macy #define	DKI_MAPTRK	0x02	/* controller does track mapping */
100*eda14cbcSMatt Macy #define	DKI_FMTTRK	0x04	/* formats only full track at a time */
101*eda14cbcSMatt Macy #define	DKI_FMTVOL	0x08	/* formats only full volume at a time */
102*eda14cbcSMatt Macy #define	DKI_FMTCYL	0x10	/* formats only full cylinders at a time */
103*eda14cbcSMatt Macy #define	DKI_HEXUNIT	0x20	/* unit number is printed as 3 hex digits */
104*eda14cbcSMatt Macy #define	DKI_PCMCIA_PFD	0x40	/* PCMCIA pseudo-floppy memory card */
105*eda14cbcSMatt Macy 
106*eda14cbcSMatt Macy /*
107*eda14cbcSMatt Macy  * Used for all partitions
108*eda14cbcSMatt Macy  */
109*eda14cbcSMatt Macy struct dk_allmap {
110*eda14cbcSMatt Macy 	struct dk_map	dka_map[NDKMAP];
111*eda14cbcSMatt Macy };
112*eda14cbcSMatt Macy 
113*eda14cbcSMatt Macy #if defined(_SYSCALL32)
114*eda14cbcSMatt Macy struct dk_allmap32 {
115*eda14cbcSMatt Macy 	struct dk_map32	dka_map[NDKMAP];
116*eda14cbcSMatt Macy };
117*eda14cbcSMatt Macy #endif /* _SYSCALL32 */
118*eda14cbcSMatt Macy 
119*eda14cbcSMatt Macy /*
120*eda14cbcSMatt Macy  * Definition of a disk's geometry
121*eda14cbcSMatt Macy  */
122*eda14cbcSMatt Macy struct dk_geom {
123*eda14cbcSMatt Macy 	unsigned short	dkg_ncyl;	/* # of data cylinders */
124*eda14cbcSMatt Macy 	unsigned short	dkg_acyl;	/* # of alternate cylinders */
125*eda14cbcSMatt Macy 	unsigned short	dkg_bcyl;	/* cyl offset (for fixed head area) */
126*eda14cbcSMatt Macy 	unsigned short	dkg_nhead;	/* # of heads */
127*eda14cbcSMatt Macy 	unsigned short	dkg_obs1;	/* obsolete */
128*eda14cbcSMatt Macy 	unsigned short	dkg_nsect;	/* # of data sectors per track */
129*eda14cbcSMatt Macy 	unsigned short	dkg_intrlv;	/* interleave factor */
130*eda14cbcSMatt Macy 	unsigned short	dkg_obs2;	/* obsolete */
131*eda14cbcSMatt Macy 	unsigned short	dkg_obs3;	/* obsolete */
132*eda14cbcSMatt Macy 	unsigned short	dkg_apc;	/* alternates per cyl (SCSI only) */
133*eda14cbcSMatt Macy 	unsigned short	dkg_rpm;	/* revolutions per minute */
134*eda14cbcSMatt Macy 	unsigned short	dkg_pcyl;	/* # of physical cylinders */
135*eda14cbcSMatt Macy 	unsigned short	dkg_write_reinstruct;	/* # sectors to skip, writes */
136*eda14cbcSMatt Macy 	unsigned short	dkg_read_reinstruct;	/* # sectors to skip, reads */
137*eda14cbcSMatt Macy 	unsigned short	dkg_extra[7];	/* for compatible expansion */
138*eda14cbcSMatt Macy };
139*eda14cbcSMatt Macy 
140*eda14cbcSMatt Macy /*
141*eda14cbcSMatt Macy  * These defines are for historic compatibility with old drivers.
142*eda14cbcSMatt Macy  */
143*eda14cbcSMatt Macy #define	dkg_bhead	dkg_obs1	/* used to be head offset */
144*eda14cbcSMatt Macy #define	dkg_gap1	dkg_obs2	/* used to be gap1 */
145*eda14cbcSMatt Macy #define	dkg_gap2	dkg_obs3	/* used to be gap2 */
146*eda14cbcSMatt Macy 
147*eda14cbcSMatt Macy /*
148*eda14cbcSMatt Macy  * Disk io control commands
149*eda14cbcSMatt Macy  * Warning: some other ioctls with the DIOC prefix exist elsewhere.
150*eda14cbcSMatt Macy  * The Generic DKIOC numbers are from	0   -  50.
151*eda14cbcSMatt Macy  *	The Floppy Driver uses		51  - 100.
152*eda14cbcSMatt Macy  *	The Hard Disk (except SCSI)	101 - 106.	(these are obsolete)
153*eda14cbcSMatt Macy  *	The CDROM Driver		151 - 200.
154*eda14cbcSMatt Macy  *	The USCSI ioctl			201 - 250.
155*eda14cbcSMatt Macy  */
156*eda14cbcSMatt Macy #define	DKIOC		(0x04 << 8)
157*eda14cbcSMatt Macy 
158*eda14cbcSMatt Macy /*
159*eda14cbcSMatt Macy  * The following ioctls are generic in nature and need to be
160*eda14cbcSMatt Macy  * supported as appropriate by all disk drivers
161*eda14cbcSMatt Macy  */
162*eda14cbcSMatt Macy #define	DKIOCGGEOM	(DKIOC|1)		/* Get geometry */
163*eda14cbcSMatt Macy #define	DKIOCINFO	(DKIOC|3)		/* Get info */
164*eda14cbcSMatt Macy #define	DKIOCEJECT	(DKIOC|6)		/* Generic 'eject' */
165*eda14cbcSMatt Macy #define	DKIOCGVTOC	(DKIOC|11)		/* Get VTOC */
166*eda14cbcSMatt Macy #define	DKIOCSVTOC	(DKIOC|12)		/* Set VTOC & Write to Disk */
167*eda14cbcSMatt Macy 
168*eda14cbcSMatt Macy /*
169*eda14cbcSMatt Macy  * Disk Cache Controls.  These ioctls should be supported by
170*eda14cbcSMatt Macy  * all disk drivers.
171*eda14cbcSMatt Macy  *
172*eda14cbcSMatt Macy  * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl
173*eda14cbcSMatt Macy  * argument, but it should be passed as NULL to allow for future
174*eda14cbcSMatt Macy  * reinterpretation.  From user-mode, this ioctl request is synchronous.
175*eda14cbcSMatt Macy  *
176*eda14cbcSMatt Macy  * When invoked from within the kernel, the arg can be NULL to indicate
177*eda14cbcSMatt Macy  * a synchronous request or can be the address of a struct dk_callback
178*eda14cbcSMatt Macy  * to request an asynchronous callback when the flush request is complete.
179*eda14cbcSMatt Macy  * In this case, the flag to the ioctl must include FKIOCTL and the
180*eda14cbcSMatt Macy  * dkc_callback field of the pointed to struct must be non-null or the
181*eda14cbcSMatt Macy  * request is made synchronously.
182*eda14cbcSMatt Macy  *
183*eda14cbcSMatt Macy  * In the callback case: if the ioctl returns 0, a callback WILL be performed.
184*eda14cbcSMatt Macy  * If the ioctl returns non-zero, a callback will NOT be performed.
185*eda14cbcSMatt Macy  * NOTE: In some cases, the callback may be done BEFORE the ioctl call
186*eda14cbcSMatt Macy  * returns.  The caller's locking strategy should be prepared for this case.
187*eda14cbcSMatt Macy  */
188*eda14cbcSMatt Macy #define	DKIOCFLUSHWRITECACHE	(DKIOC|34)	/* flush cache to phys medium */
189*eda14cbcSMatt Macy 
190*eda14cbcSMatt Macy struct dk_callback {
191*eda14cbcSMatt Macy 	void (*dkc_callback)(void *dkc_cookie, int error);
192*eda14cbcSMatt Macy 	void *dkc_cookie;
193*eda14cbcSMatt Macy 	int dkc_flag;
194*eda14cbcSMatt Macy };
195*eda14cbcSMatt Macy 
196*eda14cbcSMatt Macy /* bit flag definitions for dkc_flag */
197*eda14cbcSMatt Macy #define	FLUSH_VOLATILE		0x1	/* Bit 0: if set, only flush */
198*eda14cbcSMatt Macy 					/* volatile cache; otherwise, flush */
199*eda14cbcSMatt Macy 					/* volatile and non-volatile cache */
200*eda14cbcSMatt Macy 
201*eda14cbcSMatt Macy #define	DKIOCGETWCE		(DKIOC|36)	/* Get current write cache */
202*eda14cbcSMatt Macy 						/* enablement status */
203*eda14cbcSMatt Macy #define	DKIOCSETWCE		(DKIOC|37)	/* Enable/Disable write cache */
204*eda14cbcSMatt Macy 
205*eda14cbcSMatt Macy /*
206*eda14cbcSMatt Macy  * The following ioctls are used by Sun drivers to communicate
207*eda14cbcSMatt Macy  * with their associated format routines. Support of these ioctls
208*eda14cbcSMatt Macy  * is not required of foreign drivers
209*eda14cbcSMatt Macy  */
210*eda14cbcSMatt Macy #define	DKIOCSGEOM	(DKIOC|2)		/* Set geometry */
211*eda14cbcSMatt Macy #define	DKIOCSAPART	(DKIOC|4)		/* Set all partitions */
212*eda14cbcSMatt Macy #define	DKIOCGAPART	(DKIOC|5)		/* Get all partitions */
213*eda14cbcSMatt Macy #define	DKIOCG_PHYGEOM	(DKIOC|32)		/* get physical geometry */
214*eda14cbcSMatt Macy #define	DKIOCG_VIRTGEOM	(DKIOC|33)		/* get virtual geometry */
215*eda14cbcSMatt Macy 
216*eda14cbcSMatt Macy /*
217*eda14cbcSMatt Macy  * The following ioctl's are removable media support
218*eda14cbcSMatt Macy  */
219*eda14cbcSMatt Macy #define	DKIOCLOCK	(DKIOC|7)	/* Generic 'lock' */
220*eda14cbcSMatt Macy #define	DKIOCUNLOCK	(DKIOC|8)	/* Generic 'unlock' */
221*eda14cbcSMatt Macy #define	DKIOCSTATE	(DKIOC|13)	/* Inquire insert/eject state */
222*eda14cbcSMatt Macy #define	DKIOCREMOVABLE	(DKIOC|16)	/* is media removable */
223*eda14cbcSMatt Macy 
224*eda14cbcSMatt Macy 
225*eda14cbcSMatt Macy /*
226*eda14cbcSMatt Macy  * ioctl for hotpluggable devices
227*eda14cbcSMatt Macy  */
228*eda14cbcSMatt Macy #define	DKIOCHOTPLUGGABLE	(DKIOC|35)	/* is hotpluggable */
229*eda14cbcSMatt Macy 
230*eda14cbcSMatt Macy /*
231*eda14cbcSMatt Macy  * Ioctl to force driver to re-read the alternate partition and rebuild
232*eda14cbcSMatt Macy  * the internal defect map.
233*eda14cbcSMatt Macy  */
234*eda14cbcSMatt Macy #define	DKIOCADDBAD	(DKIOC|20)	/* Re-read the alternate map (IDE) */
235*eda14cbcSMatt Macy #define	DKIOCGETDEF	(DKIOC|21)	/* read defect list (IDE)	   */
236*eda14cbcSMatt Macy 
237*eda14cbcSMatt Macy /*
238*eda14cbcSMatt Macy  * Used by applications to get disk defect information from IDE
239*eda14cbcSMatt Macy  * drives.
240*eda14cbcSMatt Macy  */
241*eda14cbcSMatt Macy #ifdef _SYSCALL32
242*eda14cbcSMatt Macy struct defect_header32 {
243*eda14cbcSMatt Macy 	int		head;
244*eda14cbcSMatt Macy 	caddr32_t	buffer;
245*eda14cbcSMatt Macy };
246*eda14cbcSMatt Macy #endif /* _SYSCALL32 */
247*eda14cbcSMatt Macy 
248*eda14cbcSMatt Macy struct defect_header {
249*eda14cbcSMatt Macy 	int		head;
250*eda14cbcSMatt Macy 	caddr_t		buffer;
251*eda14cbcSMatt Macy };
252*eda14cbcSMatt Macy 
253*eda14cbcSMatt Macy #define	DKIOCPARTINFO	(DKIOC|22)	/* Get partition or slice parameters */
254*eda14cbcSMatt Macy 
255*eda14cbcSMatt Macy /*
256*eda14cbcSMatt Macy  * Used by applications to get partition or slice information
257*eda14cbcSMatt Macy  */
258*eda14cbcSMatt Macy #ifdef _SYSCALL32
259*eda14cbcSMatt Macy struct part_info32 {
260*eda14cbcSMatt Macy 	uint32_t	p_start;
261*eda14cbcSMatt Macy 	int		p_length;
262*eda14cbcSMatt Macy };
263*eda14cbcSMatt Macy #endif /* _SYSCALL32 */
264*eda14cbcSMatt Macy 
265*eda14cbcSMatt Macy struct part_info {
266*eda14cbcSMatt Macy 	uint64_t	p_start;
267*eda14cbcSMatt Macy 	int		p_length;
268*eda14cbcSMatt Macy };
269*eda14cbcSMatt Macy 
270*eda14cbcSMatt Macy /* The following ioctls are for Optical Memory Device */
271*eda14cbcSMatt Macy #define	DKIOC_EBP_ENABLE  (DKIOC|40)	/* enable by pass erase on write */
272*eda14cbcSMatt Macy #define	DKIOC_EBP_DISABLE (DKIOC|41)	/* disable by pass erase on write */
273*eda14cbcSMatt Macy 
274*eda14cbcSMatt Macy /*
275*eda14cbcSMatt Macy  * This state enum is the argument passed to the DKIOCSTATE ioctl.
276*eda14cbcSMatt Macy  */
277*eda14cbcSMatt Macy enum dkio_state { DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED, DKIO_DEV_GONE };
278*eda14cbcSMatt Macy 
279*eda14cbcSMatt Macy #define	DKIOCGMEDIAINFO	(DKIOC|42)	/* get information about the media */
280*eda14cbcSMatt Macy 
281*eda14cbcSMatt Macy /*
282*eda14cbcSMatt Macy  * ioctls to read/write mboot info.
283*eda14cbcSMatt Macy  */
284*eda14cbcSMatt Macy #define	DKIOCGMBOOT	(DKIOC|43)	/* get mboot info */
285*eda14cbcSMatt Macy #define	DKIOCSMBOOT	(DKIOC|44)	/* set mboot info */
286*eda14cbcSMatt Macy 
287*eda14cbcSMatt Macy /*
288*eda14cbcSMatt Macy  * ioctl to get the device temperature.
289*eda14cbcSMatt Macy  */
290*eda14cbcSMatt Macy #define	DKIOCGTEMPERATURE	(DKIOC|45)	/* get temperature */
291*eda14cbcSMatt Macy 
292*eda14cbcSMatt Macy /*
293*eda14cbcSMatt Macy  * Used for providing the temperature.
294*eda14cbcSMatt Macy  */
295*eda14cbcSMatt Macy 
296*eda14cbcSMatt Macy struct	dk_temperature	{
297*eda14cbcSMatt Macy 	uint_t		dkt_flags;	/* Flags */
298*eda14cbcSMatt Macy 	short		dkt_cur_temp;	/* Current disk temperature */
299*eda14cbcSMatt Macy 	short		dkt_ref_temp;	/* reference disk temperature */
300*eda14cbcSMatt Macy };
301*eda14cbcSMatt Macy 
302*eda14cbcSMatt Macy #define	DKT_BYPASS_PM		0x1
303*eda14cbcSMatt Macy #define	DKT_INVALID_TEMP	0xFFFF
304*eda14cbcSMatt Macy 
305*eda14cbcSMatt Macy 
306*eda14cbcSMatt Macy /*
307*eda14cbcSMatt Macy  * Used for Media info or the current profile info
308*eda14cbcSMatt Macy  */
309*eda14cbcSMatt Macy struct dk_minfo {
310*eda14cbcSMatt Macy 	uint_t		dki_media_type;	/* Media type or profile info */
311*eda14cbcSMatt Macy 	uint_t		dki_lbsize;	/* Logical blocksize of media */
312*eda14cbcSMatt Macy 	diskaddr_t	dki_capacity;	/* Capacity as # of dki_lbsize blks */
313*eda14cbcSMatt Macy };
314*eda14cbcSMatt Macy 
315*eda14cbcSMatt Macy /*
316*eda14cbcSMatt Macy  * Media types or profiles known
317*eda14cbcSMatt Macy  */
318*eda14cbcSMatt Macy #define	DK_UNKNOWN		0x00	/* Media inserted - type unknown */
319*eda14cbcSMatt Macy 
320*eda14cbcSMatt Macy 
321*eda14cbcSMatt Macy /*
322*eda14cbcSMatt Macy  * SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are retained to
323*eda14cbcSMatt Macy  * maintain compatibility with SFF8090.  The following define the
324*eda14cbcSMatt Macy  * optical media type.
325*eda14cbcSMatt Macy  */
326*eda14cbcSMatt Macy #define	DK_REMOVABLE_DISK	0x02 /* Removable Disk */
327*eda14cbcSMatt Macy #define	DK_MO_ERASABLE		0x03 /* MO Erasable */
328*eda14cbcSMatt Macy #define	DK_MO_WRITEONCE		0x04 /* MO Write once */
329*eda14cbcSMatt Macy #define	DK_AS_MO		0x05 /* AS MO */
330*eda14cbcSMatt Macy #define	DK_CDROM		0x08 /* CDROM */
331*eda14cbcSMatt Macy #define	DK_CDR			0x09 /* CD-R */
332*eda14cbcSMatt Macy #define	DK_CDRW			0x0A /* CD-RW */
333*eda14cbcSMatt Macy #define	DK_DVDROM		0x10 /* DVD-ROM */
334*eda14cbcSMatt Macy #define	DK_DVDR			0x11 /* DVD-R */
335*eda14cbcSMatt Macy #define	DK_DVDRAM		0x12 /* DVD_RAM or DVD-RW */
336*eda14cbcSMatt Macy 
337*eda14cbcSMatt Macy /*
338*eda14cbcSMatt Macy  * Media types for other rewritable magnetic media
339*eda14cbcSMatt Macy  */
340*eda14cbcSMatt Macy #define	DK_FIXED_DISK		0x10001	/* Fixed disk SCSI or otherwise */
341*eda14cbcSMatt Macy #define	DK_FLOPPY		0x10002 /* Floppy media */
342*eda14cbcSMatt Macy #define	DK_ZIP			0x10003 /* IOMEGA ZIP media */
343*eda14cbcSMatt Macy #define	DK_JAZ			0x10004 /* IOMEGA JAZ media */
344*eda14cbcSMatt Macy 
345*eda14cbcSMatt Macy #define	DKIOCSETEFI	(DKIOC|17)		/* Set EFI info */
346*eda14cbcSMatt Macy #define	DKIOCGETEFI	(DKIOC|18)		/* Get EFI info */
347*eda14cbcSMatt Macy 
348*eda14cbcSMatt Macy #define	DKIOCPARTITION	(DKIOC|9)		/* Get partition info */
349*eda14cbcSMatt Macy 
350*eda14cbcSMatt Macy /*
351*eda14cbcSMatt Macy  * Ioctls to get/set volume capabilities related to Logical Volume Managers.
352*eda14cbcSMatt Macy  * They include the ability to get/set capabilities and to issue a read to a
353*eda14cbcSMatt Macy  * specific underlying device of a replicated device.
354*eda14cbcSMatt Macy  */
355*eda14cbcSMatt Macy 
356*eda14cbcSMatt Macy #define	DKIOCGETVOLCAP	(DKIOC | 25)	/* Get volume capabilities */
357*eda14cbcSMatt Macy #define	DKIOCSETVOLCAP	(DKIOC | 26)	/* Set volume capabilities */
358*eda14cbcSMatt Macy #define	DKIOCDMR	(DKIOC | 27)	/* Issue a directed read */
359*eda14cbcSMatt Macy 
360*eda14cbcSMatt Macy typedef uint_t volcapinfo_t;
361*eda14cbcSMatt Macy 
362*eda14cbcSMatt Macy typedef uint_t volcapset_t;
363*eda14cbcSMatt Macy 
364*eda14cbcSMatt Macy #define	DKV_ABR_CAP 0x00000001		/* Support Appl.Based Recovery */
365*eda14cbcSMatt Macy #define	DKV_DMR_CAP 0x00000002		/* Support Directed  Mirror Read */
366*eda14cbcSMatt Macy 
367*eda14cbcSMatt Macy typedef struct volcap {
368*eda14cbcSMatt Macy 	volcapinfo_t vc_info;	/* Capabilities available */
369*eda14cbcSMatt Macy 	volcapset_t vc_set;	/* Capabilities set */
370*eda14cbcSMatt Macy } volcap_t;
371*eda14cbcSMatt Macy 
372*eda14cbcSMatt Macy #define	VOL_SIDENAME 256
373*eda14cbcSMatt Macy 
374*eda14cbcSMatt Macy typedef struct vol_directed_rd {
375*eda14cbcSMatt Macy 	int		vdr_flags;
376*eda14cbcSMatt Macy 	offset_t	vdr_offset;
377*eda14cbcSMatt Macy 	size_t		vdr_nbytes;
378*eda14cbcSMatt Macy 	size_t		vdr_bytesread;
379*eda14cbcSMatt Macy 	void		*vdr_data;
380*eda14cbcSMatt Macy 	int		vdr_side;
381*eda14cbcSMatt Macy 	char		vdr_side_name[VOL_SIDENAME];
382*eda14cbcSMatt Macy } vol_directed_rd_t;
383*eda14cbcSMatt Macy 
384*eda14cbcSMatt Macy #define	DKV_SIDE_INIT		(-1)
385*eda14cbcSMatt Macy #define	DKV_DMR_NEXT_SIDE	0x00000001
386*eda14cbcSMatt Macy #define	DKV_DMR_DONE		0x00000002
387*eda14cbcSMatt Macy #define	DKV_DMR_ERROR		0x00000004
388*eda14cbcSMatt Macy #define	DKV_DMR_SUCCESS		0x00000008
389*eda14cbcSMatt Macy #define	DKV_DMR_SHORT		0x00000010
390*eda14cbcSMatt Macy 
391*eda14cbcSMatt Macy #ifdef _MULTI_DATAMODEL
392*eda14cbcSMatt Macy #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
393*eda14cbcSMatt Macy #pragma pack(4)
394*eda14cbcSMatt Macy #endif
395*eda14cbcSMatt Macy typedef struct vol_directed_rd32 {
396*eda14cbcSMatt Macy 	int32_t		vdr_flags;
397*eda14cbcSMatt Macy 	offset_t	vdr_offset;	/* 64-bit element on 32-bit alignment */
398*eda14cbcSMatt Macy 	size32_t	vdr_nbytes;
399*eda14cbcSMatt Macy 	size32_t	vdr_bytesread;
400*eda14cbcSMatt Macy 	caddr32_t	vdr_data;
401*eda14cbcSMatt Macy 	int32_t		vdr_side;
402*eda14cbcSMatt Macy 	char		vdr_side_name[VOL_SIDENAME];
403*eda14cbcSMatt Macy } vol_directed_rd32_t;
404*eda14cbcSMatt Macy #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
405*eda14cbcSMatt Macy #pragma pack()
406*eda14cbcSMatt Macy #endif
407*eda14cbcSMatt Macy #endif	/* _MULTI_DATAMODEL */
408*eda14cbcSMatt Macy 
409*eda14cbcSMatt Macy /*
410*eda14cbcSMatt Macy  * The ioctl is used to fetch disk's device type, vendor ID,
411*eda14cbcSMatt Macy  * model number/product ID, firmware revision and serial number together.
412*eda14cbcSMatt Macy  *
413*eda14cbcSMatt Macy  * Currently there are two device types - DKD_ATA_TYPE which means the
414*eda14cbcSMatt Macy  * disk is driven by cmdk/ata or dad/uata driver, and DKD_SCSI_TYPE
415*eda14cbcSMatt Macy  * which means the disk is driven by sd/scsi hba driver.
416*eda14cbcSMatt Macy  */
417*eda14cbcSMatt Macy #define	DKIOC_GETDISKID	(DKIOC|46)
418*eda14cbcSMatt Macy 
419*eda14cbcSMatt Macy /* These two labels are for dkd_dtype of dk_disk_id_t */
420*eda14cbcSMatt Macy #define	DKD_ATA_TYPE	0x01 /* ATA disk or legacy mode SATA disk */
421*eda14cbcSMatt Macy #define	DKD_SCSI_TYPE	0x02 /* SCSI disk or native mode SATA disk */
422*eda14cbcSMatt Macy 
423*eda14cbcSMatt Macy #define	DKD_ATA_MODEL	40	/* model number length */
424*eda14cbcSMatt Macy #define	DKD_ATA_FWVER	8	/* firmware revision length */
425*eda14cbcSMatt Macy #define	DKD_ATA_SERIAL	20	/* serial number length */
426*eda14cbcSMatt Macy 
427*eda14cbcSMatt Macy #define	DKD_SCSI_VENDOR	8	/* vendor ID length */
428*eda14cbcSMatt Macy #define	DKD_SCSI_PRODUCT 16	/* product ID length */
429*eda14cbcSMatt Macy #define	DKD_SCSI_REVLEVEL 4	/* revision level length */
430*eda14cbcSMatt Macy #define	DKD_SCSI_SERIAL 12	/* serial number length */
431*eda14cbcSMatt Macy 
432*eda14cbcSMatt Macy /*
433*eda14cbcSMatt Macy  * The argument type for DKIOC_GETDISKID ioctl.
434*eda14cbcSMatt Macy  */
435*eda14cbcSMatt Macy typedef struct dk_disk_id {
436*eda14cbcSMatt Macy 	uint_t	dkd_dtype;
437*eda14cbcSMatt Macy 	union {
438*eda14cbcSMatt Macy 		struct {
439*eda14cbcSMatt Macy 			char dkd_amodel[DKD_ATA_MODEL];		/* 40 bytes */
440*eda14cbcSMatt Macy 			char dkd_afwver[DKD_ATA_FWVER];		/* 8 bytes */
441*eda14cbcSMatt Macy 			char dkd_aserial[DKD_ATA_SERIAL];	/* 20 bytes */
442*eda14cbcSMatt Macy 		} ata_disk_id;
443*eda14cbcSMatt Macy 		struct {
444*eda14cbcSMatt Macy 			char dkd_svendor[DKD_SCSI_VENDOR];	/* 8 bytes */
445*eda14cbcSMatt Macy 			char dkd_sproduct[DKD_SCSI_PRODUCT];	/* 16 bytes */
446*eda14cbcSMatt Macy 			char dkd_sfwver[DKD_SCSI_REVLEVEL];	/* 4 bytes */
447*eda14cbcSMatt Macy 			char dkd_sserial[DKD_SCSI_SERIAL];	/* 12 bytes */
448*eda14cbcSMatt Macy 		} scsi_disk_id;
449*eda14cbcSMatt Macy 	} disk_id;
450*eda14cbcSMatt Macy } dk_disk_id_t;
451*eda14cbcSMatt Macy 
452*eda14cbcSMatt Macy /*
453*eda14cbcSMatt Macy  * The ioctl is used to update the firmware of device.
454*eda14cbcSMatt Macy  */
455*eda14cbcSMatt Macy #define	DKIOC_UPDATEFW		(DKIOC|47)
456*eda14cbcSMatt Macy 
457*eda14cbcSMatt Macy /* The argument type for DKIOC_UPDATEFW ioctl */
458*eda14cbcSMatt Macy typedef struct dk_updatefw {
459*eda14cbcSMatt Macy 	caddr_t		dku_ptrbuf;	/* pointer to firmware buf */
460*eda14cbcSMatt Macy 	uint_t		dku_size;	/* firmware buf length */
461*eda14cbcSMatt Macy 	uint8_t		dku_type;	/* firmware update type */
462*eda14cbcSMatt Macy } dk_updatefw_t;
463*eda14cbcSMatt Macy 
464*eda14cbcSMatt Macy #ifdef _SYSCALL32
465*eda14cbcSMatt Macy typedef struct dk_updatefw_32 {
466*eda14cbcSMatt Macy 	caddr32_t	dku_ptrbuf;	/* pointer to firmware buf */
467*eda14cbcSMatt Macy 	uint_t		dku_size;	/* firmware buf length */
468*eda14cbcSMatt Macy 	uint8_t		dku_type;	/* firmware update type */
469*eda14cbcSMatt Macy } dk_updatefw_32_t;
470*eda14cbcSMatt Macy #endif /* _SYSCALL32 */
471*eda14cbcSMatt Macy 
472*eda14cbcSMatt Macy /*
473*eda14cbcSMatt Macy  * firmware update type - temporary or permanent use
474*eda14cbcSMatt Macy  */
475*eda14cbcSMatt Macy #define	FW_TYPE_TEMP	0x0		/* temporary use */
476*eda14cbcSMatt Macy #define	FW_TYPE_PERM	0x1		/* permanent use */
477*eda14cbcSMatt Macy 
478*eda14cbcSMatt Macy 
479*eda14cbcSMatt Macy #ifdef	__cplusplus
480*eda14cbcSMatt Macy }
481*eda14cbcSMatt Macy #endif
482*eda14cbcSMatt Macy 
483*eda14cbcSMatt Macy #endif /* _SYS_DKIO_H */
484