1 #ifndef _ASMI386_IOCTL_H
2 #define _ASMI386_IOCTL_H
4 /* ioctl command encoding: 32 bits total, command in lower 16 bits,
5 * size of the parameter structure in the lower 14 bits of the
7 * Encoding the size of the parameter structure in the ioctl request
8 * The highest 2 bits are reserved for indicating the ``access mode''.
9 * NOTE: This limits the max parameter size to 16kB -1 !
13 * The following is for compatibility across the various Linux
14 * platforms. The i386 ioctl numbering scheme doesn't really enforce
15 * a type field. De facto, however, the top 8 bits of the lower 16
16 * bits are indeed used as a type field, so we might just as well make
17 * this explicit here. Please be sure to use the decoding macros
21 #define _IOC_TYPEBITS 8
22 #define _IOC_SIZEBITS 14
23 #define _IOC_DIRBITS 2
25 #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
26 #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
27 #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
28 #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
30 #define _IOC_NRSHIFT 0
31 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
32 #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
33 #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
42 #define _IOC(dir,type,nr,size) (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
44 /* used to create numbers */
45 #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
46 #define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
47 #define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
48 #define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
50 /* used to decode ioctl numbers.. */
51 #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
52 #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
53 #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
54 #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
56 /* ...and for the drivers/sound files... */
58 #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
59 #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
60 #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
61 #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
62 #define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
64 #endif /* _ASMI386_IOCTL_H */