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