1
2
3
4
5
6 #ifndef _LINUX_IOCTL_H
7 #define _LINUX_IOCTL_H
8
9
10
11
12
13
14
15
16
17
18
19
20 #define IOC_VOID 0x00000000
21 #define IOC_IN 0x40000000
22 #define IOC_OUT 0x80000000
23 #define IOC_INOUT (IOC_IN | IOC_OUT)
24 #define IOCSIZE_MASK 0x3fff0000
25 #define IOCSIZE_SHIFT 16
26 #define IOCSIZE_MAX ((PAGE_SIZE-1)&(IOCSIZE_MASK >> IOC_SHIFT))
27 #define IOCCMD_MASK 0x0000ffff
28 #define IOCCMD_SHIFT 0
29 #define IOCPARM_MASK IOCCMD_MASK
30 #define IOCPARM_SHIFT IOCCMD_SHIFT
31
32 #define IOC_SIZE(cmd) (((cmd) & IOCSIZE_MASK) >> IOCSIZE_SHIFT)
33 #define IOCBASECMD(cmd) ((cmd) & ~IOCPARM_MASK)
34 #define IOCGROUP(cmd) (((cmd) >> 8) & 0xFF)
35
36 #ifndef _IO
37
38
39
40 #define _IO(c,d) (IOC_VOID | ((c)<<8) | (d))
41 #endif
42
43 #ifndef _IOW
44
45
46
47 #define _IOW(c,d,t) (IOC_IN | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
48 ((c)<<8) | (d))
49 #define _IOR(c,d,t) (IOC_OUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
50 ((c)<<8) | (d))
51
52 #define _IOWR(c,d,t) (IOC_INOUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
53 ((c)<<8) | (d))
54 #endif
55
56 #endif
57