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__ */
37 unsigned short ws_row
;
38 unsigned short ws_col
;
39 unsigned short ws_xpixel
;
40 unsigned short ws_ypixel
;
44 #include <linux/module.h>
47 * c_cc characters in the termio structure. Oh, how I love being
48 * backwardly compatible. Notice that character 4 and 5 are
49 * interpreted differently depending on whether ICANON is set in
50 * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
51 * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
52 * is compatible with sysV)...
58 /* intr=^C quit=^\ erase=del kill=^U
59 eof=^D eol=\0 eol2=\0 sxtc=\0
60 start=^Q stop=^S susp=^Z dsusp=^Y
61 reprint=^R discard=^U werase=^W lnext=^V
64 #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001"
67 * Translate a "termio" structure into a "termios". Ugh.
69 #define user_termio_to_kernel_termios(termios, termio) \
72 get_user(tmp, &(termio)->c_iflag); \
73 (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
74 get_user(tmp, &(termio)->c_oflag); \
75 (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
76 get_user(tmp, &(termio)->c_cflag); \
77 (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
78 get_user(tmp, &(termio)->c_lflag); \
79 (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
80 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
85 * Translate a "termios" structure into a "termio". Ugh.
87 * Note the "fun" _VMIN overloading.
89 #define kernel_termios_to_user_termio(termio, termios) \
91 put_user((termios)->c_iflag, &(termio)->c_iflag); \
92 put_user((termios)->c_oflag, &(termio)->c_oflag); \
93 put_user((termios)->c_cflag, &(termio)->c_cflag); \
94 put_user((termios)->c_lflag, &(termio)->c_lflag); \
95 put_user((termios)->c_line, &(termio)->c_line); \
96 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
97 if (!((termios)->c_lflag & ICANON)) { \
98 put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
99 put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
104 #define user_termios_to_kernel_termios(k, u) \
107 err = get_user((k)->c_iflag, &(u)->c_iflag); \
108 err |= get_user((k)->c_oflag, &(u)->c_oflag); \
109 err |= get_user((k)->c_cflag, &(u)->c_cflag); \
110 err |= get_user((k)->c_lflag, &(u)->c_lflag); \
111 err |= get_user((k)->c_line, &(u)->c_line); \
112 err |= copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
113 if ((k)->c_lflag & ICANON) { \
114 err |= get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
115 err |= get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
117 err |= get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
118 err |= get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
120 err |= get_user((k)->c_ispeed, &(u)->c_ispeed); \
121 err |= get_user((k)->c_ospeed, &(u)->c_ospeed); \
125 #define kernel_termios_to_user_termios(u, k) \
128 err = put_user((k)->c_iflag, &(u)->c_iflag); \
129 err |= put_user((k)->c_oflag, &(u)->c_oflag); \
130 err |= put_user((k)->c_cflag, &(u)->c_cflag); \
131 err |= put_user((k)->c_lflag, &(u)->c_lflag); \
132 err |= put_user((k)->c_line, &(u)->c_line); \
133 err |= copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
134 if (!((k)->c_lflag & ICANON)) { \
135 err |= put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
136 err |= put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
138 err |= put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
139 err |= put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
141 err |= put_user((k)->c_ispeed, &(u)->c_ispeed); \
142 err |= put_user((k)->c_ospeed, &(u)->c_ospeed); \
146 #define user_termios_to_kernel_termios_1(k, u) \
148 get_user((k)->c_iflag, &(u)->c_iflag); \
149 get_user((k)->c_oflag, &(u)->c_oflag); \
150 get_user((k)->c_cflag, &(u)->c_cflag); \
151 get_user((k)->c_lflag, &(u)->c_lflag); \
152 get_user((k)->c_line, &(u)->c_line); \
153 copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
154 if ((k)->c_lflag & ICANON) { \
155 get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
156 get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
158 get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
159 get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
164 #define kernel_termios_to_user_termios_1(u, k) \
166 put_user((k)->c_iflag, &(u)->c_iflag); \
167 put_user((k)->c_oflag, &(u)->c_oflag); \
168 put_user((k)->c_cflag, &(u)->c_cflag); \
169 put_user((k)->c_lflag, &(u)->c_lflag); \
170 put_user((k)->c_line, &(u)->c_line); \
171 copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
172 if (!((k)->c_lflag & ICANON)) { \
173 put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
174 put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
176 put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
177 put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
182 #endif /* __KERNEL__ */
184 #endif /* _SPARC_TERMIOS_H */