1 /* $NetBSD: linux32_ioctl.h,v 1.4 2008/04/28 20:23:44 martin Exp $ */
4 * Copyright (c) 1995-2006 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden, Eric Haszlakiewicz, and Emmanuel Dreyfus.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _LINUX32_IOCTL_H
33 #define _LINUX32_IOCTL_H
35 #if defined(__amd64__)
36 #include <compat/linux32/arch/amd64/linux32_ioctl.h>
41 struct linux32_sys_ioctl_args
;
42 int linux32_ioctl_termios(struct lwp
*, const struct linux32_sys_ioctl_args
*,
44 int linux32_ioctl_socket(struct lwp
*, const struct linux32_sys_ioctl_args
*,
49 #define _LINUX32_IOC_NRMASK ((1 << _LINUX32_IOC_NRBITS) - 1)
50 #define _LINUX32_IOC_TYPEMASK ((1 << _LINUX32_IOC_TYPEBITS) - 1)
51 #define _LINUX32_IOC_SIZEMAEK ((1 << _LINUX32_IOC_SIZEBITS) - 1)
52 #define _LINUX32_IOC_DIRMASK ((1 << _LINUX32_IOC_DIRBITS) - 1)
54 #define _LINUX32_IOC_TYPESHIFT (_LINUX32_IOC_NRSHIFT + _LINUX32_IOC_NRBITS)
55 #define _LINUX32_IOC_SIZESHIFT (_LINUX32_IOC_TYPESHIFT + _LINUX32_IOC_TYPEBITS)
56 #define _LINUX32_IOC_DIRSHIFT (_LINUX32_IOC_SIZESHIFT + _LINUX32_IOC_SIZEBITS)
58 #define _LINUX32_IOC(dir,type,nr,size) \
59 (((nr) << _LINUX32_IOC_NRSHIFT) | \
60 ((type) << _LINUX32_IOC_TYPESHIFT) | \
61 ((size) << _LINUX32_IOC_SIZESHIFT) | \
62 ((dir) << _LINUX32_IOC_DIRSHIFT))
64 #define _LINUX32_IO(type,nr) \
65 _LINUX32_IOC(_LINUX32_IOC_NONE,(type),(nr),0)
66 #define _LINUX32_IOR(type,nr,size) \
67 _LINUX32_IOC(_LINUX32_IOC_READ,(type),(nr),sizeof(size))
68 #define _LINUX32_IOW(type,nr,size) \
69 _LINUX32_IOC(_LINUX32_IOC_WRITE,(type),(nr),sizeof(size))
70 #define _LINUX32_IOWR(type,nr,size) \
71 _LINUX32_IOC(_LINUX32_IOC_READ|_LINUX32_IOC_WRITE,(type),(nr),sizeof(size))
73 #define _LINUX32_IOC_DIR(nr) \
74 (((nr) >> _LINUX32_IOC_DIRSHIFT) & _LINUX32_IOC_DIRMASK)
75 #define _LINUX32_IOC_TYPE(nr) \
76 (((nr) >> _LINUX32_IOC_TYPESHIFT) & _LINUX32_IOC_TYPEMASK)
77 #define _LINUX32_IOC_NR(nr) \
78 (((nr) >> _LINUX32_IOC_NRSHIFT) & _LINUX32_IOC_NRMASK)
79 #define _LINUX32_IOC_SIZE(nr) \
80 (((nr) >> _LINUX32_IOC_SIZESHIFT) & _LINUX32_IOC_SIZEMASK)
82 #define LINUX32_IOCGROUP(x) _LINUX32_IOC_TYPE(x)
84 #endif /* !_LINUX32_IOCTL_H */