wut  v1.7.0
Wii U Toolchain
ioccom.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4  * Ioctl's have the command encoded in the lower word, and the size of
5  * any in or out parameters in the upper word. The high 3 bits of the
6  * upper word are used to encode the in/out status of the parameter.
7  */
8 #define IOCPARM_SHIFT 13 /* number of bits for ioctl size */
9 #define IOCPARM_MASK ((1 << IOCPARM_SHIFT) - 1) /* parameter length mask */
10 #define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
11 #define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
12 #define IOCGROUP(x) (((x) >> 8) & 0xff)
13 
14 #define IOCPARM_MAX (1 << IOCPARM_SHIFT) /* max size of ioctl */
15 #define IOC_VOID 0x20000000 /* no parameters */
16 #define IOC_OUT 0x40000000 /* copy out parameters */
17 #define IOC_IN 0x80000000 /* copy in parameters */
18 #define IOC_INOUT (IOC_IN|IOC_OUT)
19 #define IOC_DIRMASK (IOC_VOID|IOC_OUT|IOC_IN)
20 
21 #define _IOC(inout,group,num,len) ((int) \
22  ((inout) | (((len) & IOCPARM_MASK) << 16) | ((group) << 8) | (num)))
23 #define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
24 #define _IOWINT(g,n) _IOC(IOC_VOID, (g), (n), sizeof(int))
25 #define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
26 #define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
27 /* this should be _IORW, but stdio got there first */
28 #define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 int ioctl(int fd,
35  int request,
36  ...);
37 
38 #ifdef __cplusplus
39 }
40 #endif
int ioctl(int fd, int request,...)