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