xref: /titanic_51/usr/src/lib/libbc/inc/include/termios.h (revision 19449258028e6813f0b7a606b554b2fa37a390ec)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	__SYS_TERMIOS_H
28 #define	__SYS_TERMIOS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/stdtypes.h>
33 #include <sys/ioccom.h>
34 #include <sys/ttydev.h>
35 #include <sys/ttycom.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #define	NCCS	17
42 
43 /*
44  * control characters
45  * the following are not (yet) posix
46  * VEOL2, VSWTCH, VDSUSP, VREPRINT, VDISCARD, VWERASE, VLNEXT, VSTATUS
47  */
48 #define	VINTR		0
49 #define	VQUIT		1
50 #define	VERASE		2
51 #define	VKILL		3
52 #define	VEOF		4
53 #define	VEOL		5
54 #ifndef _POSIX_SOURCE
55 #define	VEOL2		6
56 #define	VSWTCH		7
57 #endif
58 #define	VSTART		8
59 #define	VSTOP		9
60 #define	VSUSP		10
61 #ifndef _POSIX_SOURCE
62 #define	VDSUSP		11
63 #define	VREPRINT	12
64 #define	VDISCARD	13
65 #define	VWERASE		14
66 #define	VLNEXT		15
67 #define	VSTATUS		16
68 #endif
69 
70 #define	VMIN		VEOF
71 #define	VTIME		VEOL
72 
73 #ifndef	_POSIX_SOURCE
74 #define	_CTRL(c)	('c'&037)
75 
76 /*
77  * default control chars.
78  * guarded for ttychars.h.
79  */
80 #ifndef	CINTR
81 #define	CINTR	_CTRL(c)
82 #define	CQUIT	034		/* FS, ^\ */
83 #define	CERASE	0177		/* DEL, ^? */
84 #define	CKILL	_CTRL(u)
85 #define	CEOF	_CTRL(d)
86 #define	CEOT	CEOF
87 #define	CEOL	0
88 #define	CEOL2	0
89 #define	CSWTCH	0
90 #define	CNSWTCH	0
91 #define	CSTART	_CTRL(q)
92 #define	CSTOP	_CTRL(s)
93 #define	CSUSP	_CTRL(z)
94 #define	CDSUSP	_CTRL(y)
95 #define	CRPRNT	_CTRL(r)
96 #define	CFLUSH	_CTRL(o)
97 #define	CWERASE	_CTRL(w)
98 #define	CLNEXT	_CTRL(v)
99 #endif	/* !CINTR */
100 
101 #define	CESC	'\\'
102 #define	CNUL	0
103 #define	CDEL	0377
104 #endif	/* !_POSIX_SOURCE */
105 
106 /* input modes */
107 #define	IGNBRK	0x00000001
108 #define	BRKINT	0x00000002
109 #define	IGNPAR	0x00000004
110 #define	PARMRK	0x00000008
111 #define	INPCK	0x00000010
112 #define	ISTRIP	0x00000020
113 #define	INLCR	0x00000040
114 #define	IGNCR	0x00000080
115 #define	ICRNL	0x00000100
116 /*	IUCLC	0x00000200	not posix, defined below */
117 #define	IXON	0x00000400
118 /*	IXANY	0x00000800	not posix, defined below */
119 #define	IXOFF	0x00001000
120 /*	IMAXBEL	0x00002000	not posix, defined below */
121 
122 #ifndef	_POSIX_SOURCE
123 #define	IUCLC	0x00000200
124 #define	IXANY	0x00000800
125 #define	IMAXBEL	0x00002000
126 #endif	/* !_POSIX_SOURCE */
127 
128 /* output modes */
129 #define	OPOST	0x00000001
130 #ifndef	_POSIX_SOURCE
131 #define	OLCUC	0x00000002
132 #define	ONLCR	0x00000004
133 #define	OCRNL	0x00000008
134 #define	ONOCR	0x00000010
135 #define	ONLRET	0x00000020
136 #define	OFILL	0x00000040
137 #define	OFDEL	0x00000080
138 #define	NLDLY	0x00000100
139 #define	NL0	0
140 #define	NL1	0x00000100
141 #define	CRDLY	0x00000600
142 #define	CR0	0
143 #define	CR1	0x00000200
144 #define	CR2	0x00000400
145 #define	CR3	0x00000600
146 #define	TABDLY	0x00001800
147 #define	TAB0	0
148 #define	TAB1	0x00000800
149 #define	TAB2	0x00001000
150 #define	XTABS	0x00001800
151 #define	TAB3	XTABS
152 #define	BSDLY	0x00002000
153 #define	BS0	0
154 #define	BS1	0x00002000
155 #define	VTDLY	0x00004000
156 #define	VT0	0
157 #define	VT1	0x00004000
158 #define	FFDLY	0x00008000
159 #define	FF0	0
160 #define	FF1	0x00008000
161 #define	PAGEOUT	0x00010000
162 #define	WRAP	0x00020000
163 #endif	/* !_POSIX_SOURCE */
164 
165 /* control modes */
166 #ifndef	_POSIX_SOURCE
167 #define	CBAUD	0x0000000f
168 #endif
169 #define	CSIZE	0x00000030
170 #define	CS5	0
171 #define	CS6	0x00000010
172 #define	CS7	0x00000020
173 #define	CS8	0x00000030
174 #define	CSTOPB	0x00000040
175 #define	CREAD	0x00000080
176 #define	PARENB	0x00000100
177 #define	PARODD	0x00000200
178 #define	HUPCL	0x00000400
179 #define	CLOCAL	0x00000800
180 #ifndef	_POSIX_SOURCE
181 #define	LOBLK	0x00001000
182 #define	CIBAUD	0x000f0000
183 #define	CRTSXOFF 0x40000000
184 #define	CRTSCTS	0x80000000
185 #define	CBAUDEXT 0x200000
186 #define	CIBAUDEXT 0x400000
187 
188 /*
189  * 4.4BSD flags for hardware flow control
190  */
191 #define	CRTS_IFLOW 0x40000000
192 #define	CCTS_OFLOW 0x80000000
193 
194 #define	IBSHIFT	16
195 #endif	/* !_POSIX_SOURCE */
196 
197 /* line discipline 0 modes */
198 #define	ISIG	0x00000001
199 #define	ICANON	0x00000002
200 /*	XCASE	0x00000004		not posix, defined below */
201 #define	ECHO	0x00000008
202 #define	ECHOE	0x00000010
203 #define	ECHOK	0x00000020
204 #define	ECHONL	0x00000040
205 #define	NOFLSH	0x00000080
206 #define	TOSTOP	0x00000100
207 /*	ECHOCTL	0x00000200		not posix, defined below */
208 /*	ECHOPRT	0x00000400		not posix, defined below */
209 /*	ECHOKE	0x00000800		not posix, defined below */
210 /*	DEFECHO	0x00001000		not posix, defined below */
211 /*	FLUSHO	0x00002000		not posix, defined below */
212 /*	PENDIN	0x00004000		not posix, defined below */
213 #define	IEXTEN	0x00008000
214 
215 #ifndef	_POSIX_SOURCE
216 #define	XCASE	0x00000004
217 #define	ECHOCTL	0x00000200
218 #define	ECHOPRT	0x00000400
219 #define	ECHOKE	0x00000800
220 #define	DEFECHO	0x00001000
221 #define	FLUSHO	0x00002000
222 #define	PENDIN	0x00004000
223 #endif	/* !_POSIX_SOURCE */
224 
225 #ifndef	_POSIX_SOURCE
226 /*
227  * codes 1 through 5, not shown here, are old "termio" calls
228  */
229 #define	TCXONC		_IO('T', 6)
230 #define	TCFLSH		_IO('T', 7)
231 #define	TCGETS		_IOR('T', 8, struct termios)
232 #define	TCSETS		_IOW('T', 9, struct termios)
233 #define	TCSETSW		_IOW('T', 10, struct termios)
234 #define	TCSETSF		_IOW('T', 11, struct termios)
235 #endif	/* !_POSIX_SOURCE */
236 
237 #define	TCOOFF		0		/* arg to TCXONC & tcflow() */
238 #define	TCOON		1		/* arg to TCXONC & tcflow() */
239 #define	TCIOFF		2		/* arg to TCXONC & tcflow() */
240 #define	TCION		3		/* arg to TCXONC & tcflow() */
241 #define	TCIFLUSH	0		/* arg to TCFLSH & tcflush() */
242 #define	TCOFLUSH	1		/* arg to TCFLSH & tcflush() */
243 #define	TCIOFLUSH	2		/* arg to TCFLSH & tcflush() */
244 #define	TCSANOW		0		/* arg to tcsetattr() */
245 #define	TCSADRAIN	1		/* arg to tcsetattr() */
246 #define	TCSAFLUSH	2		/* arg to tcsetattr() */
247 
248 /*
249  * Ioctl control packet
250  */
251 struct	termios {
252 	tcflag_t	c_iflag;	/* input modes */
253 	tcflag_t	c_oflag;	/* output modes */
254 	tcflag_t	c_cflag;	/* control modes */
255 	tcflag_t	c_lflag;	/* line discipline modes */
256 	char		c_line;		/* line discipline XXX */
257 	cc_t		c_cc[NCCS];	/* control chars */
258 };
259 
260 
261 #ifndef	KERNEL
262 speed_t	cfgetispeed(/* struct termios *termios_p */);
263 speed_t	cfgetospeed(/* struct termios *termios_p */);
264 int	cfsetispeed(/* struct termios *termios_p, speed_t speed */);
265 int	cfsetospeed(/* struct termios *termios_p, speed_t speed */);
266 int	tcdrain(/* int fildes */);
267 int	tcflow(/* int fildes, int action */);
268 int	tcflush(/* int fildes, int queue_selector */);
269 int	tcgetattr(/* int fildes, struct termios *termios_p */);
270 int	tcsendbreak(/* int fildes, int duration */);
271 int	tcsetattr(/* int fildes, int optional_actions, struct *termios_p */);
272 #endif	/* !KERNEL */
273 
274 #ifdef	__cplusplus
275 }
276 #endif
277 
278 #endif	/* __SYS_TERMIOS_H */
279