xref: /f-stack/freebsd/sys/_termios.h (revision 22ce4aff)
1a9643ea8Slogwang /*-
2*22ce4affSfengbojiang  * SPDX-License-Identifier: BSD-3-Clause
3*22ce4affSfengbojiang  *
4a9643ea8Slogwang  * Copyright (c) 1988, 1989, 1993, 1994
5a9643ea8Slogwang  *	The Regents of the University of California.  All rights reserved.
6a9643ea8Slogwang  *
7a9643ea8Slogwang  * Redistribution and use in source and binary forms, with or without
8a9643ea8Slogwang  * modification, are permitted provided that the following conditions
9a9643ea8Slogwang  * are met:
10a9643ea8Slogwang  * 1. Redistributions of source code must retain the above copyright
11a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer.
12a9643ea8Slogwang  * 2. Redistributions in binary form must reproduce the above copyright
13a9643ea8Slogwang  *    notice, this list of conditions and the following disclaimer in the
14a9643ea8Slogwang  *    documentation and/or other materials provided with the distribution.
15*22ce4affSfengbojiang  * 3. Neither the name of the University nor the names of its contributors
16a9643ea8Slogwang  *    may be used to endorse or promote products derived from this software
17a9643ea8Slogwang  *    without specific prior written permission.
18a9643ea8Slogwang  *
19a9643ea8Slogwang  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20a9643ea8Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21a9643ea8Slogwang  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22a9643ea8Slogwang  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23a9643ea8Slogwang  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24a9643ea8Slogwang  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25a9643ea8Slogwang  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26a9643ea8Slogwang  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27a9643ea8Slogwang  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28a9643ea8Slogwang  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29a9643ea8Slogwang  * SUCH DAMAGE.
30a9643ea8Slogwang  *
31a9643ea8Slogwang  *	@(#)termios.h	8.3 (Berkeley) 3/28/94
32a9643ea8Slogwang  * $FreeBSD$
33a9643ea8Slogwang  */
34a9643ea8Slogwang 
35a9643ea8Slogwang #ifndef _SYS__TERMIOS_H_
36a9643ea8Slogwang #define	_SYS__TERMIOS_H_
37a9643ea8Slogwang 
38a9643ea8Slogwang /*
39a9643ea8Slogwang  * Special Control Characters
40a9643ea8Slogwang  *
41a9643ea8Slogwang  * Index into c_cc[] character array.
42a9643ea8Slogwang  *
43a9643ea8Slogwang  *	Name	     Subscript	Enabled by
44a9643ea8Slogwang  */
45a9643ea8Slogwang #define	VEOF		0	/* ICANON */
46a9643ea8Slogwang #define	VEOL		1	/* ICANON */
47*22ce4affSfengbojiang #if __BSD_VISIBLE
48a9643ea8Slogwang #define	VEOL2		2	/* ICANON together with IEXTEN */
49a9643ea8Slogwang #endif
50a9643ea8Slogwang #define	VERASE		3	/* ICANON */
51*22ce4affSfengbojiang #if __BSD_VISIBLE
52a9643ea8Slogwang #define	VWERASE 	4	/* ICANON together with IEXTEN */
53a9643ea8Slogwang #endif
54a9643ea8Slogwang #define	VKILL		5	/* ICANON */
55*22ce4affSfengbojiang #if __BSD_VISIBLE
56a9643ea8Slogwang #define	VREPRINT 	6	/* ICANON together with IEXTEN */
57a9643ea8Slogwang #define	VERASE2 	7	/* ICANON */
58a9643ea8Slogwang #endif
59a9643ea8Slogwang /*			7	   ex-spare 1 */
60a9643ea8Slogwang #define	VINTR		8	/* ISIG */
61a9643ea8Slogwang #define	VQUIT		9	/* ISIG */
62a9643ea8Slogwang #define	VSUSP		10	/* ISIG */
63*22ce4affSfengbojiang #if __BSD_VISIBLE
64a9643ea8Slogwang #define	VDSUSP		11	/* ISIG together with IEXTEN */
65a9643ea8Slogwang #endif
66a9643ea8Slogwang #define	VSTART		12	/* IXON, IXOFF */
67a9643ea8Slogwang #define	VSTOP		13	/* IXON, IXOFF */
68*22ce4affSfengbojiang #if __BSD_VISIBLE
69a9643ea8Slogwang #define	VLNEXT		14	/* IEXTEN */
70a9643ea8Slogwang #define	VDISCARD	15	/* IEXTEN */
71a9643ea8Slogwang #endif
72a9643ea8Slogwang #define	VMIN		16	/* !ICANON */
73a9643ea8Slogwang #define	VTIME		17	/* !ICANON */
74*22ce4affSfengbojiang #if __BSD_VISIBLE
75a9643ea8Slogwang #define	VSTATUS		18	/* ICANON together with IEXTEN */
76a9643ea8Slogwang /*			19	   spare 2 */
77a9643ea8Slogwang #endif
78a9643ea8Slogwang #define	NCCS		20
79a9643ea8Slogwang 
80a9643ea8Slogwang #define	_POSIX_VDISABLE	0xff
81a9643ea8Slogwang 
82a9643ea8Slogwang /*
83a9643ea8Slogwang  * Input flags - software input processing
84a9643ea8Slogwang  */
85a9643ea8Slogwang #define	IGNBRK		0x00000001	/* ignore BREAK condition */
86a9643ea8Slogwang #define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
87a9643ea8Slogwang #define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
88a9643ea8Slogwang #define	PARMRK		0x00000008	/* mark parity and framing errors */
89a9643ea8Slogwang #define	INPCK		0x00000010	/* enable checking of parity errors */
90a9643ea8Slogwang #define	ISTRIP		0x00000020	/* strip 8th bit off chars */
91a9643ea8Slogwang #define	INLCR		0x00000040	/* map NL into CR */
92a9643ea8Slogwang #define	IGNCR		0x00000080	/* ignore CR */
93a9643ea8Slogwang #define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
94a9643ea8Slogwang #define	IXON		0x00000200	/* enable output flow control */
95a9643ea8Slogwang #define	IXOFF		0x00000400	/* enable input flow control */
96*22ce4affSfengbojiang #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
97a9643ea8Slogwang #define	IXANY		0x00000800	/* any char will restart after stop */
98*22ce4affSfengbojiang #endif
99*22ce4affSfengbojiang #if __BSD_VISIBLE
100a9643ea8Slogwang #define	IMAXBEL		0x00002000	/* ring bell on input queue full */
101*22ce4affSfengbojiang #endif
102a9643ea8Slogwang 
103a9643ea8Slogwang /*
104a9643ea8Slogwang  * Output flags - software output processing
105a9643ea8Slogwang  */
106a9643ea8Slogwang #define	OPOST		0x00000001	/* enable following output processing */
107*22ce4affSfengbojiang #if __XSI_VISIBLE
108a9643ea8Slogwang #define	ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
109*22ce4affSfengbojiang #endif
110*22ce4affSfengbojiang #if __BSD_VISIBLE
111a9643ea8Slogwang #define	TABDLY		0x00000004	/* tab delay mask */
112a9643ea8Slogwang #define	    TAB0	    0x00000000	    /* no tab delay and expansion */
113a9643ea8Slogwang #define	    TAB3	    0x00000004	    /* expand tabs to spaces */
114a9643ea8Slogwang #define	ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
115*22ce4affSfengbojiang #endif
116*22ce4affSfengbojiang #if __XSI_VISIBLE
117a9643ea8Slogwang #define	OCRNL		0x00000010	/* map CR to NL on output */
118a9643ea8Slogwang #define	ONOCR		0x00000020	/* no CR output at column 0 */
119a9643ea8Slogwang #define	ONLRET		0x00000040	/* NL performs CR function */
120*22ce4affSfengbojiang #endif
121a9643ea8Slogwang 
122a9643ea8Slogwang /*
123a9643ea8Slogwang  * Control flags - hardware control of terminal
124a9643ea8Slogwang  */
125*22ce4affSfengbojiang #if __BSD_VISIBLE
126a9643ea8Slogwang #define	CIGNORE		0x00000001	/* ignore control flags */
127a9643ea8Slogwang #endif
128a9643ea8Slogwang #define	CSIZE		0x00000300	/* character size mask */
129a9643ea8Slogwang #define	    CS5		    0x00000000	    /* 5 bits (pseudo) */
130a9643ea8Slogwang #define	    CS6		    0x00000100	    /* 6 bits */
131a9643ea8Slogwang #define	    CS7		    0x00000200	    /* 7 bits */
132a9643ea8Slogwang #define	    CS8		    0x00000300	    /* 8 bits */
133a9643ea8Slogwang #define	CSTOPB		0x00000400	/* send 2 stop bits */
134a9643ea8Slogwang #define	CREAD		0x00000800	/* enable receiver */
135a9643ea8Slogwang #define	PARENB		0x00001000	/* parity enable */
136a9643ea8Slogwang #define	PARODD		0x00002000	/* odd parity, else even */
137a9643ea8Slogwang #define	HUPCL		0x00004000	/* hang up on last close */
138a9643ea8Slogwang #define	CLOCAL		0x00008000	/* ignore modem status lines */
139*22ce4affSfengbojiang #if __BSD_VISIBLE
140a9643ea8Slogwang #define	CCTS_OFLOW	0x00010000	/* CTS flow control of output */
141a9643ea8Slogwang #define	CRTSCTS		(CCTS_OFLOW | CRTS_IFLOW)
142a9643ea8Slogwang #define	CRTS_IFLOW	0x00020000	/* RTS flow control of input */
143a9643ea8Slogwang #define	CDTR_IFLOW	0x00040000	/* DTR flow control of input */
144a9643ea8Slogwang #define	CDSR_OFLOW	0x00080000	/* DSR flow control of output */
145a9643ea8Slogwang #define	CCAR_OFLOW	0x00100000	/* DCD flow control of output */
146*22ce4affSfengbojiang #define	CNO_RTSDTR	0x00200000	/* Do not assert RTS or DTR automatically */
147a9643ea8Slogwang #endif
148a9643ea8Slogwang 
149a9643ea8Slogwang /*
150a9643ea8Slogwang  * "Local" flags - dumping ground for other state
151a9643ea8Slogwang  *
152a9643ea8Slogwang  * Warning: some flags in this structure begin with
153a9643ea8Slogwang  * the letter "I" and look like they belong in the
154a9643ea8Slogwang  * input flag.
155a9643ea8Slogwang  */
156a9643ea8Slogwang 
157*22ce4affSfengbojiang #if __BSD_VISIBLE
158a9643ea8Slogwang #define	ECHOKE		0x00000001	/* visual erase for line kill */
159*22ce4affSfengbojiang #endif
160a9643ea8Slogwang #define	ECHOE		0x00000002	/* visually erase chars */
161a9643ea8Slogwang #define	ECHOK		0x00000004	/* echo NL after line kill */
162a9643ea8Slogwang #define	ECHO		0x00000008	/* enable echoing */
163a9643ea8Slogwang #define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
164*22ce4affSfengbojiang #if __BSD_VISIBLE
165a9643ea8Slogwang #define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
166a9643ea8Slogwang #define	ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
167*22ce4affSfengbojiang #endif
168a9643ea8Slogwang #define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
169a9643ea8Slogwang #define	ICANON		0x00000100	/* canonicalize input lines */
170*22ce4affSfengbojiang #if __BSD_VISIBLE
171a9643ea8Slogwang #define	ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
172*22ce4affSfengbojiang #endif
173a9643ea8Slogwang #define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
174a9643ea8Slogwang #define	EXTPROC         0x00000800      /* external processing */
175a9643ea8Slogwang #define	TOSTOP		0x00400000	/* stop background jobs from output */
176*22ce4affSfengbojiang #if __BSD_VISIBLE
177a9643ea8Slogwang #define	FLUSHO		0x00800000	/* output being flushed (state) */
178a9643ea8Slogwang #define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
179a9643ea8Slogwang #define	PENDIN		0x20000000	/* XXX retype pending input (state) */
180*22ce4affSfengbojiang #endif
181a9643ea8Slogwang #define	NOFLSH		0x80000000	/* don't flush after interrupt */
182a9643ea8Slogwang 
183a9643ea8Slogwang /*
184a9643ea8Slogwang  * Standard speeds
185a9643ea8Slogwang  */
186a9643ea8Slogwang #define	B0	0
187a9643ea8Slogwang #define	B50	50
188a9643ea8Slogwang #define	B75	75
189a9643ea8Slogwang #define	B110	110
190a9643ea8Slogwang #define	B134	134
191a9643ea8Slogwang #define	B150	150
192a9643ea8Slogwang #define	B200	200
193a9643ea8Slogwang #define	B300	300
194a9643ea8Slogwang #define	B600	600
195a9643ea8Slogwang #define	B1200	1200
196a9643ea8Slogwang #define	B1800	1800
197a9643ea8Slogwang #define	B2400	2400
198a9643ea8Slogwang #define	B4800	4800
199a9643ea8Slogwang #define	B9600	9600
200a9643ea8Slogwang #define	B19200	19200
201a9643ea8Slogwang #define	B38400	38400
202*22ce4affSfengbojiang #if __BSD_VISIBLE
203a9643ea8Slogwang #define	B7200	7200
204a9643ea8Slogwang #define	B14400	14400
205a9643ea8Slogwang #define	B28800	28800
206a9643ea8Slogwang #define	B57600	57600
207a9643ea8Slogwang #define	B76800	76800
208a9643ea8Slogwang #define	B115200	115200
209a9643ea8Slogwang #define	B230400	230400
210a9643ea8Slogwang #define	B460800	460800
211a9643ea8Slogwang #define	B921600	921600
212a9643ea8Slogwang #define	EXTA	19200
213a9643ea8Slogwang #define	EXTB	38400
214*22ce4affSfengbojiang #endif
215a9643ea8Slogwang 
216a9643ea8Slogwang typedef unsigned int	tcflag_t;
217a9643ea8Slogwang typedef unsigned char	cc_t;
218a9643ea8Slogwang typedef unsigned int	speed_t;
219a9643ea8Slogwang 
220a9643ea8Slogwang struct termios {
221a9643ea8Slogwang 	tcflag_t	c_iflag;	/* input flags */
222a9643ea8Slogwang 	tcflag_t	c_oflag;	/* output flags */
223a9643ea8Slogwang 	tcflag_t	c_cflag;	/* control flags */
224a9643ea8Slogwang 	tcflag_t	c_lflag;	/* local flags */
225a9643ea8Slogwang 	cc_t		c_cc[NCCS];	/* control chars */
226a9643ea8Slogwang 	speed_t		c_ispeed;	/* input speed */
227a9643ea8Slogwang 	speed_t		c_ospeed;	/* output speed */
228a9643ea8Slogwang };
229a9643ea8Slogwang 
230a9643ea8Slogwang #endif /* !_SYS__TERMIOS_H_ */
231