Move core man pages 1M -> 8
[unleashed.git] / include / sys / termios.h
blob0c07623ce681f06827bf32bd959c5416c192f1cc
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
26 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
31 #ifndef _SYS_TERMIOS_H
32 #define _SYS_TERMIOS_H
34 #include <sys/feature_tests.h>
36 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
37 #include <sys/ttydev.h>
38 #include <sys/time.h>
39 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
41 #include <sys/types.h>
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
48 * _POSIX_VDISABLE has been defined in <sys/termios.h> since the
49 * introduction of the header. The POSIX standard, IEEE Std.
50 * 1003.1-1988 also required the existence of _POSIX_VDISABLE in
51 * this header. Subsequent versions of the IEEE Standard as well
52 * as the X/Open specifications required that _POSIX_VDISABLE be
53 * defined in <unistd.h> while still allowing for it's existence
54 * here. With the introduction of XPG6, _POSIX_VDISABLE can only
55 * be defined in <unistd.h>.
57 #if !defined(_XPG6) || defined(__EXTENSIONS__)
58 #ifndef _POSIX_VDISABLE
59 #define _POSIX_VDISABLE 0 /* Disable special character functions */
60 #endif
61 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
63 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
64 #define CTRL(c) ((c)&037)
65 #define IBSHIFT 16
66 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
68 /* required by termio.h and VCEOF/VCEOL */
69 #define _NCC 8
70 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
71 #define NCC _NCC
72 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
74 /* some defines required by POSIX */
75 #define NCCS 19
78 * types defined by POSIX. These are better off in types.h, but
79 * the standard says that they have to be in termios.h.
81 typedef unsigned int tcflag_t;
82 typedef unsigned char cc_t;
83 typedef unsigned int speed_t;
86 * Ioctl control packet
88 struct termios {
89 tcflag_t c_iflag; /* input modes */
90 tcflag_t c_oflag; /* output modes */
91 tcflag_t c_cflag; /* control modes */
92 tcflag_t c_lflag; /* line discipline modes */
93 cc_t c_cc[NCCS]; /* control chars */
97 * POSIX termios functions
98 * These functions get mapped into ioctls.
101 #ifndef _KERNEL
103 extern speed_t cfgetospeed(const struct termios *);
104 extern int cfsetospeed(struct termios *, speed_t);
105 extern speed_t cfgetispeed(const struct termios *);
106 extern int cfsetispeed(struct termios *, speed_t);
107 extern int tcgetattr(int, struct termios *);
108 extern int tcsetattr(int, int, const struct termios *);
109 extern int tcsendbreak(int, int);
110 extern int tcdrain(int);
111 extern int tcflush(int, int);
112 extern int tcflow(int, int);
114 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
116 extern pid_t tcgetsid(int);
118 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
120 #endif
122 /* control characters */
123 #define VINTR 0
124 #define VQUIT 1
125 #define VERASE 2
126 #define VKILL 3
127 #define VEOF 4
128 #define VEOL 5
129 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
130 #define VEOL2 6
131 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
132 #define VMIN 4
133 #define VTIME 5
134 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
135 #define VSWTCH 7
136 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
137 #define VSTART 8
138 #define VSTOP 9
139 #define VSUSP 10
140 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
141 #define VDSUSP 11
142 #define VREPRINT 12
143 #define VDISCARD 13
144 #define VWERASE 14
145 #define VLNEXT 15
146 #define VSTATUS 16
147 #define VERASE2 17
148 /* 18 through 19 reserved for future use */
151 * control characters form Xenix termio.h
153 #define VCEOF NCC /* RESERVED true EOF char (V7 compatability) */
154 #define VCEOL (NCC + 1) /* RESERVED true EOL char */
156 #define CNUL 0
157 #define CDEL 0177
159 /* S5 default control chars */
160 /* CINTR, CERASE and CKILL modified to SunOS traditional values */
161 #define CESC '\\'
162 #define CINTR CTRL('c')
163 #define CQUIT 034 /* FS, cntl | */
164 #define CERASE 0177 /* DEL */
165 #define CERASE2 CTRL('h')
166 #define CKILL CTRL('u')
167 #define CEOT 04
168 #define CEOL 0
169 #define CEOL2 0
170 #define CEOF 04 /* cntl d */
171 #define CSTART 021 /* cntl q */
172 #define CSTOP 023 /* cntl s */
173 #define CSWTCH 032 /* cntl z */
174 #define CNSWTCH 0
175 #define CSUSP CTRL('z')
176 #define CDSUSP CTRL('y')
177 #define CRPRNT CTRL('r')
178 #define CFLUSH CTRL('o')
179 #define CWERASE CTRL('w')
180 #define CLNEXT CTRL('v')
181 #define CSTATUS CTRL('t')
182 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
185 /* input modes */
186 #define IGNBRK 0000001
187 #define BRKINT 0000002
188 #define IGNPAR 0000004
189 #define PARMRK 0000010
190 #define INPCK 0000020
191 #define ISTRIP 0000040
192 #define INLCR 0000100
193 #define IGNCR 0000200
194 #define ICRNL 0000400
195 #if !defined(_POSIX_C_SOURCE) || \
196 (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \
197 defined(__EXTENSIONS__)
198 #define IUCLC 0001000
199 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
200 #define IXON 0002000
201 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
202 defined(__EXTENSIONS__)
203 #define IXANY 0004000
204 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
205 #define IXOFF 0010000
206 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
207 #define IMAXBEL 0020000
208 #define DOSMODE 0100000 /* for 386 compatibility */
209 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
211 /* output modes */
212 #define OPOST 0000001
213 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
214 defined(__EXTENSIONS__)
215 #if !defined(_XPG6) || defined(__EXTENSIONS__)
216 #define OLCUC 0000002
217 #endif
218 #define ONLCR 0000004
219 #define OCRNL 0000010
220 #define ONOCR 0000020
221 #define ONLRET 0000040
222 #define OFILL 0000100
223 #define OFDEL 0000200
224 #define NLDLY 0000400
225 #define NL0 0
226 #define NL1 0000400
227 #define CRDLY 0003000
228 #define CR0 0
229 #define CR1 0001000
230 #define CR2 0002000
231 #define CR3 0003000
232 #define TABDLY 0014000
233 #define TAB0 0
234 #define TAB1 0004000
235 #define TAB2 0010000
236 #define TAB3 0014000
237 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
238 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
239 #define XTABS 0014000
240 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
241 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
242 defined(__EXTENSIONS__)
243 #define BSDLY 0020000
244 #define BS0 0
245 #define BS1 0020000
246 #define VTDLY 0040000
247 #define VT0 0
248 #define VT1 0040000
249 #define FFDLY 0100000
250 #define FF0 0
251 #define FF1 0100000
252 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
253 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
254 #define PAGEOUT 0200000
255 #define WRAP 0400000
257 /* control modes */
258 #define CBAUD 0000017
259 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
260 #define CSIZE 0000060
261 #define CS5 0
262 #define CS6 0000020
263 #define CS7 0000040
264 #define CS8 0000060
265 #define CSTOPB 0000100
266 #define CREAD 0000200
267 #define PARENB 0000400
268 #define PARODD 0001000
269 #define HUPCL 0002000
270 #define CLOCAL 0004000
271 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
272 #define RCV1EN 0010000
273 #define XMT1EN 0020000
274 #define LOBLK 0040000
275 #define XCLUDE 0100000 /* *V7* exclusive use coming fron XENIX */
276 #define CRTSXOFF 010000000000
277 #define CRTSCTS 020000000000
278 #define CIBAUD 03600000
279 #define PAREXT 04000000
280 #define CBAUDEXT 010000000
281 #define CIBAUDEXT 020000000
284 * 4.4BSD hardware flow control flags
286 #define CRTS_IFLOW 010000000000
287 #define CCTS_OFLOW 020000000000
289 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
291 /* line discipline 0 modes */
292 #define ISIG 0000001
293 #define ICANON 0000002
294 #if !defined(_POSIX_C_SOURCE) || \
295 (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \
296 defined(__EXTENSIONS__)
297 #define XCASE 0000004
298 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
299 #define ECHO 0000010
300 #define ECHOE 0000020
301 #define ECHOK 0000040
302 #define ECHONL 0000100
303 #define NOFLSH 0000200
304 #define TOSTOP 0000400
305 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
306 #define ECHOCTL 0001000
307 #define ECHOPRT 0002000
308 #define ECHOKE 0004000
309 #define DEFECHO 0010000
310 #define FLUSHO 0020000
311 #define PENDIN 0040000
312 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
314 #define IEXTEN 0100000 /* POSIX flag - enable POSIX extensions */
315 #define _TIOC ('T'<<8)
317 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
319 #define TIOC _TIOC
321 #define TCGETA (_TIOC|1)
322 #define TCSETA (_TIOC|2)
323 #define TCSETAW (_TIOC|3)
324 #define TCSETAF (_TIOC|4)
325 #define TCSBRK (_TIOC|5)
326 #define TCXONC (_TIOC|6)
327 #define TCFLSH (_TIOC|7)
329 /* Slots reserved for 386/XENIX compatibility - keyboard control */
331 #define TIOCKBON (_TIOC|8)
332 #define TIOCKBOF (_TIOC|9)
333 #define KBENABLED (_TIOC|10)
335 #ifndef IOCTYPE
336 #define IOCTYPE 0xff00
337 #endif
339 #define TCDSET (_TIOC|32)
340 #define RTS_TOG (_TIOC|33) /* 386 - "RTS" toggle define 8A1 protocol */
342 #define TIOCGWINSZ (_TIOC|104)
343 #define TIOCSWINSZ (_TIOC|103)
346 * Softcarrier ioctls
348 #define TIOCGSOFTCAR (_TIOC|105)
349 #define TIOCSSOFTCAR (_TIOC|106)
352 /* termios ioctls */
354 #define TCGETS (_TIOC|13)
355 #define TCSETS (_TIOC|14)
356 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
357 #define TCSANOW (_TIOC|14) /* same as TCSETS */
358 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
359 #define TCSETSW (_TIOC|15)
360 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
361 #define TCSADRAIN (_TIOC|15) /* same as TCSETSW */
362 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
363 #define TCSETSF (_TIOC|16)
366 * NTP PPS ioctls
368 #define TIOCGPPS (_TIOC|125)
369 #define TIOCSPPS (_TIOC|126)
370 #define TIOCGPPSEV (_TIOC|127)
372 /* Argument filled in by TIOCGPPSEV */
373 struct ppsclockev {
374 struct timeval tv;
375 uint_t serial;
378 #if defined(_SYSCALL32)
379 struct ppsclockev32 {
380 struct timeval32 tv;
381 uint32_t serial;
383 #endif /* _SYSCALL32 */
385 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
387 #define TCSAFLUSH (_TIOC|16) /* same as TCSETSF */
389 /* termios option flags */
391 #define TCIFLUSH 0 /* flush data received but not read */
392 #define TCOFLUSH 1 /* flush data written but not transmitted */
393 #define TCIOFLUSH 2 /* flush both data both input and output queues */
395 #define TCOOFF 0 /* suspend output */
396 #define TCOON 1 /* restart suspended output */
397 #define TCIOFF 2 /* suspend input */
398 #define TCION 3 /* restart suspended input */
400 /* TIOC ioctls for BSD, ptys, job control and modem control */
402 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
403 #define tIOC ('t'<<8)
404 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
406 /* Slots for 386/XENIX compatibility */
407 /* BSD includes these ioctls in ttold.h */
409 #ifndef _SYS_TTOLD_H
411 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
412 #define TIOCGETD (tIOC|0)
413 #define TIOCSETD (tIOC|1)
414 #define TIOCHPCL (tIOC|2)
415 #define TIOCGETP (tIOC|8)
416 #define TIOCSETP (tIOC|9)
417 #define TIOCSETN (tIOC|10)
418 #define TIOCEXCL (tIOC|13)
419 #define TIOCNXCL (tIOC|14)
420 #define TIOCFLUSH (tIOC|16)
421 #define TIOCSETC (tIOC|17)
422 #define TIOCGETC (tIOC|18)
424 * BSD ioctls that are not the same as XENIX are included here.
425 * There are also some relevant ioctls from SUN/BSD sys/ttycom.h
426 * BSD pty ioctls like TIOCPKT are not supported in SVR4.
429 #define TIOCLBIS (tIOC|127) /* bis local mode bits */
430 #define TIOCLBIC (tIOC|126) /* bic local mode bits */
431 #define TIOCLSET (tIOC|125) /* set entire local mode word */
432 #define TIOCLGET (tIOC|124) /* get local modes */
433 #define TIOCSBRK (tIOC|123) /* set break bit */
434 #define TIOCCBRK (tIOC|122) /* clear break bit */
435 #define TIOCSDTR (tIOC|121) /* set data terminal ready */
436 #define TIOCCDTR (tIOC|120) /* clear data terminal ready */
437 #define TIOCSLTC (tIOC|117) /* set local special chars */
438 #define TIOCGLTC (tIOC|116) /* get local special chars */
439 #define TIOCOUTQ (tIOC|115) /* driver output queue size */
440 #define TIOCNOTTY (tIOC|113) /* void tty association */
441 #define TIOCSCTTY (tIOC|132) /* get a ctty */
442 #define TIOCSTOP (tIOC|111) /* stop output, like ^S */
443 #define TIOCSTART (tIOC|110) /* start output, like ^Q */
444 #define TIOCSILOOP (tIOC|109) /* private to Sun; do not use */
445 #define TIOCCILOOP (tIOC|108) /* private to Sun; do not use */
447 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
449 #endif /* end _SYS_TTOLD_H */
451 /* POSIX job control ioctls */
453 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
454 #define TIOCGPGRP (tIOC|20) /* get pgrp of tty */
455 #define TIOCSPGRP (tIOC|21) /* set pgrp of tty */
456 #define TIOCGSID (tIOC|22) /* get session id on ctty */
458 /* Miscellaneous */
459 #define TIOCSTI (tIOC|23) /* simulate terminal input */
461 /* Modem control */
462 #define TIOCMSET (tIOC|26) /* set all modem bits */
463 #define TIOCMBIS (tIOC|27) /* bis modem bits */
464 #define TIOCMBIC (tIOC|28) /* bic modem bits */
465 #define TIOCMGET (tIOC|29) /* get all modem bits */
466 #define TIOCM_LE 0001 /* line enable */
467 #define TIOCM_DTR 0002 /* data terminal ready */
468 #define TIOCM_RTS 0004 /* request to send */
469 #define TIOCM_ST 0010 /* secondary transmit */
470 #define TIOCM_SR 0020 /* secondary receive */
471 #define TIOCM_CTS 0040 /* clear to send */
472 #define TIOCM_CAR 0100 /* carrier detect */
473 #define TIOCM_CD TIOCM_CAR
474 #define TIOCM_RNG 0200 /* ring */
475 #define TIOCM_RI TIOCM_RNG
476 #define TIOCM_DSR 0400 /* data set ready */
478 /* pseudo-tty */
480 #define TIOCREMOTE (tIOC|30) /* remote input editing */
481 #define TIOCSIGNAL (tIOC|31) /* pty: send signal to slave */
484 /* Some more 386 xenix stuff */
486 #define LDIOC ('D'<<8)
488 #define LDOPEN (LDIOC|0)
489 #define LDCLOSE (LDIOC|1)
490 #define LDCHG (LDIOC|2)
491 #define LDGETT (LDIOC|8)
492 #define LDSETT (LDIOC|9)
494 /* Slots for 386 compatibility */
496 #define LDSMAP (LDIOC|110)
497 #define LDGMAP (LDIOC|111)
498 #define LDNMAP (LDIOC|112)
499 #define LDEMAP (LDIOC|113)
500 #define LDDMAP (LDIOC|114)
503 * These are retained for 386/XENIX compatibility.
506 #define DIOC ('d'<<8)
507 #define DIOCGETP (DIOC|8) /* V7 */
508 #define DIOCSETP (DIOC|9) /* V7 */
511 * Returns a non-zero value if there
512 * are characters in the input queue.
514 * XXX - somebody is confused here. V7 had no such "ioctl", although XENIX may
515 * have added it; 4BSD had FIONREAD, which returned the number of characters
516 * waiting, and was supposed to work on all descriptors (i.e., every driver
517 * should make a stab at implementing it).
519 #define FIORDCHK (('f'<<8)|3) /* V7 */
520 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
523 * Speeds
525 #define B0 0
526 #define B50 1
527 #define B75 2
528 #define B110 3
529 #define B134 4
530 #define B150 5
531 #define B200 6
532 #define B300 7
533 #define B600 8
534 #define B1200 9
535 #define B1800 10
536 #define B2400 11
537 #define B4800 12
538 #define B9600 13
539 #define B19200 14
540 #define B38400 15
541 #define B57600 16
542 #define B76800 17
543 #define B115200 18
544 #define B153600 19
545 #define B230400 20
546 #define B307200 21
547 #define B460800 22
548 #define B921600 23
550 #ifndef _SYS_TTOLD_H
552 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
553 /* Windowing structure to support JWINSIZE/TIOCSWINSZ/TIOCGWINSZ */
554 struct winsize {
555 unsigned short ws_row; /* rows, in characters */
556 unsigned short ws_col; /* columns, in character */
557 unsigned short ws_xpixel; /* horizontal size, pixels */
558 unsigned short ws_ypixel; /* vertical size, pixels */
560 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
562 #endif /* end _SYS_TTOLD_H */
564 #ifdef __cplusplus
566 #endif
568 #endif /* _SYS_TERMIOS_H */