2 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * The C library's definition of struct termios might differ from
31 * the kernel one, and we need to use the kernel layout.
33 #include <linux/termios.h>
35 #include "xlat/tcxonc_options.h"
36 #include "xlat/tcflsh_options.h"
37 #include "xlat/baud_options.h"
38 #include "xlat/modem_flags.h"
41 decode_termios(struct tcb *tcp, const long addr)
50 if (umove_or_printaddr(tcp, addr, &tios))
54 printxval(baud_options, tios.c_cflag & CBAUD, "B???");
55 tprintf(" %sopost %sisig %sicanon %secho ...}",
56 (tios.c_oflag & OPOST) ? "" : "-",
57 (tios.c_lflag & ISIG) ? "" : "-",
58 (tios.c_lflag & ICANON) ? "" : "-",
59 (tios.c_lflag & ECHO) ? "" : "-");
62 tprintf("{c_iflags=%#lx, c_oflags=%#lx, ",
63 (long) tios.c_iflag, (long) tios.c_oflag);
64 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
65 (long) tios.c_cflag, (long) tios.c_lflag);
66 tprintf("c_line=%u, ", tios.c_line);
67 if (!(tios.c_lflag & ICANON))
68 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
69 tios.c_cc[VMIN], tios.c_cc[VTIME]);
71 for (i = 0; i < NCCS; i++)
72 tprintf("\\x%02x", tios.c_cc[i]);
77 decode_termio(struct tcb *tcp, const long addr)
86 if (umove_or_printaddr(tcp, addr, &tio))
90 printxval(baud_options, tio.c_cflag & CBAUD, "B???");
91 tprintf(" %sopost %sisig %sicanon %secho ...}",
92 (tio.c_oflag & OPOST) ? "" : "-",
93 (tio.c_lflag & ISIG) ? "" : "-",
94 (tio.c_lflag & ICANON) ? "" : "-",
95 (tio.c_lflag & ECHO) ? "" : "-");
98 tprintf("{c_iflags=%#lx, c_oflags=%#lx, ",
99 (long) tio.c_iflag, (long) tio.c_oflag);
100 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
101 (long) tio.c_cflag, (long) tio.c_lflag);
102 tprintf("c_line=%u, ", tio.c_line);
104 if (!(tio.c_lflag & ICANON))
105 tprintf("c_cc[_VMIN]=%d, c_cc[_VTIME]=%d, ",
106 tio.c_cc[_VMIN], tio.c_cc[_VTIME]);
108 if (!(tio.c_lflag & ICANON))
109 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
110 tio.c_cc[VMIN], tio.c_cc[VTIME]);
113 for (i = 0; i < NCC; i++)
114 tprintf("\\x%02x", tio.c_cc[i]);
119 decode_winsize(struct tcb *tcp, const long addr)
127 if (umove_or_printaddr(tcp, addr, &ws))
129 tprintf("{ws_row=%d, ws_col=%d, ws_xpixel=%d, ws_ypixel=%d}",
130 ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
135 decode_ttysize(struct tcb *tcp, const long addr)
143 if (umove_or_printaddr(tcp, addr, &ts))
145 tprintf("{ts_lines=%d, ts_cols=%d}",
146 ts.ts_lines, ts.ts_cols);
151 decode_modem_flags(struct tcb *tcp, const long addr)
159 if (umove_or_printaddr(tcp, addr, &i))
162 printflags(modem_flags, i, "TIOCM_???");
167 term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
191 decode_termios(tcp, arg);
201 decode_termio(tcp, arg);
209 decode_winsize(tcp, arg);
218 decode_ttysize(tcp, arg);
222 /* ioctls with a direct decodable arg */
225 printxval_long(tcxonc_options, arg, "TC???");
229 printxval_long(tcflsh_options, arg, "TC???");
234 tprintf(", %d", (int) arg);
237 /* ioctls with an indirect parameter displayed as modem flags */
244 decode_modem_flags(tcp, arg);
247 /* ioctls with an indirect parameter displayed in decimal */
271 printnum_int(tcp, arg, "%d");
274 /* ioctls with an indirect parameter displayed as a char */
277 printstr(tcp, arg, 1);
280 /* ioctls with no parameters */
298 /* ioctls which are unknown */
304 return RVAL_DECODED | 1;