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