5 this is a derived version of linux headers for ulinux
7 ioctl command encoding: 32 bits total, command in lower 16 bits,
8 size of the parameter structure in the lower 14 bits of the
10 Encoding the size of the parameter structure in the ioctl request
11 is useful for catching programs compiled with old versions
12 and to avoid overwriting user space outside the user buffer area.
13 The highest 2 bits are reserved for indicating the ``access mode''.
14 NOTE: This limits the max parameter size to 16kB -1 !
16 The following is for compatibility across the various Linux
17 platforms. The generic ioctl numbering scheme doesn't really enforce
18 a type field. De facto, however, the top 8 bits of the lower 16
19 bits are indeed used as a type field, so we might just as well make
20 this explicit here. Please be sure to use the decoding macros
24 #define ULINUX_IOC_NRBITS 8
25 #define ULINUX_IOC_TYPEBITS 8
28 Let any architecture override either of the following before
32 /*XXX:can be arch dependent*/
33 #define ULINUX_IOC_SIZEBITS 14
35 /*XXX:can be arch dependent*/
36 #define ULINUX_IOC_DIRBITS 2
38 #define ULINUX_IOC_NRMASK ((1<<ULINUX_IOC_NRBITS)-1)
39 #define ULINUX_IOC_TYPEMASK ((1<<ULINUX_IOC_TYPEBITS)-1)
40 #define ULINUX_IOC_SIZEMASK ((1<<ULINUX_IOC_SIZEBITS)-1)
41 #define ULINUX_IOC_DIRMASK ((1<<ULINUX_IOC_DIRBITS)-1)
43 #define ULINUX_IOC_NRSHIFT 0
44 #define ULINUX_IOC_TYPESHIFT (ULINUX_IOC_NRSHIFT+ULINUX_IOC_NRBITS)
45 #define ULINUX_IOC_SIZESHIFT (ULINUX_IOC_TYPESHIFT+ULINUX_IOC_TYPEBITS)
46 #define ULINUX_IOC_DIRSHIFT (ULINUX_IOC_SIZESHIFT+ULINUX_IOC_SIZEBITS)
49 Direction bits, which any architecture can choose to override
50 before including this file.
53 /*XXX:can be arch dependent*/
54 #define ULINUX_IOC_NONE 0U
56 /*XXX:can be arch dependent*/
57 #define ULINUX_IOC_WRITE 1U
59 /*XXX:can be arch dependent*/
60 #define ULINUX_IOC_READ 2U
62 #define ULINUX_IOC(dir,type,nr,size) \
63 (((dir)<<ULINUX_IOC_DIRSHIFT) | \
64 ((type)<<ULINUX_IOC_TYPESHIFT) | \
65 ((nr)<<ULINUX_IOC_NRSHIFT) | \
66 ((size)<<ULINUX_IOC_SIZESHIFT))
68 #define ULINUX_IOC_TYPECHECK(t) (sizeof(t))
70 /*used to create numbers*/
71 #define ULINUX_IO(type,nr) ULINUX_IOC(ULINUX_IOC_NONE,(type),(nr),0)
72 #define ULINUX_IOR(type,nr,size)\
73 ULINUX_IOC(ULINUX_IOC_READ,(type),(nr),(ULINUX_IOC_TYPECHECK(size)))
74 #define ULINUX_IOW(type,nr,size)\
75 ULINUX_IOC(ULINUX_IOC_WRITE,(type),(nr),(ULINUX_IOC_TYPECHECK(size)))
76 #define ULINUX_IOWR(type,nr,size)\
77 ULINUX_IOC(ULINUX_IOC_READ|ULINUX_IOC_WRITE,(type),(nr),\
78 (ULINUX_IOC_TYPECHECK(size)))
79 #define ULINUX_IOR_BAD(type,nr,size) ULINUX_IOC(ULINUX_IOC_READ,(type),(nr),\
81 #define ULINUX_IOW_BAD(type,nr,size) ULINUX_IOC(ULINUX_IOC_WRITE,(type),(nr),\
83 #define ULINUX_IOWR_BAD(type,nr,size)\
84 ULINUX_IOC(ULINUX_IOC_READ|ULINUX_IOC_WRITE,(type),(nr),sizeof(size))
86 /*used to decode ioctl numbers*/
87 #define ULINUX_IOC_DIR(nr) (((nr)>>ULINUX_IOC_DIRSHIFT)&ULINUX_IOC_DIRMASK)
88 #define ULINUX_IOC_TYPE(nr) (((nr)>>ULINUX_IOC_TYPESHIFT)&ULINUX_IOC_TYPEMASK)
89 #define ULINUX_IOC_NR(nr) (((nr)>>ULINUX_IOC_NRSHIFT)&ULINUX_IOC_NRMASK)
90 #define ULINUX_IOC_SIZE(nr) (((nr)>>ULINUX_IOC_SIZESHIFT)&ULINUX_IOC_SIZEMASK)
92 /*...and for the drivers/sound files...*/
93 #define ULINUX_IOC_IN (ULINUX_IOC_WRITE<<ULINUX_IOC_DIRSHIFT)
94 #define ULINUX_IOC_OUT (ULINUX_IOC_READ<<ULINUX_IOC_DIRSHIFT)
95 #define ULINUX_IOC_INOUT ((ULINUX_IOC_WRITE|ULINUX_IOC_READ)<<\
97 #define ULINUX_IOCSIZE_MASK (ULINUX_IOC_SIZEMASK<<ULINUX_IOC_SIZESHIFT)
98 #define ULINUX_IOCSIZE_SHIFT (ULINUX_IOC_SIZESHIFT)