1 | /* $NetBSD: linux_ioctl.h,v 1.27 2013/06/08 12:50:32 stacktic Exp $ */ |
2 | |
3 | /*- |
4 | * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. |
5 | * All rights reserved. |
6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Frank van der Linden and Eric Haszlakiewicz. |
9 | * |
10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions |
12 | * are met: |
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. |
18 | * |
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. |
30 | */ |
31 | |
32 | #ifndef _LINUX_IOCTL_H |
33 | #define _LINUX_IOCTL_H |
34 | |
35 | struct linux_sys_ioctl_args; |
36 | |
37 | #ifdef _KERNEL |
38 | __BEGIN_DECLS |
39 | int linux_machdepioctl(struct lwp *, const struct linux_sys_ioctl_args *, register_t *); |
40 | int linux_ioctl_cdrom(struct lwp *, const struct linux_sys_ioctl_args *, |
41 | register_t *); |
42 | int linux_ioctl_termios(struct lwp *, const struct linux_sys_ioctl_args *, |
43 | register_t *); |
44 | int linux_ioctl_socket(struct lwp *, const struct linux_sys_ioctl_args *, |
45 | register_t *); |
46 | int linux_ioctl_hdio(struct lwp *, const struct linux_sys_ioctl_args *, |
47 | register_t *); |
48 | int linux_ioctl_fdio(struct lwp *, const struct linux_sys_ioctl_args *uap, |
49 | register_t *retval); |
50 | int linux_ioctl_blkio(struct lwp *, const struct linux_sys_ioctl_args *uap, |
51 | register_t *retval); |
52 | int linux_ioctl_sg(struct lwp *, const struct linux_sys_ioctl_args *uap, |
53 | register_t *retval); |
54 | int linux_ioctl_mtio(struct lwp *, const struct linux_sys_ioctl_args *uap, |
55 | register_t *retval); |
56 | __END_DECLS |
57 | #endif /* !_KERNEL */ |
58 | |
59 | #if defined(__i386__) |
60 | #include <compat/linux/arch/i386/linux_ioctl.h> |
61 | #elif defined(__m68k__) |
62 | #include <compat/linux/arch/m68k/linux_ioctl.h> |
63 | #elif defined(__alpha__) |
64 | #include <compat/linux/arch/alpha/linux_ioctl.h> |
65 | #elif defined(__powerpc__) |
66 | #include <compat/linux/arch/powerpc/linux_ioctl.h> |
67 | #elif defined(__mips__) |
68 | #include <compat/linux/arch/mips/linux_ioctl.h> |
69 | #elif defined(__arm__) |
70 | #include <compat/linux/arch/arm/linux_ioctl.h> |
71 | #elif defined(__amd64__) |
72 | #include <compat/linux/arch/amd64/linux_ioctl.h> |
73 | #else |
74 | #error Undefined linux_ioctl.h machine type. |
75 | #endif |
76 | |
77 | #define _LINUX_IOC_NRMASK ((1 << _LINUX_IOC_NRBITS) - 1) |
78 | #define _LINUX_IOC_TYPEMASK ((1 << _LINUX_IOC_TYPEBITS) - 1) |
79 | #define _LINUX_IOC_SIZEMASK ((1 << _LINUX_IOC_SIZEBITS) - 1) |
80 | #define _LINUX_IOC_DIRMASK ((1 << _LINUX_IOC_DIRBITS) - 1) |
81 | |
82 | #define _LINUX_IOC_TYPESHIFT (_LINUX_IOC_NRSHIFT + _LINUX_IOC_NRBITS) |
83 | #define _LINUX_IOC_SIZESHIFT (_LINUX_IOC_TYPESHIFT + _LINUX_IOC_TYPEBITS) |
84 | #define _LINUX_IOC_DIRSHIFT (_LINUX_IOC_SIZESHIFT + _LINUX_IOC_SIZEBITS) |
85 | |
86 | #define _LINUX_IOC(dir,type,nr,size) \ |
87 | (((nr) << _LINUX_IOC_NRSHIFT) | \ |
88 | ((type) << _LINUX_IOC_TYPESHIFT) | \ |
89 | ((size) << _LINUX_IOC_SIZESHIFT) | \ |
90 | ((dir) << _LINUX_IOC_DIRSHIFT)) |
91 | |
92 | #define _LINUX_IO(type,nr) \ |
93 | _LINUX_IOC(_LINUX_IOC_NONE,(type),(nr),0) |
94 | #define _LINUX_IOR(type,nr,size) \ |
95 | _LINUX_IOC(_LINUX_IOC_READ,(type),(nr),sizeof(size)) |
96 | #define _LINUX_IOW(type,nr,size) \ |
97 | _LINUX_IOC(_LINUX_IOC_WRITE,(type),(nr),sizeof(size)) |
98 | #define _LINUX_IOWR(type,nr,size) \ |
99 | _LINUX_IOC(_LINUX_IOC_READ|_LINUX_IOC_WRITE,(type),(nr),sizeof(size)) |
100 | |
101 | #define _LINUX_IOC_DIR(nr) \ |
102 | (((nr) >> _LINUX_IOC_DIRSHIFT) & _LINUX_IOC_DIRMASK) |
103 | #define _LINUX_IOC_TYPE(nr) \ |
104 | (((nr) >> _LINUX_IOC_TYPESHIFT) & _LINUX_IOC_TYPEMASK) |
105 | #define _LINUX_IOC_NR(nr) \ |
106 | (((nr) >> _LINUX_IOC_NRSHIFT) & _LINUX_IOC_NRMASK) |
107 | #define _LINUX_IOC_SIZE(nr) \ |
108 | (((nr) >> _LINUX_IOC_SIZESHIFT) & _LINUX_IOC_SIZEMASK) |
109 | |
110 | #define LINUX_IOCGROUP(x) _LINUX_IOC_TYPE(x) |
111 | |
112 | #endif /* !_LINUX_IOCTL_H */ |
113 | |