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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 /* 27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31 #ifndef _SYS_TERMIOS_H 32 #define _SYS_TERMIOS_H 33 34 #pragma ident "%Z%%M% %I% %E% SMI" 35 36 #include <sys/feature_tests.h> 37 38 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 39 #include <sys/ttydev.h> 40 #include <sys/time.h> 41 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 42 43 #include <sys/types.h> 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /* 50 * _POSIX_VDISABLE has been defined in <sys/termios.h> since the 51 * introduction of the header. The POSIX standard, IEEE Std. 52 * 1003.1-1988 also required the existence of _POSIX_VDISABLE in 53 * this header. Subsequent versions of the IEEE Standard as well 54 * as the X/Open specifications required that _POSIX_VDISABLE be 55 * defined in <unistd.h> while still allowing for it's existence 56 * here. With the introduction of XPG6, _POSIX_VDISABLE can only 57 * be defined in <unistd.h>. 58 */ 59 #if !defined(_XPG6) || defined(__EXTENSIONS__) 60 #ifndef _POSIX_VDISABLE 61 #define _POSIX_VDISABLE 0 /* Disable special character functions */ 62 #endif 63 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */ 64 65 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 66 #define CTRL(c) ((c)&037) 67 #define IBSHIFT 16 68 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 69 70 /* required by termio.h and VCEOF/VCEOL */ 71 #define _NCC 8 72 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 73 #define NCC _NCC 74 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 75 76 /* some defines required by POSIX */ 77 #define NCCS 19 78 79 /* 80 * types defined by POSIX. These are better off in types.h, but 81 * the standard says that they have to be in termios.h. 82 */ 83 typedef unsigned int tcflag_t; 84 typedef unsigned char cc_t; 85 typedef unsigned int speed_t; 86 87 /* 88 * Ioctl control packet 89 */ 90 struct termios { 91 tcflag_t c_iflag; /* input modes */ 92 tcflag_t c_oflag; /* output modes */ 93 tcflag_t c_cflag; /* control modes */ 94 tcflag_t c_lflag; /* line discipline modes */ 95 cc_t c_cc[NCCS]; /* control chars */ 96 }; 97 98 /* 99 * POSIX termios functions 100 * These functions get mapped into ioctls. 101 */ 102 103 #ifndef _KERNEL 104 105 #if defined(__STDC__) 106 107 extern speed_t cfgetospeed(const struct termios *); 108 extern int cfsetospeed(struct termios *, speed_t); 109 extern speed_t cfgetispeed(const struct termios *); 110 extern int cfsetispeed(struct termios *, speed_t); 111 extern int tcgetattr(int, struct termios *); 112 extern int tcsetattr(int, int, const struct termios *); 113 extern int tcsendbreak(int, int); 114 extern int tcdrain(int); 115 extern int tcflush(int, int); 116 extern int tcflow(int, int); 117 118 #else 119 120 extern speed_t cfgetospeed(); 121 extern int cfsetospeed(); 122 extern speed_t cfgetispeed(); 123 extern int cfsetispeed(); 124 extern int tcgetattr(); 125 extern int tcsetattr(); 126 extern int tcsendbreak(); 127 extern int tcdrain(); 128 extern int tcflush(); 129 extern int tcflow(); 130 131 #endif /* __STDC__ */ 132 133 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 134 135 #if defined(__STDC__) 136 extern pid_t tcgetsid(int); 137 #else 138 extern pid_t tcgetsid(); 139 #endif /* __STDC__ */ 140 141 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */ 142 143 #endif 144 145 /* control characters */ 146 #define VINTR 0 147 #define VQUIT 1 148 #define VERASE 2 149 #define VKILL 3 150 #define VEOF 4 151 #define VEOL 5 152 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 153 #define VEOL2 6 154 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 155 #define VMIN 4 156 #define VTIME 5 157 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 158 #define VSWTCH 7 159 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 160 #define VSTART 8 161 #define VSTOP 9 162 #define VSUSP 10 163 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 164 #define VDSUSP 11 165 #define VREPRINT 12 166 #define VDISCARD 13 167 #define VWERASE 14 168 #define VLNEXT 15 169 /* 16 thru 19 reserved for future use */ 170 171 /* 172 * control characters form Xenix termio.h 173 */ 174 #define VCEOF NCC /* RESERVED true EOF char (V7 compatability) */ 175 #define VCEOL (NCC + 1) /* RESERVED true EOL char */ 176 177 #define CNUL 0 178 #define CDEL 0177 179 180 /* S5 default control chars */ 181 /* CINTR, CERASE and CKILL modified to SunOS traditional values */ 182 #define CESC '\\' 183 #define CINTR CTRL('c') 184 #define CQUIT 034 /* FS, cntl | */ 185 #define CERASE 0177 /* DEL */ 186 #define CKILL CTRL('u') 187 #define CEOT 04 188 #define CEOL 0 189 #define CEOL2 0 190 #define CEOF 04 /* cntl d */ 191 #define CSTART 021 /* cntl q */ 192 #define CSTOP 023 /* cntl s */ 193 #define CSWTCH 032 /* cntl z */ 194 #define CNSWTCH 0 195 #define CSUSP CTRL('z') 196 #define CDSUSP CTRL('y') 197 #define CRPRNT CTRL('r') 198 #define CFLUSH CTRL('o') 199 #define CWERASE CTRL('w') 200 #define CLNEXT CTRL('v') 201 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 202 203 204 /* input modes */ 205 #define IGNBRK 0000001 206 #define BRKINT 0000002 207 #define IGNPAR 0000004 208 #define PARMRK 0000010 209 #define INPCK 0000020 210 #define ISTRIP 0000040 211 #define INLCR 0000100 212 #define IGNCR 0000200 213 #define ICRNL 0000400 214 #if !defined(_POSIX_C_SOURCE) || \ 215 (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \ 216 defined(__EXTENSIONS__) 217 #define IUCLC 0001000 218 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ 219 #define IXON 0002000 220 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 221 defined(__EXTENSIONS__) 222 #define IXANY 0004000 223 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ 224 #define IXOFF 0010000 225 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 226 #define IMAXBEL 0020000 227 #define DOSMODE 0100000 /* for 386 compatibility */ 228 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 229 230 /* output modes */ 231 #define OPOST 0000001 232 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 233 defined(__EXTENSIONS__) 234 #if !defined(_XPG6) || defined(__EXTENSIONS__) 235 #define OLCUC 0000002 236 #endif 237 #define ONLCR 0000004 238 #define OCRNL 0000010 239 #define ONOCR 0000020 240 #define ONLRET 0000040 241 #define OFILL 0000100 242 #define OFDEL 0000200 243 #define NLDLY 0000400 244 #define NL0 0 245 #define NL1 0000400 246 #define CRDLY 0003000 247 #define CR0 0 248 #define CR1 0001000 249 #define CR2 0002000 250 #define CR3 0003000 251 #define TABDLY 0014000 252 #define TAB0 0 253 #define TAB1 0004000 254 #define TAB2 0010000 255 #define TAB3 0014000 256 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ 257 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 258 #define XTABS 0014000 259 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 260 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 261 defined(__EXTENSIONS__) 262 #define BSDLY 0020000 263 #define BS0 0 264 #define BS1 0020000 265 #define VTDLY 0040000 266 #define VT0 0 267 #define VT1 0040000 268 #define FFDLY 0100000 269 #define FF0 0 270 #define FF1 0100000 271 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ 272 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 273 #define PAGEOUT 0200000 274 #define WRAP 0400000 275 276 /* control modes */ 277 #define CBAUD 0000017 278 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 279 #define CSIZE 0000060 280 #define CS5 0 281 #define CS6 0000020 282 #define CS7 0000040 283 #define CS8 0000060 284 #define CSTOPB 0000100 285 #define CREAD 0000200 286 #define PARENB 0000400 287 #define PARODD 0001000 288 #define HUPCL 0002000 289 #define CLOCAL 0004000 290 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 291 #define RCV1EN 0010000 292 #define XMT1EN 0020000 293 #define LOBLK 0040000 294 #define XCLUDE 0100000 /* *V7* exclusive use coming fron XENIX */ 295 #define CRTSXOFF 010000000000 296 #define CRTSCTS 020000000000 297 #define CIBAUD 03600000 298 #define PAREXT 04000000 299 #define CBAUDEXT 010000000 300 #define CIBAUDEXT 020000000 301 302 /* 303 * 4.4BSD hardware flow control flags 304 */ 305 #define CRTS_IFLOW 010000000000 306 #define CCTS_OFLOW 020000000000 307 308 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 309 310 /* line discipline 0 modes */ 311 #define ISIG 0000001 312 #define ICANON 0000002 313 #if !defined(_POSIX_C_SOURCE) || \ 314 (defined(_XOPEN_SOURCE) && !defined(_XPG6)) || \ 315 defined(__EXTENSIONS__) 316 #define XCASE 0000004 317 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ 318 #define ECHO 0000010 319 #define ECHOE 0000020 320 #define ECHOK 0000040 321 #define ECHONL 0000100 322 #define NOFLSH 0000200 323 #define TOSTOP 0000400 324 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 325 #define ECHOCTL 0001000 326 #define ECHOPRT 0002000 327 #define ECHOKE 0004000 328 #define DEFECHO 0010000 329 #define FLUSHO 0020000 330 #define PENDIN 0040000 331 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 332 333 #define IEXTEN 0100000 /* POSIX flag - enable POSIX extensions */ 334 #define _TIOC ('T'<<8) 335 336 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 337 338 #define TIOC _TIOC 339 340 #define TCGETA (_TIOC|1) 341 #define TCSETA (_TIOC|2) 342 #define TCSETAW (_TIOC|3) 343 #define TCSETAF (_TIOC|4) 344 #define TCSBRK (_TIOC|5) 345 #define TCXONC (_TIOC|6) 346 #define TCFLSH (_TIOC|7) 347 348 /* Slots reserved for 386/XENIX compatibility - keyboard control */ 349 350 #define TIOCKBON (_TIOC|8) 351 #define TIOCKBOF (_TIOC|9) 352 #define KBENABLED (_TIOC|10) 353 354 #ifndef IOCTYPE 355 #define IOCTYPE 0xff00 356 #endif 357 358 #define TCDSET (_TIOC|32) 359 #define RTS_TOG (_TIOC|33) /* 386 - "RTS" toggle define 8A1 protocol */ 360 361 #define TIOCGWINSZ (_TIOC|104) 362 #define TIOCSWINSZ (_TIOC|103) 363 364 /* 365 * Softcarrier ioctls 366 */ 367 #define TIOCGSOFTCAR (_TIOC|105) 368 #define TIOCSSOFTCAR (_TIOC|106) 369 370 371 /* termios ioctls */ 372 373 #define TCGETS (_TIOC|13) 374 #define TCSETS (_TIOC|14) 375 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 376 #define TCSANOW (_TIOC|14) /* same as TCSETS */ 377 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 378 #define TCSETSW (_TIOC|15) 379 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 380 #define TCSADRAIN (_TIOC|15) /* same as TCSETSW */ 381 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 382 #define TCSETSF (_TIOC|16) 383 384 /* 385 * NTP PPS ioctls 386 */ 387 #define TIOCGPPS (_TIOC|125) 388 #define TIOCSPPS (_TIOC|126) 389 #define TIOCGPPSEV (_TIOC|127) 390 391 /* Argument filled in by TIOCGPPSEV */ 392 struct ppsclockev { 393 struct timeval tv; 394 uint_t serial; 395 }; 396 397 #if defined(_SYSCALL32) 398 struct ppsclockev32 { 399 struct timeval32 tv; 400 uint32_t serial; 401 }; 402 #endif /* _SYSCALL32 */ 403 404 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 405 406 #define TCSAFLUSH (_TIOC|16) /* same as TCSETSF */ 407 408 /* termios option flags */ 409 410 #define TCIFLUSH 0 /* flush data received but not read */ 411 #define TCOFLUSH 1 /* flush data written but not transmitted */ 412 #define TCIOFLUSH 2 /* flush both data both input and output queues */ 413 414 #define TCOOFF 0 /* suspend output */ 415 #define TCOON 1 /* restart suspended output */ 416 #define TCIOFF 2 /* suspend input */ 417 #define TCION 3 /* restart suspended input */ 418 419 /* TIOC ioctls for BSD, ptys, job control and modem control */ 420 421 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 422 #define tIOC ('t'<<8) 423 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 424 425 /* Slots for 386/XENIX compatibility */ 426 /* BSD includes these ioctls in ttold.h */ 427 428 #ifndef _SYS_TTOLD_H 429 430 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 431 #define TIOCGETD (tIOC|0) 432 #define TIOCSETD (tIOC|1) 433 #define TIOCHPCL (tIOC|2) 434 #define TIOCGETP (tIOC|8) 435 #define TIOCSETP (tIOC|9) 436 #define TIOCSETN (tIOC|10) 437 #define TIOCEXCL (tIOC|13) 438 #define TIOCNXCL (tIOC|14) 439 #define TIOCFLUSH (tIOC|16) 440 #define TIOCSETC (tIOC|17) 441 #define TIOCGETC (tIOC|18) 442 /* 443 * BSD ioctls that are not the same as XENIX are included here. 444 * There are also some relevant ioctls from SUN/BSD sys/ttycom.h 445 * BSD pty ioctls like TIOCPKT are not supported in SVR4. 446 */ 447 448 #define TIOCLBIS (tIOC|127) /* bis local mode bits */ 449 #define TIOCLBIC (tIOC|126) /* bic local mode bits */ 450 #define TIOCLSET (tIOC|125) /* set entire local mode word */ 451 #define TIOCLGET (tIOC|124) /* get local modes */ 452 #define TIOCSBRK (tIOC|123) /* set break bit */ 453 #define TIOCCBRK (tIOC|122) /* clear break bit */ 454 #define TIOCSDTR (tIOC|121) /* set data terminal ready */ 455 #define TIOCCDTR (tIOC|120) /* clear data terminal ready */ 456 #define TIOCSLTC (tIOC|117) /* set local special chars */ 457 #define TIOCGLTC (tIOC|116) /* get local special chars */ 458 #define TIOCOUTQ (tIOC|115) /* driver output queue size */ 459 #define TIOCNOTTY (tIOC|113) /* void tty association */ 460 #define TIOCSTOP (tIOC|111) /* stop output, like ^S */ 461 #define TIOCSTART (tIOC|110) /* start output, like ^Q */ 462 #define TIOCSILOOP (tIOC|109) /* 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 566 #ifndef _SYS_TTOLD_H 567 568 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 569 /* Windowing structure to support JWINSIZE/TIOCSWINSZ/TIOCGWINSZ */ 570 struct winsize { 571 unsigned short ws_row; /* rows, in characters */ 572 unsigned short ws_col; /* columns, in character */ 573 unsigned short ws_xpixel; /* horizontal size, pixels */ 574 unsigned short ws_ypixel; /* vertical size, pixels */ 575 }; 576 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 577 578 #endif /* end _SYS_TTOLD_H */ 579 580 #ifdef __cplusplus 581 } 582 #endif 583 584 #endif /* _SYS_TERMIOS_H */ 585