GNU Linux-libre 4.14.266-gnu1
[releases.git] / arch / mn10300 / include / uapi / asm / termios.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_ASM_TERMIOS_H
3 #define _UAPI_ASM_TERMIOS_H
4
5 #include <asm/termbits.h>
6 #include <asm/ioctls.h>
7
8 struct winsize {
9         unsigned short ws_row;
10         unsigned short ws_col;
11         unsigned short ws_xpixel;
12         unsigned short ws_ypixel;
13 };
14
15 #define NCC 8
16 struct termio {
17         unsigned short c_iflag;         /* input mode flags */
18         unsigned short c_oflag;         /* output mode flags */
19         unsigned short c_cflag;         /* control mode flags */
20         unsigned short c_lflag;         /* local mode flags */
21         unsigned char c_line;           /* line discipline */
22         unsigned char c_cc[NCC];        /* control characters */
23 };
24
25
26 /* modem lines */
27 #define TIOCM_LE        0x001
28 #define TIOCM_DTR       0x002
29 #define TIOCM_RTS       0x004
30 #define TIOCM_ST        0x008
31 #define TIOCM_SR        0x010
32 #define TIOCM_CTS       0x020
33 #define TIOCM_CAR       0x040
34 #define TIOCM_RNG       0x080
35 #define TIOCM_DSR       0x100
36 #define TIOCM_CD        TIOCM_CAR
37 #define TIOCM_RI        TIOCM_RNG
38 #define TIOCM_OUT1      0x2000
39 #define TIOCM_OUT2      0x4000
40 #define TIOCM_LOOP      0x8000
41
42 #define TIOCM_MODEM_BITS       TIOCM_OUT2      /* IRDA support */
43
44 /*
45  * Translate a "termio" structure into a "termios". Ugh.
46  */
47 #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
48         unsigned short __tmp; \
49         get_user(__tmp, &(termio)->x); \
50         *(unsigned short *) &(termios)->x = __tmp; \
51 }
52
53 #define user_termio_to_kernel_termios(termios, termio) \
54 ({ \
55         SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
56         SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
57         SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
58         SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
59         copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
60 })
61
62 /*
63  * Translate a "termios" structure into a "termio". Ugh.
64  */
65 #define kernel_termios_to_user_termio(termio, termios) \
66 ({ \
67         put_user((termios)->c_iflag, &(termio)->c_iflag); \
68         put_user((termios)->c_oflag, &(termio)->c_oflag); \
69         put_user((termios)->c_cflag, &(termio)->c_cflag); \
70         put_user((termios)->c_lflag, &(termio)->c_lflag); \
71         put_user((termios)->c_line,  &(termio)->c_line); \
72         copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
73 })
74
75 #define user_termios_to_kernel_termios(k, u) \
76         copy_from_user(k, u, sizeof(struct termios2))
77 #define kernel_termios_to_user_termios(u, k) \
78         copy_to_user(u, k, sizeof(struct termios2))
79 #define user_termios_to_kernel_termios_1(k, u) \
80         copy_from_user(k, u, sizeof(struct termios))
81 #define kernel_termios_to_user_termios_1(u, k) \
82         copy_to_user(u, k, sizeof(struct termios))
83
84 #endif /* _UAPI_ASM_TERMIOS_H */