1
2
3
4
5
6 #ifndef _ASMI386_IOCTL_H
7 #define _ASMI386_IOCTL_H
8
9 #include <asm/page.h>
10
11
12
13
14
15
16
17
18
19
20
21 #define IOC_VOID 0x00000000
22 #define IOC_IN 0x40000000
23 #define IOC_OUT 0x80000000
24 #define IOC_INOUT (IOC_IN | IOC_OUT)
25 #define IOCSIZE_MASK 0x3fff0000
26 #define IOCSIZE_SHIFT 16
27 #define IOCSIZE_MAX ((PAGE_SIZE-1)&(IOCSIZE_MASK >> IOCSIZE_SHIFT))
28 #define IOCCMD_MASK 0x0000ffff
29 #define IOCCMD_SHIFT 0
30 #define IOCPARM_MASK IOCCMD_MASK
31 #define IOCPARM_SHIFT IOCCMD_SHIFT
32
33 #define IOC_SIZE(cmd) (((cmd) & IOCSIZE_MASK) >> IOCSIZE_SHIFT)
34 #define IOCBASECMD(cmd) ((cmd) & ~IOCPARM_MASK)
35 #define IOCGROUP(cmd) (((cmd) >> 8) & 0xFF)
36
37
38
39
40 #define _IO(c,d) (IOC_VOID | ((c)<<8) | (d))
41
42
43
44
45 #define _IOW(c,d,t) (IOC_IN | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
46 ((c)<<8) | (d))
47 #define _IOR(c,d,t) (IOC_OUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
48 ((c)<<8) | (d))
49
50 #define _IOWR(c,d,t) (IOC_INOUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
51 ((c)<<8) | (d))
52
53
54
55
56
57
58
59
60
61 #define _IOC_NRBITS 8
62 #define _IOC_TYPEBITS 8
63 #define _IOC_SIZEBITS 14
64 #define _IOC_DIRBITS 2
65
66 #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
67 #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
68 #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
69 #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
70
71 #define _IOC_NRSHIFT 0
72 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
73 #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
74 #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
75
76
77
78
79 #define _IOC_NONE 0U
80 #define _IOC_READ 1U
81 #define _IOC_WRITE 2U
82
83
84 #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
85 #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
86 #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
87 #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
88
89 #endif