xref: /freebsd/sys/cddl/compat/opensolaris/sys/dkio.h (revision 81ad6265)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * $FreeBSD$
22  */
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef _OPENSOLARIS_SYS_DKIO_H_
29 #define	_OPENSOLARIS_SYS_DKIO_H_
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Disk io control commands
37  * Warning: some other ioctls with the DIOC prefix exist elsewhere.
38  * The Generic DKIOC numbers are from	0   -  50.
39  *	The Floppy Driver uses		51  - 100.
40  *	The Hard Disk (except SCSI)	101 - 106.	(these are obsolete)
41  *	The CDROM Driver		151 - 200.
42  *	The USCSI ioctl			201 - 250.
43  */
44 #define	DKIOC		(0x04 << 8)
45 
46 /*
47  * The following ioctls are generic in nature and need to be
48  * suported as appropriate by all disk drivers
49  */
50 #define	DKIOCGGEOM	(DKIOC|1)		/* Get geometry */
51 #define	DKIOCINFO	(DKIOC|3)		/* Get info */
52 #define	DKIOCEJECT	(DKIOC|6)		/* Generic 'eject' */
53 #define	DKIOCGVTOC	(DKIOC|11)		/* Get VTOC */
54 #define	DKIOCSVTOC	(DKIOC|12)		/* Set VTOC & Write to Disk */
55 
56 /*
57  * Disk Cache Controls.  These ioctls should be supported by
58  * all disk drivers.
59  *
60  * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl
61  * argument, but it should be passed as NULL to allow for future
62  * reinterpretation.  From user-mode, this ioctl request is synchronous.
63  *
64  * When invoked from within the kernel, the arg can be NULL to indicate
65  * a synchronous request or can be the address of a struct dk_callback
66  * to request an asynchronous callback when the flush request is complete.
67  * In this case, the flag to the ioctl must include FKIOCTL and the
68  * dkc_callback field of the pointed to struct must be non-null or the
69  * request is made synchronously.
70  *
71  * In the callback case: if the ioctl returns 0, a callback WILL be performed.
72  * If the ioctl returns non-zero, a callback will NOT be performed.
73  * NOTE: In some cases, the callback may be done BEFORE the ioctl call
74  * returns.  The caller's locking strategy should be prepared for this case.
75  */
76 #define	DKIOCFLUSHWRITECACHE	(DKIOC|34)	/* flush cache to phys medium */
77 
78 struct dk_callback {
79 	void (*dkc_callback)(void *dkc_cookie, int error);
80 	void *dkc_cookie;
81 };
82 
83 #ifdef	__cplusplus
84 }
85 #endif
86 
87 #endif /* _OPENSOLARIS_SYS_DKIO_H_ */
88