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]
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>
39 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
41 #include <sys/types.h>
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 */
61 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
63 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
64 #define CTRL(c) ((c)&037)
66 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
68 /* required by termio.h and VCEOF/VCEOL */
70 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
72 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
74 /* some defines required by POSIX */
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
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.
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) ... */
122 /* control characters */
129 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
131 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
134 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
136 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
140 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
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 */
159 /* S5 default control chars */
160 /* CINTR, CERASE and CKILL modified to SunOS traditional values */
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')
170 #define CEOF 04 /* cntl d */
171 #define CSTART 021 /* cntl q */
172 #define CSTOP 023 /* cntl s */
173 #define CSWTCH 032 /* cntl z */
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__) */
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)... */
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__) */
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
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
227 #define CRDLY 0003000
232 #define TABDLY 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
246 #define VTDLY 0040000
249 #define FFDLY 0100000
252 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
253 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
254 #define PAGEOUT 0200000
258 #define CBAUD 0000017
259 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
260 #define CSIZE 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 */
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)... */
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__)
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)
336 #define IOCTYPE 0xff00
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)
348 #define TIOCGSOFTCAR (_TIOC|105)
349 #define TIOCSSOFTCAR (_TIOC|106)
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)
368 #define TIOCGPPS (_TIOC|125)
369 #define TIOCSPPS (_TIOC|126)
370 #define TIOCGPPSEV (_TIOC|127)
372 /* Argument filled in by TIOCGPPSEV */
378 #if defined(_SYSCALL32)
379 struct ppsclockev32
{
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 */
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 */
459 #define TIOCSTI (tIOC|23) /* simulate terminal input */
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 */
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__) */
552 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
553 /* Windowing structure to support JWINSIZE/TIOCSWINSZ/TIOCGWINSZ */
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 */
568 #endif /* _SYS_TERMIOS_H */