1 /* $NetBSD: linux_termios.h,v 1.18 2008/06/28 21:34:32 chris Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Eric Haszlakiewicz.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _LINUX_TERMIOS_H
33 #define _LINUX_TERMIOS_H
34
35 #if defined(__i386__)
36 #include <compat/linux/arch/i386/linux_termios.h>
37 #elif defined(__m68k__)
38 #include <compat/linux/arch/m68k/linux_termios.h>
39 #elif defined(__alpha__)
40 #include <compat/linux/arch/alpha/linux_termios.h>
41 #elif defined(__powerpc__)
42 #include <compat/linux/arch/powerpc/linux_termios.h>
43 #elif defined(__mips__)
44 #include <compat/linux/arch/mips/linux_termios.h>
45 #elif defined(__arm__)
46 #include <compat/linux/arch/arm/linux_termios.h>
47 #elif defined(__amd64__)
48 #include <compat/linux/arch/amd64/linux_termios.h>
49 #else
50 #error Undefined linux_termios.h machine type.
51 #endif
52
53 struct linux_winsize {
54 unsigned short ws_row;
55 unsigned short ws_col;
56 unsigned short ws_xpixel;
57 unsigned short ws_ypixel;
58 };
59
60 /*
61 * LINUX_NCC is architecture dependent. It is now
62 * defined in sys/compat/linux/<arch>/linux_termios.h
63 */
64 struct linux_termio {
65 unsigned short c_iflag;
66 unsigned short c_oflag;
67 unsigned short c_cflag;
68 unsigned short c_lflag;
69 unsigned char c_line;
70 unsigned char c_cc[LINUX_NCC];
71 };
72
73 struct linux_termios {
74 linux_tcflag_t c_iflag;
75 linux_tcflag_t c_oflag;
76 linux_tcflag_t c_cflag;
77 linux_tcflag_t c_lflag;
78 linux_cc_t c_line;
79 linux_cc_t c_cc[LINUX_NCCS];
80 #ifdef LINUX_LARGE_STRUCT_TERMIOS
81 /*
82 * Present on some linux ports but unused:
83 * However we must enable it, else it breaks ioctl
84 * definitions (the size does not match anymore)
85 */
86 linux_speed_t c_ispeed;
87 linux_speed_t c_ospeed;
88 #endif
89 };
90
91 /* Linux modem line defines.. not sure if they'll be used */
92 #define LINUX_TIOCM_LE 0x0001
93 #define LINUX_TIOCM_DTR 0x0002
94 #define LINUX_TIOCM_RTS 0x0004
95 #define LINUX_TIOCM_ST 0x0008
96 #define LINUX_TIOCM_SR 0x0010
97 #define LINUX_TIOCM_CTS 0x0020
98 #define LINUX_TIOCM_CAR 0x0040
99 #define LINUX_TIOCM_RNG 0x0080
100 #define LINUX_TIOCM_DSR 0x0100
101 #define LINUX_TIOCM_CD LINUX_TIOCM_CAR
102 #define LINUX_TIOCM_RI LINUX_TIOCM_RNG
103
104 #define LINUX_TCIFLUSH 0
105 #define LINUX_TCOFLUSH 1
106 #define LINUX_TCIOFLUSH 2
107
108 #define LINUX_TCOOFF 0
109 #define LINUX_TCOON 1
110 #define LINUX_TCIOFF 2
111 #define LINUX_TCION 3
112
113 #define LINUX_TCSANOW 0
114 #define LINUX_TCSADRAIN 1
115 #define LINUX_TCSAFLUSH 2
116
117 /* Linux line disciplines */
118 #define LINUX_N_TTY 0
119 #define LINUX_N_SLIP 1
120 #define LINUX_N_MOUSE 2
121 #define LINUX_N_PPP 3
122 #define LINUX_N_STRIP 4
123
124 /* currently unused: */
125 #define LINUX_N_AX25 5
126 #define LINUX_N_X25 6
127 #define LINUX_N_6PACK 7
128
129 /* values passed to TIOCLINUX ioctl */
130 #define LINUX_TIOCLINUX_COPY 2
131 #define LINUX_TIOCLINUX_PASTE 3
132 #define LINUX_TIOCLINUX_UNBLANK 4
133 #define LINUX_TIOCLINUX_LOADLUT 5
134 #define LINUX_TIOCLINUX_READSHIFT 6
135 #define LINUX_TIOCLINUX_READMOUSE 7
136 #define LINUX_TIOCLINUX_VESABLANK 10
137 #define LINUX_TIOCLINUX_KERNMSG 11
138 #define LINUX_TIOCLINUX_CURCONS 12
139
140 static linux_speed_t linux_speeds[] = {
141 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
142 9600, 19200, 38400, 57600, 115200, 230400
143 };
144
145 static const int linux_spmasks[] = {
146 LINUX_B0, LINUX_B50, LINUX_B75, LINUX_B110, LINUX_B134, LINUX_B150,
147 LINUX_B200, LINUX_B300, LINUX_B600, LINUX_B1200, LINUX_B1800,
148 LINUX_B2400, LINUX_B4800, LINUX_B9600, LINUX_B19200, LINUX_B38400,
149 LINUX_B57600, LINUX_B115200, LINUX_B230400
150 };
151
152 #ifdef COMPAT_LINUX32
153 struct linux32_termio;
154 struct linux32_termios;
155 static void linux32_termio_to_bsd_termios(struct linux32_termio *,
156 struct termios *);
157 static void bsd_termios_to_linux32_termio(struct termios *,
158 struct linux32_termio *);
159 static void linux32_termios_to_bsd_termios(struct linux32_termios *,
160 struct termios *);
161 static void bsd_termios_to_linux32_termios(struct termios *,
162 struct linux32_termios *);
163 #else
164 struct linux_termio;
165 struct linux_termios;
166 static void linux_termio_to_bsd_termios(struct linux_termio *,
167 struct termios *);
168 static void bsd_termios_to_linux_termio(struct termios *,
169 struct linux_termio *);
170 static void linux_termios_to_bsd_termios(struct linux_termios *,
171 struct termios *);
172 static void bsd_termios_to_linux_termios(struct termios *,
173 struct linux_termios *);
174 #endif
175
176 /*
177 * Deal with termio ioctl cruft. This doesn't look very good..
178 * XXX too much code duplication, obviously..
179 *
180 * The conversion routines between Linux and BSD structures assume
181 * that the fields are already filled with the current values,
182 * so that fields present in BSD but not in Linux keep their current
183 * values.
184 */
185
186 static void
187 #ifdef COMPAT_LINUX32
188 linux32_termio_to_bsd_termios(lt, bts)
189 struct linux32_termio *lt;
190 struct termios *bts;
191 #else
192 linux_termio_to_bsd_termios(lt, bts)
193 struct linux_termio *lt;
194 struct termios *bts;
195 #endif
196 {
197 int index;
198
199 bts->c_iflag = 0;
200 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNBRK, IGNBRK);
201 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_BRKINT, BRKINT);
202 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNPAR, IGNPAR);
203 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_INPCK, INPCK);
204 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_ISTRIP, ISTRIP);
205 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_INLCR, INLCR);
206 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNCR, IGNCR);
207 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_ICRNL, ICRNL);
208 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXON, IXON);
209 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXANY, IXANY);
210 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXOFF, IXOFF);
211 bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IMAXBEL, IMAXBEL);
212
213 bts->c_oflag = 0;
214 bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_OPOST, OPOST);
215 bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_ONLCR, ONLCR);
216 bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_XTABS, OXTABS);
217
218 /*
219 * This could have been:
220 * bts->c_cflag = (lt->c_flag & LINUX_CSIZE) << 4
221 * But who knows, those values might perhaps change one day.
222 */
223 switch (lt->c_cflag & LINUX_CSIZE) {
224 case LINUX_CS5:
225 bts->c_cflag = CS5;
226 break;
227 case LINUX_CS6:
228 bts->c_cflag = CS6;
229 break;
230 case LINUX_CS7:
231 bts->c_cflag = CS7;
232 break;
233 case LINUX_CS8:
234 bts->c_cflag = CS8;
235 break;
236 }
237 bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CSTOPB, CSTOPB);
238 bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CREAD, CREAD);
239 bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_PARENB, PARENB);
240 bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_PARODD, PARODD);
241 bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_HUPCL, HUPCL);
242 bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CLOCAL, CLOCAL);
243 bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CRTSCTS, CRTSCTS);
244
245 bts->c_lflag = 0;
246 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ISIG, ISIG);
247 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ICANON, ICANON);
248 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHO, ECHO);
249 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOE, ECHOE);
250 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOK, ECHOK);
251 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHONL, ECHONL);
252 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_NOFLSH, NOFLSH);
253 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_TOSTOP, TOSTOP);
254 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOCTL, ECHOCTL);
255 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOPRT, ECHOPRT);
256 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOKE, ECHOKE);
257 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_FLUSHO, FLUSHO);
258 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_PENDIN, PENDIN);
259 bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_IEXTEN, IEXTEN);
260
261 index = lt->c_cflag & LINUX_CBAUD;
262 if (index & LINUX_CBAUDEX)
263 index = (index & ~LINUX_CBAUDEX) + LINUX_NSPEEDS - 1;
264 bts->c_ispeed = bts->c_ospeed = linux_speeds[index];
265
266 bts->c_cc[VINTR] = lt->c_cc[LINUX_OLD_VINTR];
267 bts->c_cc[VQUIT] = lt->c_cc[LINUX_OLD_VQUIT];
268 bts->c_cc[VERASE] = lt->c_cc[LINUX_OLD_VERASE];
269 bts->c_cc[VKILL] = lt->c_cc[LINUX_OLD_VKILL];
270 bts->c_cc[VEOF] = lt->c_cc[LINUX_OLD_VEOF];
271 bts->c_cc[VTIME] = lt->c_cc[LINUX_OLD_VTIME];
272 bts->c_cc[VMIN] = lt->c_cc[LINUX_OLD_VMIN];
273 }
274
275 static void
276 #ifdef COMPAT_LINUX32
277 bsd_termios_to_linux32_termio(bts, lt)
278 struct termios *bts;
279 struct linux32_termio *lt;
280 #else
281 bsd_termios_to_linux_termio(bts, lt)
282 struct termios *bts;
283 struct linux_termio *lt;
284 #endif
285 {
286 int i, mask;
287
288 lt->c_iflag = 0;
289 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
290 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);
291 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNPAR, LINUX_IGNPAR);
292 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, INPCK, LINUX_INPCK);
293 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, ISTRIP, LINUX_ISTRIP);
294 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, INLCR, LINUX_INLCR);
295 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNCR, LINUX_IGNCR);
296 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, ICRNL, LINUX_ICRNL);
297 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXON, LINUX_IXON);
298 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXANY, LINUX_IXANY);
299 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXOFF, LINUX_IXOFF);
300 lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IMAXBEL, LINUX_IMAXBEL);
301
302 lt->c_oflag = 0;
303 lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, OPOST, LINUX_OPOST);
304 lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, ONLCR, LINUX_ONLCR);
305 lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, OXTABS, LINUX_XTABS);
306
307 switch (bts->c_cflag & CSIZE) {
308 case CS5:
309 lt->c_cflag = LINUX_CS5;
310 break;
311 case CS6:
312 lt->c_cflag = LINUX_CS6;
313 break;
314 case CS7:
315 lt->c_cflag = LINUX_CS7;
316 break;
317 case CS8:
318 lt->c_cflag = LINUX_CS8;
319 break;
320 }
321 lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CSTOPB, LINUX_CSTOPB);
322 lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CREAD, LINUX_CREAD);
323 lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARENB, LINUX_PARENB);
324 lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARODD, LINUX_PARODD);
325 lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, HUPCL, LINUX_HUPCL);
326 lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CLOCAL, LINUX_CLOCAL);
327 lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CRTSCTS, LINUX_CRTSCTS);
328
329 lt->c_lflag = 0;
330 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ISIG, LINUX_ISIG);
331 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ICANON, LINUX_ICANON);
332 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHO, LINUX_ECHO);
333 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOE, LINUX_ECHOE);
334 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOK, LINUX_ECHOK);
335 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHONL, LINUX_ECHONL);
336 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, NOFLSH, LINUX_NOFLSH);
337 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, TOSTOP, LINUX_TOSTOP);
338 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOCTL, LINUX_ECHOCTL);
339 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOPRT, LINUX_ECHOPRT);
340 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOKE, LINUX_ECHOKE);
341 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, FLUSHO, LINUX_FLUSHO);
342 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, PENDIN, LINUX_PENDIN);
343 lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, IEXTEN, LINUX_IEXTEN);
344
345 mask = LINUX_B9600; /* XXX default value should this be 0? */
346 for (i = 0; i < sizeof (linux_speeds) / sizeof (linux_speed_t); i++) {
347 if (bts->c_ospeed == linux_speeds[i]) {
348 mask = linux_spmasks[i];
349 break;
350 }
351 }
352 lt->c_cflag |= mask;
353
354 lt->c_cc[LINUX_VINTR] = bts->c_cc[VINTR];
355 lt->c_cc[LINUX_VQUIT] = bts->c_cc[VQUIT];
356 lt->c_cc[LINUX_VERASE] = bts->c_cc[VERASE];
357 lt->c_cc[LINUX_VKILL] = bts->c_cc[VKILL];
358 lt->c_cc[LINUX_VEOF] = bts->c_cc[VEOF];
359 lt->c_cc[LINUX_VTIME] = bts->c_cc[VTIME];
360 lt->c_cc[LINUX_VMIN] = bts->c_cc[VMIN];
361 lt->c_cc[LINUX_VSWTC] = 0;
362
363 /* XXX should be fixed someday */
364 lt->c_line = 0;
365 }
366
367 static void
368 #ifdef COMPAT_LINUX32
369 linux32_termios_to_bsd_termios(lts, bts)
370 struct linux32_termios *lts;
371 struct termios *bts;
372 #else
373 linux_termios_to_bsd_termios(lts, bts)
374 struct linux_termios *lts;
375 struct termios *bts;
376 #endif
377 {
378 int index;
379
380 bts->c_iflag = 0;
381 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNBRK, IGNBRK);
382 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_BRKINT, BRKINT);
383 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNPAR, IGNPAR);
384 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_INPCK, INPCK);
385 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_ISTRIP, ISTRIP);
386 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_INLCR, INLCR);
387 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNCR, IGNCR);
388 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_ICRNL, ICRNL);
389 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXON, IXON);
390 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXANY, IXANY);
391 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXOFF, IXOFF);
392 bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IMAXBEL, IMAXBEL);
393
394 bts->c_oflag = 0;
395 bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_OPOST, OPOST);
396 bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_ONLCR, ONLCR);
397 bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_XTABS, OXTABS);
398
399 bts->c_cflag = 0;
400 switch (lts->c_cflag & LINUX_CSIZE) {
401 case LINUX_CS5:
402 bts->c_cflag = CS5;
403 break;
404 case LINUX_CS6:
405 bts->c_cflag = CS6;
406 break;
407 case LINUX_CS7:
408 bts->c_cflag = CS7;
409 break;
410 case LINUX_CS8:
411 bts->c_cflag = CS8;
412 break;
413 }
414 bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CSTOPB, CSTOPB);
415 bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CREAD, CREAD);
416 bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_PARENB, PARENB);
417 bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_PARODD, PARODD);
418 bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_HUPCL, HUPCL);
419 bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CLOCAL, CLOCAL);
420 bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CRTSCTS, CRTSCTS);
421
422 bts->c_lflag = 0;
423 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ISIG, ISIG);
424 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ICANON, ICANON);
425 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHO, ECHO);
426 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOE, ECHOE);
427 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOK, ECHOK);
428 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHONL, ECHONL);
429 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_NOFLSH, NOFLSH);
430 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_TOSTOP, TOSTOP);
431 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOCTL, ECHOCTL);
432 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOPRT, ECHOPRT);
433 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOKE, ECHOKE);
434 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_FLUSHO, FLUSHO);
435 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_PENDIN, PENDIN);
436 bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_IEXTEN, IEXTEN);
437
438 index = lts->c_cflag & LINUX_CBAUD;
439 if (index & LINUX_CBAUDEX)
440 index = (index & ~LINUX_CBAUDEX) + LINUX_NSPEEDS - 1;
441 bts->c_ispeed = bts->c_ospeed = linux_speeds[index];
442 /*
443 * A null c_ospeed causes NetBSD to hangup the terminal.
444 * Linux does not do this, and it sets c_ospeed to zero
445 * sometimes. If it is null, we store -1 in the kernel
446 */
447 if (bts->c_ospeed == 0)
448 bts->c_ospeed = -1;
449
450 bts->c_cc[VINTR] = lts->c_cc[LINUX_VINTR];
451 bts->c_cc[VQUIT] = lts->c_cc[LINUX_VQUIT];
452 bts->c_cc[VERASE] = lts->c_cc[LINUX_VERASE];
453 bts->c_cc[VKILL] = lts->c_cc[LINUX_VKILL];
454 bts->c_cc[VEOF] = lts->c_cc[LINUX_VEOF];
455 bts->c_cc[VTIME] = lts->c_cc[LINUX_VTIME];
456 bts->c_cc[VMIN] = lts->c_cc[LINUX_VMIN];
457 bts->c_cc[VEOL] = lts->c_cc[LINUX_VEOL];
458 bts->c_cc[VEOL2] = lts->c_cc[LINUX_VEOL2];
459 bts->c_cc[VWERASE] = lts->c_cc[LINUX_VWERASE];
460 bts->c_cc[VSUSP] = lts->c_cc[LINUX_VSUSP];
461 bts->c_cc[VSTART] = lts->c_cc[LINUX_VSTART];
462 bts->c_cc[VSTOP] = lts->c_cc[LINUX_VSTOP];
463 bts->c_cc[VLNEXT] = lts->c_cc[LINUX_VLNEXT];
464 bts->c_cc[VDISCARD] = lts->c_cc[LINUX_VDISCARD];
465 bts->c_cc[VREPRINT] = lts->c_cc[LINUX_VREPRINT];
466 }
467
468 static void
469 #ifdef COMPAT_LINUX32
470 bsd_termios_to_linux32_termios(bts, lts)
471 struct termios *bts;
472 struct linux32_termios *lts;
473 #else
474 bsd_termios_to_linux_termios(bts, lts)
475 struct termios *bts;
476 struct linux_termios *lts;
477 #endif
478 {
479 int i, mask;
480
481 lts->c_iflag = 0;
482 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
483 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);
484 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNPAR, LINUX_IGNPAR);
485 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, INPCK, LINUX_INPCK);
486 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, ISTRIP, LINUX_ISTRIP);
487 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, INLCR, LINUX_INLCR);
488 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNCR, LINUX_IGNCR);
489 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, ICRNL, LINUX_ICRNL);
490 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXON, LINUX_IXON);
491 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXANY, LINUX_IXANY);
492 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXOFF, LINUX_IXOFF);
493 lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IMAXBEL, LINUX_IMAXBEL);
494
495 lts->c_oflag = 0;
496 lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, OPOST, LINUX_OPOST);
497 lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, ONLCR, LINUX_ONLCR);
498 lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, OXTABS, LINUX_XTABS);
499
500 switch (bts->c_cflag & CSIZE) {
501 case CS5:
502 lts->c_cflag = LINUX_CS5;
503 break;
504 case CS6:
505 lts->c_cflag = LINUX_CS6;
506 break;
507 case CS7:
508 lts->c_cflag = LINUX_CS7;
509 break;
510 case CS8:
511 lts->c_cflag = LINUX_CS8;
512 break;
513 }
514 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS5, LINUX_CS5);
515 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS6, LINUX_CS6);
516 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS7, LINUX_CS7);
517 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS8, LINUX_CS8);
518 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CSTOPB, LINUX_CSTOPB);
519 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CREAD, LINUX_CREAD);
520 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARENB, LINUX_PARENB);
521 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARODD, LINUX_PARODD);
522 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, HUPCL, LINUX_HUPCL);
523 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CLOCAL, LINUX_CLOCAL);
524 lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CRTSCTS, LINUX_CRTSCTS);
525
526 lts->c_lflag = 0;
527 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ISIG, LINUX_ISIG);
528 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ICANON, LINUX_ICANON);
529 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHO, LINUX_ECHO);
530 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOE, LINUX_ECHOE);
531 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOK, LINUX_ECHOK);
532 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHONL, LINUX_ECHONL);
533 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, NOFLSH, LINUX_NOFLSH);
534 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, TOSTOP, LINUX_TOSTOP);
535 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOCTL, LINUX_ECHOCTL);
536 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOPRT, LINUX_ECHOPRT);
537 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOKE, LINUX_ECHOKE);
538 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, FLUSHO, LINUX_FLUSHO);
539 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, PENDIN, LINUX_PENDIN);
540 lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, IEXTEN, LINUX_IEXTEN);
541
542 mask = LINUX_B9600; /* XXX default value */
543 for (i = 0; i < sizeof (linux_speeds) / sizeof (linux_speed_t); i++) {
544 if (bts->c_ospeed == linux_speeds[i]) {
545 mask = linux_spmasks[i];
546 break;
547 }
548 }
549 /*
550 * A null c_ospeed causes NetBSD to hangup the terminal.
551 * Linux does not do this, and it sets c_ospeed to zero
552 * sometimes. If it is null, we store -1 in the kernel
553 */
554 if (bts->c_ospeed == -1)
555 bts->c_ospeed = 0;
556 lts->c_cflag |= mask;
557
558 lts->c_cc[LINUX_VINTR] = bts->c_cc[VINTR];
559 lts->c_cc[LINUX_VQUIT] = bts->c_cc[VQUIT];
560 lts->c_cc[LINUX_VERASE] = bts->c_cc[VERASE];
561 lts->c_cc[LINUX_VKILL] = bts->c_cc[VKILL];
562 lts->c_cc[LINUX_VEOF] = bts->c_cc[VEOF];
563 lts->c_cc[LINUX_VTIME] = bts->c_cc[VTIME];
564 lts->c_cc[LINUX_VMIN] = bts->c_cc[VMIN];
565 lts->c_cc[LINUX_VEOL] = bts->c_cc[VEOL];
566 lts->c_cc[LINUX_VEOL2] = bts->c_cc[VEOL2];
567 lts->c_cc[LINUX_VWERASE] = bts->c_cc[VWERASE];
568 lts->c_cc[LINUX_VSUSP] = bts->c_cc[VSUSP];
569 lts->c_cc[LINUX_VSTART] = bts->c_cc[VSTART];
570 lts->c_cc[LINUX_VSTOP] = bts->c_cc[VSTOP];
571 lts->c_cc[LINUX_VLNEXT] = bts->c_cc[VLNEXT];
572 lts->c_cc[LINUX_VDISCARD] = bts->c_cc[VDISCARD];
573 lts->c_cc[LINUX_VREPRINT] = bts->c_cc[VREPRINT];
574 lts->c_cc[LINUX_VSWTC] = 0;
575
576 /* XXX should be fixed someday */
577 lts->c_line = 0;
578 }
579 #endif /* !_LINUX_TERMIOS_H */
Cache object: f60c58d4c2e9b114557602126e4916f0
|