Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
1810611d | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
da7c5cc6 KM |
3 | * All rights reserved. The Berkeley software License Agreement |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
1c15e888 | 6 | * @(#)tty.h 7.7 (Berkeley) 6/28/90 |
da7c5cc6 | 7 | */ |
db73782e | 8 | |
a5523103 | 9 | #ifdef KERNEL |
1c15e888 | 10 | #include "termios.h" |
a5523103 | 11 | #else |
e84b8d0c | 12 | #include <sys/termios.h> |
a5523103 | 13 | #endif |
db73782e | 14 | |
2b00f3eb | 15 | /* |
ef62b42a SL |
16 | * A clist structure is the head of a linked list queue |
17 | * of characters. The characters are stored in blocks | |
18 | * containing a link and CBSIZE (param.h) characters. | |
19 | * The routines in tty_subr.c manipulate these structures. | |
2b00f3eb | 20 | */ |
0e118a41 | 21 | struct clist { |
2b00f3eb BJ |
22 | int c_cc; /* character count */ |
23 | char *c_cf; /* pointer to first char */ | |
24 | char *c_cl; /* pointer to last char */ | |
25 | }; | |
26 | ||
27 | /* | |
ef62b42a | 28 | * Per-tty structure. |
0e118a41 BJ |
29 | * |
30 | * Should be split in two, into device and tty drivers. | |
31 | * Glue could be masks of what to echo and circular buffer | |
32 | * (low, high, timeout). | |
2b00f3eb | 33 | */ |
ef62b42a | 34 | struct tty { |
a6ec0194 | 35 | struct clist t_rawq; /* queues */ |
9a8640e6 | 36 | struct clist t_canq; |
a6ec0194 | 37 | struct clist t_outq; |
0e118a41 | 38 | int (*t_oproc)(); /* device */ |
e84b8d0c | 39 | int (*t_param)(); /* device */ |
0e118a41 | 40 | struct proc *t_rsel; /* tty */ |
763be356 | 41 | struct proc *t_wsel; |
9a8640e6 | 42 | caddr_t T_LINEP; /* XXX */ |
0e118a41 BJ |
43 | caddr_t t_addr; /* ??? */ |
44 | dev_t t_dev; /* device */ | |
9a8640e6 | 45 | int t_flags; /* (compat) some of both */ |
ef62b42a | 46 | int t_state; /* some of both */ |
9a8640e6 | 47 | struct session *t_session; /* tty */ |
4423da70 | 48 | struct pgrp *t_pgrp; /* foreground process group */ |
0e118a41 | 49 | char t_line; /* glue */ |
a6ec0194 MT |
50 | short t_col; /* tty */ |
51 | short t_rocount, t_rocol; /* tty */ | |
e84b8d0c MT |
52 | short t_hiwat; /* hi water mark */ |
53 | short t_lowat; /* low water mark */ | |
5dd8d0d3 | 54 | struct winsize t_winsize; /* window size */ |
e84b8d0c MT |
55 | struct termios t_termios; /* termios state */ |
56 | #define t_iflag t_termios.c_iflag | |
57 | #define t_oflag t_termios.c_oflag | |
58 | #define t_cflag t_termios.c_cflag | |
59 | #define t_lflag t_termios.c_lflag | |
60 | #define t_min t_termios.c_min | |
61 | #define t_time t_termios.c_time | |
62 | #define t_cc t_termios.c_cc | |
63 | #define t_ispeed t_termios.c_ispeed | |
64 | #define t_ospeed t_termios.c_ospeed | |
65 | long t_cancc; /* stats */ | |
66 | long t_rawcc; | |
67 | long t_outcc; | |
a6ec0194 | 68 | short t_gen; /* generation number */ |
2b00f3eb BJ |
69 | }; |
70 | ||
2b00f3eb BJ |
71 | #define TTIPRI 28 |
72 | #define TTOPRI 29 | |
73 | ||
2b00f3eb | 74 | /* limits */ |
2e210196 | 75 | #define TTMASK 15 |
ef62b42a | 76 | #define OBUFSIZ 100 |
cd15446f | 77 | #define TTYHOG 1024 |
2e210196 | 78 | #ifdef KERNEL |
e84b8d0c MT |
79 | #define TTMAXHIWAT roundup(2048, CBSIZE) |
80 | #define TTMINHIWAT roundup(100, CBSIZE) | |
81 | #define TTMAXLOWAT 256 | |
82 | #define TTMINLOWAT 32 | |
ef62b42a | 83 | extern struct ttychars ttydefaults; |
e84b8d0c | 84 | #endif /*KERNEL*/ |
2b00f3eb | 85 | |
db73782e | 86 | /* internal state bits */ |
ef62b42a SL |
87 | #define TS_TIMEOUT 0x000001 /* delay timeout in progress */ |
88 | #define TS_WOPEN 0x000002 /* waiting for open to complete */ | |
89 | #define TS_ISOPEN 0x000004 /* device is open */ | |
90 | #define TS_FLUSH 0x000008 /* outq has been flushed during DMA */ | |
91 | #define TS_CARR_ON 0x000010 /* software copy of carrier-present */ | |
92 | #define TS_BUSY 0x000020 /* output in progress */ | |
93 | #define TS_ASLEEP 0x000040 /* wakeup when output done */ | |
94 | #define TS_XCLUDE 0x000080 /* exclusive-use flag against open */ | |
95 | #define TS_TTSTOP 0x000100 /* output stopped by ctl-s */ | |
96 | #define TS_HUPCLS 0x000200 /* hang up upon last close */ | |
97 | #define TS_TBLOCK 0x000400 /* tandem queue blocked */ | |
98 | #define TS_RCOLL 0x000800 /* collision in read select */ | |
99 | #define TS_WCOLL 0x001000 /* collision in write select */ | |
ef62b42a SL |
100 | #define TS_ASYNC 0x004000 /* tty in async i/o mode */ |
101 | /* state for intra-line fancy editing work */ | |
102 | #define TS_BKSL 0x010000 /* state for lowercase \ work */ | |
ef62b42a SL |
103 | #define TS_ERASE 0x040000 /* within a \.../ for PRTRUB */ |
104 | #define TS_LNCH 0x080000 /* next character is literal */ | |
105 | #define TS_TYPEN 0x100000 /* retyping suspended input (PENDIN) */ | |
e84b8d0c | 106 | #define TS_CNTTB 0x200000 /* counting tab width, leave FLUSHO alone */ |
ef62b42a | 107 | |
e84b8d0c | 108 | #define TS_LOCAL (TS_BKSL|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB) |
2b00f3eb | 109 | |
db73782e BJ |
110 | /* define partab character types */ |
111 | #define ORDINARY 0 | |
112 | #define CONTROL 1 | |
113 | #define BACKSPACE 2 | |
114 | #define NEWLINE 3 | |
115 | #define TAB 4 | |
116 | #define VTAB 5 | |
117 | #define RETURN 6 | |
9a8640e6 MT |
118 | |
119 | struct speedtab { | |
120 | int sp_speed; | |
121 | int sp_code; | |
122 | }; | |
123 | /* | |
124 | * Flags on character passed to ttyinput | |
125 | */ | |
126 | #define TTY_CHARMASK 0x000000ff /* Character mask */ | |
127 | #define TTY_QUOTE 0x00000100 /* Character quoted */ | |
128 | #define TTY_ERRORMASK 0xff000000 /* Error mask */ | |
129 | #define TTY_FE 0x01000000 /* Framing error or BREAK condition */ | |
130 | #define TTY_PE 0x02000000 /* Parity error */ | |
131 | ||
4423da70 | 132 | /* |
a6ec0194 | 133 | * Is tp controlling terminal for p |
4423da70 MT |
134 | */ |
135 | #define isctty(p, tp) ((p)->p_session == (tp)->t_session && \ | |
136 | (p)->p_flag&SCTTY) | |
a6ec0194 MT |
137 | /* |
138 | * Is p in background of tp | |
139 | */ | |
4423da70 MT |
140 | #define isbackground(p, tp) (isctty((p), (tp)) && \ |
141 | (p)->p_pgrp != (tp)->t_pgrp) | |
9a8640e6 MT |
142 | /* |
143 | * Modem control commands (driver). | |
144 | */ | |
145 | #define DMSET 0 | |
146 | #define DMBIS 1 | |
147 | #define DMBIC 2 | |
148 | #define DMGET 3 | |
cd15446f MK |
149 | |
150 | #ifdef KERNEL | |
151 | /* symbolic sleep message strings */ | |
152 | extern char ttyin[], ttyout[], ttopen[], ttclos[], ttybg[], ttybuf[]; | |
153 | #endif |