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