4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lnet/include/cygwin-ioctl.h
36 * linux/ioctl.h for Linux by H.H. Bergman.
39 #ifndef _ASMI386_IOCTL_H
40 #define _ASMI386_IOCTL_H
42 /* ioctl command encoding: 32 bits total, command in lower 16 bits,
43 * size of the parameter structure in the lower 14 bits of the
45 * Encoding the size of the parameter structure in the ioctl request
46 * is useful for catching programs compiled with old versions
47 * and to avoid overwriting user space outside the user buffer area.
48 * The highest 2 bits are reserved for indicating the ``access mode''.
49 * NOTE: This limits the max parameter size to 16kB -1 !
53 * The following is for compatibility across the various Linux
54 * platforms. The i386 ioctl numbering scheme doesn't really enforce
55 * a type field. De facto, however, the top 8 bits of the lower 16
56 * bits are indeed used as a type field, so we might just as well make
57 * this explicit here. Please be sure to use the decoding macros
68 #define _IOC_TYPEBITS 8
69 #define _IOC_SIZEBITS 14
70 #define _IOC_DIRBITS 2
72 #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
73 #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
74 #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
75 #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
77 #define _IOC_NRSHIFT 0
78 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
79 #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
80 #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
89 #define _IOC(dir,type,nr,size) \
90 (((dir) << _IOC_DIRSHIFT) | \
91 ((type) << _IOC_TYPESHIFT) | \
92 ((nr) << _IOC_NRSHIFT) | \
93 ((size) << _IOC_SIZESHIFT))
95 /* used to create numbers */
96 #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
97 #define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
98 #define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
99 #define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
101 /* used to decode ioctl numbers.. */
102 #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
103 #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
104 #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
105 #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
107 /* ...and for the drivers/sound files... */
109 #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
110 #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
111 #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
112 #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
113 #define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
115 #endif /* _ASMI386_IOCTL_H */