1 /* $Id: termios.h,v 1.32 2001/06/01 08:12:11 davem Exp $ */
2 #ifndef _SPARC_TERMIOS_H
3 #define _SPARC_TERMIOS_H
5 #include <asm/ioctls.h>
6 #include <asm/termbits.h>
8 #if defined(__KERNEL__) || defined(__DEFINE_BSD_TERMIOS)
34 #endif /* __KERNEL__ */
36 struct sunos_ttysize {
37 int st_lines; /* Lines on the terminal */
38 int st_columns; /* Columns on the terminal */
42 unsigned short ws_row;
43 unsigned short ws_col;
44 unsigned short ws_xpixel;
45 unsigned short ws_ypixel;
49 #include <linux/module.h>
52 * c_cc characters in the termio structure. Oh, how I love being
53 * backwardly compatible. Notice that character 4 and 5 are
54 * interpreted differently depending on whether ICANON is set in
55 * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
56 * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
57 * is compatible with sysV)...
63 /* intr=^C quit=^\ erase=del kill=^U
64 eof=^D eol=\0 eol2=\0 sxtc=\0
65 start=^Q stop=^S susp=^Z dsusp=^Y
66 reprint=^R discard=^U werase=^W lnext=^V
69 #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001"
72 * Translate a "termio" structure into a "termios". Ugh.
74 #define user_termio_to_kernel_termios(termios, termio) \
77 get_user(tmp, &(termio)->c_iflag); \
78 (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
79 get_user(tmp, &(termio)->c_oflag); \
80 (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
81 get_user(tmp, &(termio)->c_cflag); \
82 (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
83 get_user(tmp, &(termio)->c_lflag); \
84 (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
85 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
90 * Translate a "termios" structure into a "termio". Ugh.
92 * Note the "fun" _VMIN overloading.
94 #define kernel_termios_to_user_termio(termio, termios) \
96 put_user((termios)->c_iflag, &(termio)->c_iflag); \
97 put_user((termios)->c_oflag, &(termio)->c_oflag); \
98 put_user((termios)->c_cflag, &(termio)->c_cflag); \
99 put_user((termios)->c_lflag, &(termio)->c_lflag); \
100 put_user((termios)->c_line, &(termio)->c_line); \
101 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
102 if (!((termios)->c_lflag & ICANON)) { \
103 put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
104 put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
109 #define user_termios_to_kernel_termios(k, u) \
112 err = get_user((k)->c_iflag, &(u)->c_iflag); \
113 err |= get_user((k)->c_oflag, &(u)->c_oflag); \
114 err |= get_user((k)->c_cflag, &(u)->c_cflag); \
115 err |= get_user((k)->c_lflag, &(u)->c_lflag); \
116 err |= get_user((k)->c_line, &(u)->c_line); \
117 err |= copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
118 if ((k)->c_lflag & ICANON) { \
119 err |= get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
120 err |= get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
122 err |= get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
123 err |= get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
125 err |= get_user((k)->c_ispeed, &(u)->c_ispeed); \
126 err |= get_user((k)->c_ospeed, &(u)->c_ospeed); \
130 #define kernel_termios_to_user_termios(u, k) \
133 err = put_user((k)->c_iflag, &(u)->c_iflag); \
134 err |= put_user((k)->c_oflag, &(u)->c_oflag); \
135 err |= put_user((k)->c_cflag, &(u)->c_cflag); \
136 err |= put_user((k)->c_lflag, &(u)->c_lflag); \
137 err |= put_user((k)->c_line, &(u)->c_line); \
138 err |= copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
139 if (!((k)->c_lflag & ICANON)) { \
140 err |= put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
141 err |= put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
143 err |= put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
144 err |= put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
146 err |= put_user((k)->c_ispeed, &(u)->c_ispeed); \
147 err |= put_user((k)->c_ospeed, &(u)->c_ospeed); \
151 #define user_termios_to_kernel_termios_1(k, u) \
153 get_user((k)->c_iflag, &(u)->c_iflag); \
154 get_user((k)->c_oflag, &(u)->c_oflag); \
155 get_user((k)->c_cflag, &(u)->c_cflag); \
156 get_user((k)->c_lflag, &(u)->c_lflag); \
157 get_user((k)->c_line, &(u)->c_line); \
158 copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
159 if ((k)->c_lflag & ICANON) { \
160 get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
161 get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
163 get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
164 get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
169 #define kernel_termios_to_user_termios_1(u, k) \
171 put_user((k)->c_iflag, &(u)->c_iflag); \
172 put_user((k)->c_oflag, &(u)->c_oflag); \
173 put_user((k)->c_cflag, &(u)->c_cflag); \
174 put_user((k)->c_lflag, &(u)->c_lflag); \
175 put_user((k)->c_line, &(u)->c_line); \
176 copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
177 if (!((k)->c_lflag & ICANON)) { \
178 put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
179 put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
181 put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
182 put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
187 #endif /* __KERNEL__ */
189 #endif /* _SPARC_TERMIOS_H */