1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive
5  * for more details.
6  *
7  * Copyright (C) 1995, 96, 99, 2001, 06 Ralf Baechle
8  * Copyright (C) 1999 Silicon Graphics, Inc.
9  * Copyright (C) 2001 MIPS Technologies, Inc.
10  */
11 #ifndef _ASM_TERMBITS_H
12 #define _ASM_TERMBITS_H
13 
14 #include <linux/posix_types.h>
15 
16 typedef unsigned char cc_t;
17 typedef unsigned int speed_t;
18 typedef unsigned int tcflag_t;
19 
20 /*
21  * The ABI says nothing about NCC but seems to use NCCS as
22  * replacement for it in struct termio
23  */
24 #define NCCS	23
25 struct termios {
26 	tcflag_t c_iflag;		/* input mode flags */
27 	tcflag_t c_oflag;		/* output mode flags */
28 	tcflag_t c_cflag;		/* control mode flags */
29 	tcflag_t c_lflag;		/* local mode flags */
30 	cc_t c_line;			/* line discipline */
31 	cc_t c_cc[NCCS];		/* control characters */
32 };
33 
34 struct termios2 {
35 	tcflag_t c_iflag;		/* input mode flags */
36 	tcflag_t c_oflag;		/* output mode flags */
37 	tcflag_t c_cflag;		/* control mode flags */
38 	tcflag_t c_lflag;		/* local mode flags */
39 	cc_t c_line;			/* line discipline */
40 	cc_t c_cc[NCCS];		/* control characters */
41 	speed_t c_ispeed;		/* input speed */
42 	speed_t c_ospeed;		/* output speed */
43 };
44 
45 struct ktermios {
46 	tcflag_t c_iflag;		/* input mode flags */
47 	tcflag_t c_oflag;		/* output mode flags */
48 	tcflag_t c_cflag;		/* control mode flags */
49 	tcflag_t c_lflag;		/* local mode flags */
50 	cc_t c_line;			/* line discipline */
51 	cc_t c_cc[NCCS];		/* control characters */
52 	speed_t c_ispeed;		/* input speed */
53 	speed_t c_ospeed;		/* output speed */
54 };
55 
56 /* c_cc characters */
57 #define VINTR		 0		/* Interrupt character [ISIG].	*/
58 #define VQUIT		 1		/* Quit character [ISIG].  */
59 #define VERASE		 2		/* Erase character [ICANON].  */
60 #define VKILL		 3		/* Kill-line character [ICANON].  */
61 #define VMIN		 4		/* Minimum number of bytes read at once [!ICANON].  */
62 #define VTIME		 5		/* Time-out value (tenths of a second) [!ICANON].  */
63 #define VEOL2		 6		/* Second EOL character [ICANON].  */
64 #define VSWTC		 7		/* ??? */
65 #define VSWTCH		VSWTC
66 #define VSTART		 8		/* Start (X-ON) character [IXON, IXOFF].  */
67 #define VSTOP		 9		/* Stop (X-OFF) character [IXON, IXOFF].  */
68 #define VSUSP		10		/* Suspend character [ISIG].  */
69 #if 0
70 /*
71  * VDSUSP is not supported
72  */
73 #define VDSUSP		11		/* Delayed suspend character [ISIG].  */
74 #endif
75 #define VREPRINT	12		/* Reprint-line character [ICANON].  */
76 #define VDISCARD	13		/* Discard character [IEXTEN].	*/
77 #define VWERASE		14		/* Word-erase character [ICANON].  */
78 #define VLNEXT		15		/* Literal-next character [IEXTEN].  */
79 #define VEOF		16		/* End-of-file character [ICANON].  */
80 #define VEOL		17		/* End-of-line character [ICANON].  */
81 
82 /* c_iflag bits */
83 #define IGNBRK	0000001		/* Ignore break condition.  */
84 #define BRKINT	0000002		/* Signal interrupt on break.  */
85 #define IGNPAR	0000004		/* Ignore characters with parity errors.  */
86 #define PARMRK	0000010		/* Mark parity and framing errors.  */
87 #define INPCK	0000020		/* Enable input parity check.  */
88 #define ISTRIP	0000040		/* Strip 8th bit off characters.  */
89 #define INLCR	0000100		/* Map NL to CR on input.  */
90 #define IGNCR	0000200		/* Ignore CR.  */
91 #define ICRNL	0000400		/* Map CR to NL on input.  */
92 #define IUCLC	0001000		/* Map upper case to lower case on input.  */
93 #define IXON	0002000		/* Enable start/stop output control.  */
94 #define IXANY	0004000		/* Any character will restart after stop.  */
95 #define IXOFF	0010000		/* Enable start/stop input control.  */
96 #define IMAXBEL 0020000		/* Ring bell when input queue is full.	*/
97 #define IUTF8	0040000		/* Input is UTF-8 */
98 
99 /* c_oflag bits */
100 #define OPOST	0000001		/* Perform output processing.  */
101 #define OLCUC	0000002		/* Map lower case to upper case on output.  */
102 #define ONLCR	0000004		/* Map NL to CR-NL on output.  */
103 #define OCRNL	0000010
104 #define ONOCR	0000020
105 #define ONLRET	0000040
106 #define OFILL	0000100
107 #define OFDEL	0000200
108 #define NLDLY	0000400
109 #define	  NL0	0000000
110 #define	  NL1	0000400
111 #define CRDLY	0003000
112 #define	  CR0	0000000
113 #define	  CR1	0001000
114 #define	  CR2	0002000
115 #define	  CR3	0003000
116 #define TABDLY	0014000
117 #define	  TAB0	0000000
118 #define	  TAB1	0004000
119 #define	  TAB2	0010000
120 #define	  TAB3	0014000
121 #define	  XTABS 0014000
122 #define BSDLY	0020000
123 #define	  BS0	0000000
124 #define	  BS1	0020000
125 #define VTDLY	0040000
126 #define	  VT0	0000000
127 #define	  VT1	0040000
128 #define FFDLY	0100000
129 #define	  FF0	0000000
130 #define	  FF1	0100000
131 /*
132 #define PAGEOUT ???
133 #define WRAP	???
134  */
135 
136 /* c_cflag bit meaning */
137 #define CBAUD	0010017
138 #define	 B0	0000000		/* hang up */
139 #define	 B50	0000001
140 #define	 B75	0000002
141 #define	 B110	0000003
142 #define	 B134	0000004
143 #define	 B150	0000005
144 #define	 B200	0000006
145 #define	 B300	0000007
146 #define	 B600	0000010
147 #define	 B1200	0000011
148 #define	 B1800	0000012
149 #define	 B2400	0000013
150 #define	 B4800	0000014
151 #define	 B9600	0000015
152 #define	 B19200 0000016
153 #define	 B38400 0000017
154 #define EXTA B19200
155 #define EXTB B38400
156 #define CSIZE	0000060		/* Number of bits per byte (mask).  */
157 #define	  CS5	0000000		/* 5 bits per byte.  */
158 #define	  CS6	0000020		/* 6 bits per byte.  */
159 #define	  CS7	0000040		/* 7 bits per byte.  */
160 #define	  CS8	0000060		/* 8 bits per byte.  */
161 #define CSTOPB	0000100		/* Two stop bits instead of one.  */
162 #define CREAD	0000200		/* Enable receiver.  */
163 #define PARENB	0000400		/* Parity enable.  */
164 #define PARODD	0001000		/* Odd parity instead of even.	*/
165 #define HUPCL	0002000		/* Hang up on last close.  */
166 #define CLOCAL	0004000		/* Ignore modem status lines.  */
167 #define CBAUDEX 0010000
168 #define	   BOTHER 0010000
169 #define	   B57600 0010001
170 #define	  B115200 0010002
171 #define	  B230400 0010003
172 #define	  B460800 0010004
173 #define	  B500000 0010005
174 #define	  B576000 0010006
175 #define	  B921600 0010007
176 #define	 B1000000 0010010
177 #define	 B1152000 0010011
178 #define	 B1500000 0010012
179 #define	 B2000000 0010013
180 #define	 B2500000 0010014
181 #define	 B3000000 0010015
182 #define	 B3500000 0010016
183 #define	 B4000000 0010017
184 #define CIBAUD	  002003600000	/* input baud rate */
185 #define CMSPAR	  010000000000	/* mark or space (stick) parity */
186 #define CRTSCTS	  020000000000	/* flow control */
187 
188 #define IBSHIFT 16		/* Shift from CBAUD to CIBAUD */
189 
190 /* c_lflag bits */
191 #define ISIG	0000001		/* Enable signals.  */
192 #define ICANON	0000002		/* Do erase and kill processing.  */
193 #define XCASE	0000004
194 #define ECHO	0000010		/* Enable echo.	 */
195 #define ECHOE	0000020		/* Visual erase for ERASE.  */
196 #define ECHOK	0000040		/* Echo NL after KILL.	*/
197 #define ECHONL	0000100		/* Echo NL even if ECHO is off.	 */
198 #define NOFLSH	0000200		/* Disable flush after interrupt.  */
199 #define IEXTEN	0000400		/* Enable DISCARD and LNEXT.  */
200 #define ECHOCTL 0001000		/* Echo control characters as ^X.  */
201 #define ECHOPRT 0002000		/* Hardcopy visual erase.  */
202 #define ECHOKE	0004000		/* Visual erase for KILL.  */
203 #define FLUSHO	0020000
204 #define PENDIN	0040000		/* Retype pending input (state).  */
205 #define TOSTOP	0100000		/* Send SIGTTOU for background output.	*/
206 #define ITOSTOP TOSTOP
207 #define EXTPROC 0200000		/* External processing on pty */
208 
209 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
210 #define TIOCSER_TEMT	0x01	/* Transmitter physically empty */
211 
212 /* tcflow() and TCXONC use these */
213 #define TCOOFF		0	/* Suspend output.  */
214 #define TCOON		1	/* Restart suspended output.  */
215 #define TCIOFF		2	/* Send a STOP character.  */
216 #define TCION		3	/* Send a START character.  */
217 
218 /* tcflush() and TCFLSH use these */
219 #define TCIFLUSH	0	/* Discard data received but not yet read.  */
220 #define TCOFLUSH	1	/* Discard data written but not yet sent.  */
221 #define TCIOFLUSH	2	/* Discard all pending data.  */
222 
223 /* tcsetattr uses these */
224 #define TCSANOW		TCSETS	/* Change immediately.	*/
225 #define TCSADRAIN	TCSETSW /* Change when pending output is written.  */
226 #define TCSAFLUSH	TCSETSF /* Flush pending input before changing.	 */
227 
228 #endif /* _ASM_TERMBITS_H */
229