sync hh.org
[hh.org.git] / include / asm-sparc64 / termios.h
blobee26a071c67776074f9386249c8b3af040370077
1 /* $Id: termios.h,v 1.11 2001/06/01 08:12:11 davem Exp $ */
2 #ifndef _SPARC64_TERMIOS_H
3 #define _SPARC64_TERMIOS_H
5 #include <asm/ioctls.h>
6 #include <asm/termbits.h>
8 #if defined(__KERNEL__) || defined(__DEFINE_BSD_TERMIOS)
9 struct sgttyb {
10 char sg_ispeed;
11 char sg_ospeed;
12 char sg_erase;
13 char sg_kill;
14 short sg_flags;
17 struct tchars {
18 char t_intrc;
19 char t_quitc;
20 char t_startc;
21 char t_stopc;
22 char t_eofc;
23 char t_brkc;
26 struct ltchars {
27 char t_suspc;
28 char t_dsuspc;
29 char t_rprntc;
30 char t_flushc;
31 char t_werasc;
32 char t_lnextc;
34 #endif /* __KERNEL__ */
36 struct sunos_ttysize {
37 int st_lines; /* Lines on the terminal */
38 int st_columns; /* Columns on the terminal */
41 struct winsize {
42 unsigned short ws_row;
43 unsigned short ws_col;
44 unsigned short ws_xpixel;
45 unsigned short ws_ypixel;
48 /* line disciplines */
49 #define N_TTY 0
50 #define N_SLIP 1
51 #define N_MOUSE 2
52 #define N_PPP 3
53 #define N_STRIP 4
54 #define N_AX25 5
55 #define N_X25 6
56 #define N_6PACK 7
57 #define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
58 #define N_R3964 9 /* Reserved for Simatic R3964 module */
59 #define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
60 #define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
61 #define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
62 #define N_HDLC 13 /* synchronous HDLC */
63 #define N_SYNC_PPP 14 /* synchronous PPP */
64 #define N_HCI 15 /* Bluetooth HCI UART */
66 #ifdef __KERNEL__
67 #include <linux/module.h>
70 * c_cc characters in the termio structure. Oh, how I love being
71 * backwardly compatible. Notice that character 4 and 5 are
72 * interpreted differently depending on whether ICANON is set in
73 * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
74 * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
75 * is compatible with sysV)...
77 #define _VMIN 4
78 #define _VTIME 5
80 /* intr=^C quit=^\ erase=del kill=^U
81 eof=^D eol=\0 eol2=\0 sxtc=\0
82 start=^Q stop=^S susp=^Z dsusp=^Y
83 reprint=^R discard=^U werase=^W lnext=^V
84 vmin=\1 vtime=\0
86 #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001"
89 * Translate a "termio" structure into a "termios". Ugh.
91 #define user_termio_to_kernel_termios(termios, termio) \
92 ({ \
93 unsigned short tmp; \
94 int err; \
95 err = get_user(tmp, &(termio)->c_iflag); \
96 (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
97 err |= get_user(tmp, &(termio)->c_oflag); \
98 (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
99 err |= get_user(tmp, &(termio)->c_cflag); \
100 (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
101 err |= get_user(tmp, &(termio)->c_lflag); \
102 (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
103 err |= copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
104 err; \
108 * Translate a "termios" structure into a "termio". Ugh.
110 * Note the "fun" _VMIN overloading.
112 #define kernel_termios_to_user_termio(termio, termios) \
113 ({ \
114 int err; \
115 err = put_user((termios)->c_iflag, &(termio)->c_iflag); \
116 err |= put_user((termios)->c_oflag, &(termio)->c_oflag); \
117 err |= put_user((termios)->c_cflag, &(termio)->c_cflag); \
118 err |= put_user((termios)->c_lflag, &(termio)->c_lflag); \
119 err |= put_user((termios)->c_line, &(termio)->c_line); \
120 err |= copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
121 if (!((termios)->c_lflag & ICANON)) { \
122 err |= put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
123 err |= put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
125 err; \
128 #define user_termios_to_kernel_termios(k, u) \
129 ({ \
130 int err; \
131 err = get_user((k)->c_iflag, &(u)->c_iflag); \
132 err |= get_user((k)->c_oflag, &(u)->c_oflag); \
133 err |= get_user((k)->c_cflag, &(u)->c_cflag); \
134 err |= get_user((k)->c_lflag, &(u)->c_lflag); \
135 err |= get_user((k)->c_line, &(u)->c_line); \
136 err |= copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
137 if((k)->c_lflag & ICANON) { \
138 err |= get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
139 err |= get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
140 } else { \
141 err |= get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
142 err |= get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
144 err; \
147 #define kernel_termios_to_user_termios(u, k) \
148 ({ \
149 int err; \
150 err = put_user((k)->c_iflag, &(u)->c_iflag); \
151 err |= put_user((k)->c_oflag, &(u)->c_oflag); \
152 err |= put_user((k)->c_cflag, &(u)->c_cflag); \
153 err |= put_user((k)->c_lflag, &(u)->c_lflag); \
154 err |= put_user((k)->c_line, &(u)->c_line); \
155 err |= copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
156 if(!((k)->c_lflag & ICANON)) { \
157 err |= put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
158 err |= put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
159 } else { \
160 err |= put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
161 err |= put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
163 err; \
166 #endif /* __KERNEL__ */
168 #endif /* _SPARC64_TERMIOS_H */