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__)
147 /* 17 through 19 reserved for future use */
150 * control characters form Xenix termio.h
152 #define VCEOF NCC /* RESERVED true EOF char (V7 compatability) */
153 #define VCEOL (NCC + 1) /* RESERVED true EOL char */
158 /* S5 default control chars */
159 /* CINTR, CERASE and CKILL modified to SunOS traditional values */
161 #define CINTR CTRL('c')
162 #define CQUIT 034 /* FS, cntl | */
163 #define CERASE 0177 /* DEL */
164 #define CKILL CTRL('u')
168 #define CEOF 04 /* cntl d */
169 #define CSTART 021 /* cntl q */
170 #define CSTOP 023 /* cntl s */
171 #define CSWTCH 032 /* cntl z */
173 #define CSUSP CTRL('z')
174 #define CDSUSP CTRL('y')
175 #define CRPRNT CTRL('r')
176 #define CFLUSH CTRL('o')
177 #define CWERASE CTRL('w')
178 #define CLNEXT CTRL('v')
179 #define CSTATUS CTRL('t')
180 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
184 #define IGNBRK 0000001
185 #define BRKINT 0000002
186 #define IGNPAR 0000004
187 #define PARMRK 0000010
188 #define INPCK 0000020
189 #define ISTRIP 0000040
190 #define INLCR 0000100
191 #define IGNCR 0000200
192 #define ICRNL 0000400
193 #if !defined(_POSIX_C_SOURCE) || \
194 (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \
195 defined(__EXTENSIONS__)
196 #define IUCLC 0001000
197 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
199 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
200 defined(__EXTENSIONS__)
201 #define IXANY 0004000
202 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
203 #define IXOFF 0010000
204 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
205 #define IMAXBEL 0020000
206 #define DOSMODE 0100000 /* for 386 compatibility */
207 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
210 #define OPOST 0000001
211 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
212 defined(__EXTENSIONS__)
213 #if !defined(_XPG6) || defined(__EXTENSIONS__)
214 #define OLCUC 0000002
216 #define ONLCR 0000004
217 #define OCRNL 0000010
218 #define ONOCR 0000020
219 #define ONLRET 0000040
220 #define OFILL 0000100
221 #define OFDEL 0000200
222 #define NLDLY 0000400
225 #define CRDLY 0003000
230 #define TABDLY 0014000
235 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
236 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
237 #define XTABS 0014000
238 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
239 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
240 defined(__EXTENSIONS__)
241 #define BSDLY 0020000
244 #define VTDLY 0040000
247 #define FFDLY 0100000
250 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
251 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
252 #define PAGEOUT 0200000
256 #define CBAUD 0000017
257 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
258 #define CSIZE 0000060
263 #define CSTOPB 0000100
264 #define CREAD 0000200
265 #define PARENB 0000400
266 #define PARODD 0001000
267 #define HUPCL 0002000
268 #define CLOCAL 0004000
269 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
270 #define RCV1EN 0010000
271 #define XMT1EN 0020000
272 #define LOBLK 0040000
273 #define XCLUDE 0100000 /* *V7* exclusive use coming fron XENIX */
274 #define CRTSXOFF 010000000000
275 #define CRTSCTS 020000000000
276 #define CIBAUD 03600000
277 #define PAREXT 04000000
278 #define CBAUDEXT 010000000
279 #define CIBAUDEXT 020000000
282 * 4.4BSD hardware flow control flags
284 #define CRTS_IFLOW 010000000000
285 #define CCTS_OFLOW 020000000000
287 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
289 /* line discipline 0 modes */
291 #define ICANON 0000002
292 #if !defined(_POSIX_C_SOURCE) || \
293 (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \
294 defined(__EXTENSIONS__)
295 #define XCASE 0000004
296 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
298 #define ECHOE 0000020
299 #define ECHOK 0000040
300 #define ECHONL 0000100
301 #define NOFLSH 0000200
302 #define TOSTOP 0000400
303 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
304 #define ECHOCTL 0001000
305 #define ECHOPRT 0002000
306 #define ECHOKE 0004000
307 #define DEFECHO 0010000
308 #define FLUSHO 0020000
309 #define PENDIN 0040000
310 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
312 #define IEXTEN 0100000 /* POSIX flag - enable POSIX extensions */
313 #define _TIOC ('T'<<8)
315 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
319 #define TCGETA (_TIOC|1)
320 #define TCSETA (_TIOC|2)
321 #define TCSETAW (_TIOC|3)
322 #define TCSETAF (_TIOC|4)
323 #define TCSBRK (_TIOC|5)
324 #define TCXONC (_TIOC|6)
325 #define TCFLSH (_TIOC|7)
327 /* Slots reserved for 386/XENIX compatibility - keyboard control */
329 #define TIOCKBON (_TIOC|8)
330 #define TIOCKBOF (_TIOC|9)
331 #define KBENABLED (_TIOC|10)
334 #define IOCTYPE 0xff00
337 #define TCDSET (_TIOC|32)
338 #define RTS_TOG (_TIOC|33) /* 386 - "RTS" toggle define 8A1 protocol */
340 #define TIOCGWINSZ (_TIOC|104)
341 #define TIOCSWINSZ (_TIOC|103)
346 #define TIOCGSOFTCAR (_TIOC|105)
347 #define TIOCSSOFTCAR (_TIOC|106)
352 #define TCGETS (_TIOC|13)
353 #define TCSETS (_TIOC|14)
354 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
355 #define TCSANOW (_TIOC|14) /* same as TCSETS */
356 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
357 #define TCSETSW (_TIOC|15)
358 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
359 #define TCSADRAIN (_TIOC|15) /* same as TCSETSW */
360 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
361 #define TCSETSF (_TIOC|16)
366 #define TIOCGPPS (_TIOC|125)
367 #define TIOCSPPS (_TIOC|126)
368 #define TIOCGPPSEV (_TIOC|127)
370 /* Argument filled in by TIOCGPPSEV */
376 #if defined(_SYSCALL32)
377 struct ppsclockev32
{
381 #endif /* _SYSCALL32 */
383 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
385 #define TCSAFLUSH (_TIOC|16) /* same as TCSETSF */
387 /* termios option flags */
389 #define TCIFLUSH 0 /* flush data received but not read */
390 #define TCOFLUSH 1 /* flush data written but not transmitted */
391 #define TCIOFLUSH 2 /* flush both data both input and output queues */
393 #define TCOOFF 0 /* suspend output */
394 #define TCOON 1 /* restart suspended output */
395 #define TCIOFF 2 /* suspend input */
396 #define TCION 3 /* restart suspended input */
398 /* TIOC ioctls for BSD, ptys, job control and modem control */
400 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
401 #define tIOC ('t'<<8)
402 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
404 /* Slots for 386/XENIX compatibility */
405 /* BSD includes these ioctls in ttold.h */
409 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
410 #define TIOCGETD (tIOC|0)
411 #define TIOCSETD (tIOC|1)
412 #define TIOCHPCL (tIOC|2)
413 #define TIOCGETP (tIOC|8)
414 #define TIOCSETP (tIOC|9)
415 #define TIOCSETN (tIOC|10)
416 #define TIOCEXCL (tIOC|13)
417 #define TIOCNXCL (tIOC|14)
418 #define TIOCFLUSH (tIOC|16)
419 #define TIOCSETC (tIOC|17)
420 #define TIOCGETC (tIOC|18)
422 * BSD ioctls that are not the same as XENIX are included here.
423 * There are also some relevant ioctls from SUN/BSD sys/ttycom.h
424 * BSD pty ioctls like TIOCPKT are not supported in SVR4.
427 #define TIOCLBIS (tIOC|127) /* bis local mode bits */
428 #define TIOCLBIC (tIOC|126) /* bic local mode bits */
429 #define TIOCLSET (tIOC|125) /* set entire local mode word */
430 #define TIOCLGET (tIOC|124) /* get local modes */
431 #define TIOCSBRK (tIOC|123) /* set break bit */
432 #define TIOCCBRK (tIOC|122) /* clear break bit */
433 #define TIOCSDTR (tIOC|121) /* set data terminal ready */
434 #define TIOCCDTR (tIOC|120) /* clear data terminal ready */
435 #define TIOCSLTC (tIOC|117) /* set local special chars */
436 #define TIOCGLTC (tIOC|116) /* get local special chars */
437 #define TIOCOUTQ (tIOC|115) /* driver output queue size */
438 #define TIOCNOTTY (tIOC|113) /* void tty association */
439 #define TIOCSCTTY (tIOC|132) /* get a ctty */
440 #define TIOCSTOP (tIOC|111) /* stop output, like ^S */
441 #define TIOCSTART (tIOC|110) /* start output, like ^Q */
442 #define TIOCSILOOP (tIOC|109) /* private to Sun; do not use */
443 #define TIOCCILOOP (tIOC|108) /* private to Sun; do not use */
445 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
447 #endif /* end _SYS_TTOLD_H */
449 /* POSIX job control ioctls */
451 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
452 #define TIOCGPGRP (tIOC|20) /* get pgrp of tty */
453 #define TIOCSPGRP (tIOC|21) /* set pgrp of tty */
454 #define TIOCGSID (tIOC|22) /* get session id on ctty */
457 #define TIOCSTI (tIOC|23) /* simulate terminal input */
460 #define TIOCMSET (tIOC|26) /* set all modem bits */
461 #define TIOCMBIS (tIOC|27) /* bis modem bits */
462 #define TIOCMBIC (tIOC|28) /* bic modem bits */
463 #define TIOCMGET (tIOC|29) /* get all modem bits */
464 #define TIOCM_LE 0001 /* line enable */
465 #define TIOCM_DTR 0002 /* data terminal ready */
466 #define TIOCM_RTS 0004 /* request to send */
467 #define TIOCM_ST 0010 /* secondary transmit */
468 #define TIOCM_SR 0020 /* secondary receive */
469 #define TIOCM_CTS 0040 /* clear to send */
470 #define TIOCM_CAR 0100 /* carrier detect */
471 #define TIOCM_CD TIOCM_CAR
472 #define TIOCM_RNG 0200 /* ring */
473 #define TIOCM_RI TIOCM_RNG
474 #define TIOCM_DSR 0400 /* data set ready */
478 #define TIOCREMOTE (tIOC|30) /* remote input editing */
479 #define TIOCSIGNAL (tIOC|31) /* pty: send signal to slave */
482 /* Some more 386 xenix stuff */
484 #define LDIOC ('D'<<8)
486 #define LDOPEN (LDIOC|0)
487 #define LDCLOSE (LDIOC|1)
488 #define LDCHG (LDIOC|2)
489 #define LDGETT (LDIOC|8)
490 #define LDSETT (LDIOC|9)
492 /* Slots for 386 compatibility */
494 #define LDSMAP (LDIOC|110)
495 #define LDGMAP (LDIOC|111)
496 #define LDNMAP (LDIOC|112)
497 #define LDEMAP (LDIOC|113)
498 #define LDDMAP (LDIOC|114)
501 * These are retained for 386/XENIX compatibility.
504 #define DIOC ('d'<<8)
505 #define DIOCGETP (DIOC|8) /* V7 */
506 #define DIOCSETP (DIOC|9) /* V7 */
509 * Returns a non-zero value if there
510 * are characters in the input queue.
512 * XXX - somebody is confused here. V7 had no such "ioctl", although XENIX may
513 * have added it; 4BSD had FIONREAD, which returned the number of characters
514 * waiting, and was supposed to work on all descriptors (i.e., every driver
515 * should make a stab at implementing it).
517 #define FIORDCHK (('f'<<8)|3) /* V7 */
518 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
550 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
551 /* Windowing structure to support JWINSIZE/TIOCSWINSZ/TIOCGWINSZ */
553 unsigned short ws_row
; /* rows, in characters */
554 unsigned short ws_col
; /* columns, in character */
555 unsigned short ws_xpixel
; /* horizontal size, pixels */
556 unsigned short ws_ypixel
; /* vertical size, pixels */
558 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
560 #endif /* end _SYS_TTOLD_H */
566 #endif /* _SYS_TERMIOS_H */