dkio.h revision 270312
1132751Skan/*
2132751Skan * CDDL HEADER START
3169718Skan *
445299Sobrien * The contents of this file are subject to the terms of the
5132751Skan * Common Development and Distribution License (the "License").
6169718Skan * You may not use this file except in compliance with the License.
7132751Skan *
8169718Skan * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
952914Sobrien * or http://www.opensolaris.org/os/licensing.
10169718Skan * See the License for the specific language governing permissions
11132751Skan * and limitations under the License.
12169718Skan *
13132751Skan * When distributing Covered Code, include this CDDL HEADER in each
14169718Skan * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1552914Sobrien * If applicable, add the following below this CDDL HEADER, with the
16169718Skan * fields enclosed by brackets "[]" replaced with your own identifying
17132751Skan * information: Portions Copyright [yyyy] [name of copyright owner]
18169718Skan *
19132751Skan * CDDL HEADER END
20169718Skan *
2196340Sobrien * $FreeBSD: stable/10/sys/cddl/compat/opensolaris/sys/dkio.h 270312 2014-08-21 22:44:08Z smh $
22169718Skan */
23132751Skan/*
24169718Skan * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25132751Skan * Use is subject to license terms.
26169718Skan */
2796340Sobrien
28169718Skan#ifndef _OPENSOLARIS_SYS_DKIO_H_
29132751Skan#define	_OPENSOLARIS_SYS_DKIO_H_
30132751Skan
31132751Skan#ifdef	__cplusplus
32132751Skanextern "C" {
33169718Skan#endif
34132751Skan
35169718Skan/*
3652914Sobrien * Disk io control commands
3752914Sobrien * Warning: some other ioctls with the DIOC prefix exist elsewhere.
38169718Skan * The Generic DKIOC numbers are from	0   -  50.
39169718Skan *	The Floppy Driver uses		51  - 100.
40169718Skan *	The Hard Disk (except SCSI)	101 - 106.	(these are obsolete)
41169718Skan *	The CDROM Driver		151 - 200.
4245299Sobrien *	The USCSI ioctl			201 - 250.
43169718Skan */
44132751Skan#define	DKIOC		(0x04 << 8)
45132751Skan
46169718Skan/*
47169718Skan * The following ioctls are generic in nature and need to be
48169718Skan * suported as appropriate by all disk drivers
4952914Sobrien */
50169718Skan#define	DKIOCGGEOM	(DKIOC|1)		/* Get geometry */
51169718Skan#define	DKIOCINFO	(DKIOC|3)		/* Get info */
52169718Skan#define	DKIOCEJECT	(DKIOC|6)		/* Generic 'eject' */
53169718Skan#define	DKIOCGVTOC	(DKIOC|11)		/* Get VTOC */
54169718Skan#define	DKIOCSVTOC	(DKIOC|12)		/* Set VTOC & Write to Disk */
55169718Skan
56169718Skan/*
57132751Skan * Disk Cache Controls.  These ioctls should be supported by
58132751Skan * all disk drivers.
59169718Skan *
60169718Skan * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl
61169718Skan * argument, but it should be passed as NULL to allow for future
6252914Sobrien * reinterpretation.  From user-mode, this ioctl request is synchronous.
63169718Skan *
64132751Skan * When invoked from within the kernel, the arg can be NULL to indicate
65132751Skan * a synchronous request or can be the address of a struct dk_callback
66132751Skan * to request an asynchronous callback when the flush request is complete.
67169718Skan * In this case, the flag to the ioctl must include FKIOCTL and the
68169718Skan * dkc_callback field of the pointed to struct must be non-null or the
69169718Skan * request is made synchronously.
7052914Sobrien *
71169718Skan * In the callback case: if the ioctl returns 0, a callback WILL be performed.
72132751Skan * If the ioctl returns non-zero, a callback will NOT be performed.
73132751Skan * NOTE: In some cases, the callback may be done BEFORE the ioctl call
74169718Skan * returns.  The caller's locking strategy should be prepared for this case.
75169718Skan */
76169718Skan#define	DKIOCFLUSHWRITECACHE	(DKIOC|34)	/* flush cache to phys medium */
7796340Sobrien
78169718Skanstruct dk_callback {
79169718Skan	void (*dkc_callback)(void *dkc_cookie, int error);
80169718Skan	void *dkc_cookie;
81169718Skan};
82169718Skan
83169718Skan#ifdef	__cplusplus
84169718Skan}
85169718Skan#endif
86132751Skan
87132751Skan#endif /* _OPENSOLARIS_SYS_DKIO_H_ */
88132751Skan