FreeBSD/Linux Kernel Cross Reference
sys/device/tty.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993-1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: tty.h,v $
29 * Revision 2.11 93/11/17 16:35:02 dbg
30 * Changed t_ispeed, t_ospeed to unsigned char to avoid lint.
31 * [93/10/13 dbg]
32 *
33 * Revision 2.10 93/05/30 21:07:59 rvb
34 * Added t_mctl for modem control operations and TS_RTS_DOWN.
35 * [93/05/29 10:07:25 af]
36 *
37 * Revision 2.9 93/02/01 09:46:32 danner
38 * Added TS_MIN_TO_RCV definition.
39 * [93/01/27 danner]
40 *
41 * Revision 2.8 93/01/14 17:27:21 danner
42 * Removed Omron kanji support.... will replace with MI
43 * support at a later date.
44 * [92/12/10 jfriedl]
45 * Added function prototypes.
46 * [92/11/17 dbg]
47 *
48 * Revision 2.7 92/05/05 10:46:22 danner
49 * Made TTYHOG dynamically adjustable.
50 * New flags for delayed char receive.
51 * [92/05/04 11:30:59 af]
52 *
53 * Revision 2.6 91/07/09 23:16:12 danner
54 * Added omron tty specific flags; conditionalized under luna88k.
55 * [91/05/25 danner]
56 *
57 * Revision 2.5 91/05/14 16:02:00 mrt
58 * Correcting copyright
59 *
60 * Revision 2.4 91/02/05 17:10:26 mrt
61 * Changed to new Mach copyright
62 * [91/01/31 17:30:52 mrt]
63 *
64 * Revision 2.3 90/08/27 21:55:44 dbg
65 * Re-created to avoid ownership problems.
66 * [90/07/09 dbg]
67 *
68 */
69 /*
70 * Author: David B. Golub, Carnegie Mellon University
71 * Date: 7/90
72 *
73 * Compatibility TTY structure for existing TTY device drivers.
74 */
75
76 #ifndef _DEVICE_TTY_H_
77 #define _DEVICE_TTY_H_
78
79 #include <kern/lock.h>
80 #include <kern/queue.h>
81 #include <mach/port.h>
82
83 #include <device/device_types.h>
84 #include <device/tty_status.h>
85 #include <device/cirbuf.h>
86 #include <device/io_req.h>
87
88 #ifdef luna88k
89 #include <luna88k/jtermio.h>
90 #endif
91
92 struct tty {
93 decl_simple_lock_data(,t_lock)
94 struct cirbuf t_inq; /* input buffer */
95 struct cirbuf t_outq; /* output buffer */
96 char * t_addr; /* device pointer */
97 int t_dev; /* device number */
98 void (*t_start)(struct tty *);
99 /* routine to start output */
100 #define t_oproc t_start
101 void (*t_stop)(struct tty *, int);
102 /* routine to stop output */
103 int (*t_mctl)(struct tty *, int, int);
104 /* (optional) routine to control
105 modem signals */
106 unsigned char t_ispeed; /* input speed */
107 unsigned char t_ospeed; /* output speed */
108 char t_breakc; /* character to deliver when 'break'
109 condition received */
110 int t_flags; /* mode flags */
111 int t_state; /* current state */
112 int t_line; /* fake line discipline number,
113 for old drivers - always 0 */
114 queue_head_t t_delayed_read; /* pending read requests */
115 queue_head_t t_delayed_write;/* pending write requests */
116 queue_head_t t_delayed_open; /* pending open requests */
117
118 /*
119 * Items beyond this point should be removed to device-specific
120 * extension structures.
121 */
122 int (*t_getstat)(); /* routine to get status */
123 int (*t_setstat)(); /* routine to set status */
124 dev_ops_t t_tops; /* another device to possibly
125 push through */
126 };
127 typedef struct tty *tty_t;
128
129 /*
130 * Common TTY service routines
131 */
132 extern io_return_t char_open(
133 int dev,
134 struct tty * tp,
135 dev_mode_t mode,
136 io_req_t ior);
137
138 extern io_return_t char_read(
139 struct tty * tp,
140 io_req_t ior);
141
142 extern io_return_t char_write(
143 struct tty * tp,
144 io_req_t ior);
145
146 extern void ttyclose(
147 struct tty * tp);
148
149 extern io_return_t tty_get_status(
150 register struct tty *tp,
151 dev_flavor_t flavor,
152 int * data, /* pointer to OUT array */
153 natural_t *count); /* out */
154
155 extern io_return_t tty_set_status(
156 register struct tty *tp,
157 dev_flavor_t flavor,
158 int * data,
159 natural_t count);
160
161 extern void ttyinput(
162 unsigned int c,
163 struct tty * tp);
164
165 extern boolean_t ttymodem(
166 struct tty * tp,
167 boolean_t carrier_up);
168
169 extern void tty_queue_completion(
170 queue_t queue);
171 #define tt_open_wakeup(tp) \
172 (tty_queue_completion(&(tp)->t_delayed_open))
173 #define tt_write_wakeup(tp) \
174 (tty_queue_completion(&(tp)->t_delayed_write))
175
176 extern void ttychars(
177 struct tty * tp);
178
179 extern void tty_cts(
180 struct tty * tp,
181 boolean_t cts_up);
182
183 #define TTMINBUF 90
184
185 short tthiwat[NSPEEDS], ttlowat[NSPEEDS];
186 #define TTHIWAT(tp) tthiwat[(tp)->t_ospeed]
187 #define TTLOWAT(tp) ttlowat[(tp)->t_ospeed]
188
189 /* internal state bits */
190 #define TS_INIT 0x00000001 /* tty structure initialized */
191 #define TS_TIMEOUT 0x00000002 /* delay timeout in progress */
192 #define TS_WOPEN 0x00000004 /* waiting for open to complete */
193 #define TS_ISOPEN 0x00000008 /* device is open */
194 #define TS_FLUSH 0x00000010 /* outq has been flushed during DMA */
195 #define TS_CARR_ON 0x00000020 /* software copy of carrier-present */
196 #define TS_BUSY 0x00000040 /* output in progress */
197 #define TS_ASLEEP 0x00000080 /* wakeup when output done */
198
199 #define TS_TTSTOP 0x00000100 /* output stopped by ctl-s */
200 #define TS_HUPCLS 0x00000200 /* hang up upon last close */
201 #define TS_TBLOCK 0x00000400 /* tandem queue blocked */
202
203 #define TS_NBIO 0x00001000 /* tty in non-blocking mode */
204 #define TS_ONDELAY 0x00002000 /* device is open; software copy of
205 * carrier is not present */
206 #define TS_MIN 0x00004000 /* buffer input chars, if possible */
207 #define TS_MIN_TO 0x00008000 /* timeout for the above is active */
208
209 #define TS_OUT 0x00010000 /* tty in use for dialout only */
210 #define TS_RTS_DOWN 0x00020000 /* modem pls stop */
211
212 #define TS_TRANSLATE 0x00100000 /* translation device enabled */
213 #define TS_KDB 0x00200000 /* should enter kdb on ALT */
214
215 #define TS_MIN_TO_RCV 0x00400000 /* character recived during
216 receive timeout interval */
217
218 /* flags - old names defined in terms of new ones */
219
220 #define TANDEM TF_TANDEM
221 #define ODDP TF_ODDP
222 #define EVENP TF_EVENP
223 #define ANYP (ODDP|EVENP)
224 #define MDMBUF TF_MDMBUF
225 #define LITOUT TF_LITOUT
226 #define NOHANG TF_NOHANG
227
228 #define ECHO TF_ECHO
229 #define CRMOD TF_CRMOD
230 #define XTABS TF_XTABS
231
232 /* these are here only to let old code compile - they are never set */
233 #define RAW LITOUT
234 #define PASS8 LITOUT
235
236 /*
237 * Hardware bits.
238 * SHOULD NOT BE HERE.
239 */
240 #define DONE 0200
241 #define IENABLE 0100
242
243 /*
244 * Modem control commands.
245 */
246 #define DMSET 0
247 #define DMBIS 1
248 #define DMBIC 2
249 #define DMGET 3
250
251 /*
252 * Fake 'line discipline' switch, for the benefit of old code
253 * that wants to call through it.
254 */
255 struct ldisc_switch {
256 int (*l_read) (struct tty *, io_req_t); /* read */
257 int (*l_write)(struct tty *, io_req_t); /* write */
258 void (*l_rint) (unsigned int, struct tty *); /* character input */
259 boolean_t (*l_modem)(struct tty *, boolean_t); /* modem change */
260 void (*l_start)(struct tty *); /* start output */
261 };
262
263 extern struct ldisc_switch linesw[];
264
265 #endif /* _DEVICE_TTY_H_ */
Cache object: 06259ff97a1370e9089bd349fddd9dce
|