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