UbixOS V2  2.0
ioctl.h
Go to the documentation of this file.
1 /*
2  * Ioctl's have the command encoded in the lower word, and the size of
3  * any in or out parameters in the upper word. The high 3 bits of the
4  * upper word are used to encode the in/out status of the parameter.
5  */
6 #define IOCPARM_SHIFT 13 /* number of bits for ioctl size */
7 #define IOCPARM_MASK ((1 << IOCPARM_SHIFT) - 1) /* parameter length mask */
8 #define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
9 #define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
10 #define IOCGROUP(x) (((x) >> 8) & 0xff)
11 
12 #define IOCPARM_MAX (1 << IOCPARM_SHIFT) /* max size of ioctl */
13 #define IOC_VOID 0x20000000 /* no parameters */
14 #define IOC_OUT 0x40000000 /* copy out parameters */
15 #define IOC_IN 0x80000000 /* copy in parameters */
16 #define IOC_INOUT (IOC_IN|IOC_OUT)
17 #define IOC_DIRMASK (IOC_VOID|IOC_OUT|IOC_IN)
18 
19 #define _IOC(inout,group,num,len) ((unsigned long) \
20  ((inout) | (((len) & IOCPARM_MASK) << 16) | ((group) << 8) | (num)))
21 #define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
22 #define _IOWINT(g,n) _IOC(IOC_VOID, (g), (n), sizeof(int))
23 #define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
24 #define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
25 /* this should be _IORW, but stdio got there first */
26 #define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
27 
28 #define IOCPARM_IVAL(x) ((int)(intptr_t)(void *)*(caddr_t *)(void *)(x))
29 
30 #define NCCS 20
31 
32 typedef unsigned int tcflag_t;
33 typedef unsigned char cc_t;
34 typedef unsigned int speed_t;
35 
36 struct termios {
37  tcflag_t c_iflag; /* input flags */
38  tcflag_t c_oflag; /* output flags */
39  tcflag_t c_cflag; /* control flags */
40  tcflag_t c_lflag; /* local flags */
41  cc_t c_cc[NCCS]; /* control chars */
42  speed_t c_ispeed; /* input speed */
43  speed_t c_ospeed; /* output speed */
44 };
45 
46 struct winsize {
47  unsigned short ws_row; /* rows, in characters */
48  unsigned short ws_col; /* columns, in characters */
49  unsigned short ws_xpixel; /* horizontal size, pixels */
50  unsigned short ws_ypixel; /* vertical size, pixels */
51 };
52 
53 #define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */
54 #define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
winsize::ws_ypixel
unsigned short ws_ypixel
Definition: ioctl.h:50
termios::c_ispeed
speed_t c_ispeed
Definition: ioctl.h:42
speed_t
unsigned int speed_t
Definition: ioctl.h:34
winsize::ws_col
unsigned short ws_col
Definition: ioctl.h:48
winsize
Definition: ioctl.h:46
termios::c_ospeed
speed_t c_ospeed
Definition: ioctl.h:43
termios
Definition: ioctl.h:36
winsize::ws_row
unsigned short ws_row
Definition: ioctl.h:47
tcflag_t
unsigned int tcflag_t
Definition: ioctl.h:32
termios::c_cc
cc_t c_cc[20]
Definition: ioctl.h:41
termios::c_iflag
tcflag_t c_iflag
Definition: ioctl.h:37
NCCS
#define NCCS
Definition: ioctl.h:30
termios::c_oflag
tcflag_t c_oflag
Definition: ioctl.h:38
winsize::ws_xpixel
unsigned short ws_xpixel
Definition: ioctl.h:49
termios::c_cflag
tcflag_t c_cflag
Definition: ioctl.h:39
cc_t
unsigned char cc_t
Definition: ioctl.h:33
termios::c_lflag
tcflag_t c_lflag
Definition: ioctl.h:40