MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / asm-nios2nommu / ioctl.h
blobc02a36af5c12f7b724439061c69d439826773a02
1 /* $Id: ioctl.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
3 * linux/ioctl.h for Linux by H.H. Bergman.
5 * Copyright (C) 2004, Microtronix Datacom Ltd.
7 * All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
17 * NON INFRINGEMENT. See the GNU General Public License for more
18 * details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #ifndef _NIOS2_IOCTL_H
27 #define _NIOS2_IOCTL_H
29 /* ioctl command encoding: 32 bits total, command in lower 16 bits,
30 * size of the parameter structure in the lower 14 bits of the
31 * upper 16 bits.
32 * Encoding the size of the parameter structure in the ioctl request
33 * is useful for catching programs compiled with old versions
34 * and to avoid overwriting user space outside the user buffer area.
35 * The highest 2 bits are reserved for indicating the ``access mode''.
36 * NOTE: This limits the max parameter size to 16kB -1 !
40 * I don't really have any idea about what this should look like, so
41 * for the time being, this is heavily based on the PC definitions.
45 * The following is for compatibility across the various Linux
46 * platforms. The i386 ioctl numbering scheme doesn't really enforce
47 * a type field. De facto, however, the top 8 bits of the lower 16
48 * bits are indeed used as a type field, so we might just as well make
49 * this explicit here. Please be sure to use the decoding macros
50 * below from now on.
52 #define _IOC_NRBITS 8
53 #define _IOC_TYPEBITS 8
54 #define _IOC_SIZEBITS 14
55 #define _IOC_DIRBITS 2
57 #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
58 #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
59 #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
60 #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
62 #define _IOC_NRSHIFT 0
63 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
64 #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
65 #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
68 * Direction bits.
70 #define _IOC_NONE 0U
71 #define _IOC_WRITE 1U
72 #define _IOC_READ 2U
74 #define _IOC(dir,type,nr,size) \
75 (((dir) << _IOC_DIRSHIFT) | \
76 ((type) << _IOC_TYPESHIFT) | \
77 ((nr) << _IOC_NRSHIFT) | \
78 ((size) << _IOC_SIZESHIFT))
80 /* used to create numbers */
81 #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
82 #define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
83 #define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
84 #define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
86 /* used to decode ioctl numbers.. */
87 #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
88 #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
89 #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
90 #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
92 /* ...and for the drivers/sound files... */
94 #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
95 #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
96 #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
97 #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
98 #define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
100 #endif /* _NIOS2_IOCTL_H */