1168404Spjd/*
2168404Spjd * CDDL HEADER START
3168404Spjd *
4168404Spjd * The contents of this file are subject to the terms of the
5168404Spjd * Common Development and Distribution License (the "License").
6168404Spjd * You may not use this file except in compliance with the License.
7168404Spjd *
8168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9168404Spjd * or http://www.opensolaris.org/os/licensing.
10168404Spjd * See the License for the specific language governing permissions
11168404Spjd * and limitations under the License.
12168404Spjd *
13168404Spjd * When distributing Covered Code, include this CDDL HEADER in each
14168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15168404Spjd * If applicable, add the following below this CDDL HEADER, with the
16168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying
17168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner]
18168404Spjd *
19168404Spjd * CDDL HEADER END
20178414Sjb *
21178414Sjb * $FreeBSD: releng/11.0/sys/cddl/compat/opensolaris/sys/dkio.h 265152 2014-04-30 17:46:29Z smh $
22168404Spjd */
23168404Spjd/*
24168404Spjd * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25168404Spjd * Use is subject to license terms.
26168404Spjd */
27168404Spjd
28168404Spjd#ifndef _OPENSOLARIS_SYS_DKIO_H_
29168404Spjd#define	_OPENSOLARIS_SYS_DKIO_H_
30168404Spjd
31168404Spjd#ifdef	__cplusplus
32168404Spjdextern "C" {
33168404Spjd#endif
34168404Spjd
35168404Spjd/*
36168404Spjd * Disk io control commands
37168404Spjd * Warning: some other ioctls with the DIOC prefix exist elsewhere.
38168404Spjd * The Generic DKIOC numbers are from	0   -  50.
39168404Spjd *	The Floppy Driver uses		51  - 100.
40168404Spjd *	The Hard Disk (except SCSI)	101 - 106.	(these are obsolete)
41168404Spjd *	The CDROM Driver		151 - 200.
42168404Spjd *	The USCSI ioctl			201 - 250.
43168404Spjd */
44168404Spjd#define	DKIOC		(0x04 << 8)
45168404Spjd
46168404Spjd/*
47168404Spjd * The following ioctls are generic in nature and need to be
48168404Spjd * suported as appropriate by all disk drivers
49168404Spjd */
50168404Spjd#define	DKIOCGGEOM	(DKIOC|1)		/* Get geometry */
51168404Spjd#define	DKIOCINFO	(DKIOC|3)		/* Get info */
52168404Spjd#define	DKIOCEJECT	(DKIOC|6)		/* Generic 'eject' */
53168404Spjd#define	DKIOCGVTOC	(DKIOC|11)		/* Get VTOC */
54168404Spjd#define	DKIOCSVTOC	(DKIOC|12)		/* Set VTOC & Write to Disk */
55168404Spjd
56168404Spjd/*
57168404Spjd * Disk Cache Controls.  These ioctls should be supported by
58168404Spjd * all disk drivers.
59168404Spjd *
60168404Spjd * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl
61168404Spjd * argument, but it should be passed as NULL to allow for future
62168404Spjd * reinterpretation.  From user-mode, this ioctl request is synchronous.
63168404Spjd *
64168404Spjd * When invoked from within the kernel, the arg can be NULL to indicate
65168404Spjd * a synchronous request or can be the address of a struct dk_callback
66168404Spjd * to request an asynchronous callback when the flush request is complete.
67168404Spjd * In this case, the flag to the ioctl must include FKIOCTL and the
68168404Spjd * dkc_callback field of the pointed to struct must be non-null or the
69168404Spjd * request is made synchronously.
70168404Spjd *
71168404Spjd * In the callback case: if the ioctl returns 0, a callback WILL be performed.
72168404Spjd * If the ioctl returns non-zero, a callback will NOT be performed.
73168404Spjd * NOTE: In some cases, the callback may be done BEFORE the ioctl call
74168404Spjd * returns.  The caller's locking strategy should be prepared for this case.
75168404Spjd */
76168404Spjd#define	DKIOCFLUSHWRITECACHE	(DKIOC|34)	/* flush cache to phys medium */
77168404Spjd
78168404Spjdstruct dk_callback {
79168404Spjd	void (*dkc_callback)(void *dkc_cookie, int error);
80168404Spjd	void *dkc_cookie;
81168404Spjd};
82168404Spjd
83168404Spjd#ifdef	__cplusplus
84168404Spjd}
85168404Spjd#endif
86168404Spjd
87168404Spjd#endif /* _OPENSOLARIS_SYS_DKIO_H_ */
88