|
|
1.1 root 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 [email protected]
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: * Author: David B. Golub, Carnegie Mellon University
28: * Date: 7/90
29: *
30: * Compatibility TTY structure for existing TTY device drivers.
31: */
32:
33: #ifndef _DEVICE_TTY_H_
34: #define _DEVICE_TTY_H_
35:
36: #include <kern/lock.h>
37: #include <kern/queue.h>
38: #include <mach/port.h>
39:
40: #include <device/device_types.h>
41: #include <device/tty_status.h>
42: #include <device/cirbuf.h>
43: #include <device/io_req.h>
44:
45: struct tty {
46: decl_simple_lock_data(,t_lock)
47: struct cirbuf t_inq; /* input buffer */
48: struct cirbuf t_outq; /* output buffer */
49: char * t_addr; /* device pointer */
50: int t_dev; /* device number */
1.1.1.2 root 51: void (*t_start)(struct tty *);
1.1 root 52: /* routine to start output */
53: #define t_oproc t_start
1.1.1.2 root 54: void (*t_stop)(struct tty *, int);
1.1 root 55: /* routine to stop output */
56: int (*t_mctl)(struct tty *, int, int);
57: /* (optional) routine to control
58: modem signals */
1.1.1.2 root 59: unsigned char t_ispeed; /* input speed */
60: unsigned char t_ospeed; /* output speed */
1.1 root 61: char t_breakc; /* character to deliver when 'break'
62: condition received */
63: int t_flags; /* mode flags */
64: int t_state; /* current state */
65: int t_line; /* fake line discipline number,
66: for old drivers - always 0 */
67: queue_head_t t_delayed_read; /* pending read requests */
68: queue_head_t t_delayed_write;/* pending write requests */
69: queue_head_t t_delayed_open; /* pending open requests */
70:
71: /*
72: * Items beyond this point should be removed to device-specific
73: * extension structures.
74: */
1.1.1.3 ! root 75: io_return_t (*t_getstat)(dev_t, int, int *, natural_t *); /* routine to get status */
! 76: io_return_t (*t_setstat)(dev_t, int, int *, natural_t); /* routine to set status */
1.1 root 77: dev_ops_t t_tops; /* another device to possibly
78: push through */
79: };
80: typedef struct tty *tty_t;
81:
82: /*
83: * Common TTY service routines
84: */
85: extern io_return_t char_open(
86: int dev,
87: struct tty * tp,
88: dev_mode_t mode,
89: io_req_t ior);
90:
91: extern io_return_t char_read(
92: struct tty * tp,
93: io_req_t ior);
94:
95: extern io_return_t char_write(
96: struct tty * tp,
97: io_req_t ior);
98:
99: extern void ttyinput(
100: unsigned int c,
101: struct tty * tp);
102:
1.1.1.2 root 103: extern void ttyinput_many(
104: struct tty * tp,
105: char * chars,
106: int count);
107:
1.1 root 108: extern boolean_t ttymodem(
109: struct tty * tp,
110: boolean_t carrier_up);
111:
1.1.1.2 root 112: extern void tty_cts(
113: struct tty * tp,
114: boolean_t cts_up);
115:
1.1 root 116: extern void tty_queue_completion(
117: queue_t queue);
118: #define tt_open_wakeup(tp) \
119: (tty_queue_completion(&(tp)->t_delayed_open))
120: #define tt_write_wakeup(tp) \
121: (tty_queue_completion(&(tp)->t_delayed_write))
122:
123: extern void ttychars(
124: struct tty * tp);
125:
126: #define TTMINBUF 90
127:
128: short tthiwat[NSPEEDS], ttlowat[NSPEEDS];
129: #define TTHIWAT(tp) tthiwat[(tp)->t_ospeed]
130: #define TTLOWAT(tp) ttlowat[(tp)->t_ospeed]
131:
1.1.1.2 root 132: extern io_return_t tty_get_status(
133: struct tty * tp,
134: dev_flavor_t flavor,
135: int * data,
136: natural_t * count);
137:
138: extern io_return_t tty_set_status(
139: struct tty * tp,
140: dev_flavor_t flavor,
141: int * data,
142: natural_t count);
143:
144: extern void tty_flush(
145: struct tty * tp,
146: int rw);
147:
148: extern void ttrstrt(
149: struct tty * tp);
150:
151: extern void ttstart(
152: struct tty * tp);
153:
154: extern void ttyclose(
155: struct tty * tp);
156:
157: extern boolean_t tty_portdeath(
158: struct tty * tp,
159: ipc_port_t port);
160:
1.1 root 161: /* internal state bits */
162: #define TS_INIT 0x00000001 /* tty structure initialized */
163: #define TS_TIMEOUT 0x00000002 /* delay timeout in progress */
164: #define TS_WOPEN 0x00000004 /* waiting for open to complete */
165: #define TS_ISOPEN 0x00000008 /* device is open */
166: #define TS_FLUSH 0x00000010 /* outq has been flushed during DMA */
167: #define TS_CARR_ON 0x00000020 /* software copy of carrier-present */
168: #define TS_BUSY 0x00000040 /* output in progress */
169: #define TS_ASLEEP 0x00000080 /* wakeup when output done */
170:
171: #define TS_TTSTOP 0x00000100 /* output stopped by ctl-s */
172: #define TS_HUPCLS 0x00000200 /* hang up upon last close */
173: #define TS_TBLOCK 0x00000400 /* tandem queue blocked */
174:
175: #define TS_NBIO 0x00001000 /* tty in non-blocking mode */
176: #define TS_ONDELAY 0x00002000 /* device is open; software copy of
177: * carrier is not present */
178: #define TS_MIN 0x00004000 /* buffer input chars, if possible */
179: #define TS_MIN_TO 0x00008000 /* timeout for the above is active */
180:
181: #define TS_OUT 0x00010000 /* tty in use for dialout only */
182: #define TS_RTS_DOWN 0x00020000 /* modem pls stop */
183:
184: #define TS_TRANSLATE 0x00100000 /* translation device enabled */
185: #define TS_KDB 0x00200000 /* should enter kdb on ALT */
186:
1.1.1.3 ! root 187: #define TS_MIN_TO_RCV 0x00400000 /* character received during
1.1 root 188: receive timeout interval */
189:
190: /* flags - old names defined in terms of new ones */
191:
192: #define TANDEM TF_TANDEM
193: #define ODDP TF_ODDP
194: #define EVENP TF_EVENP
195: #define ANYP (ODDP|EVENP)
196: #define MDMBUF TF_MDMBUF
197: #define LITOUT TF_LITOUT
198: #define NOHANG TF_NOHANG
199:
200: #define ECHO TF_ECHO
201: #define CRMOD TF_CRMOD
202: #define XTABS TF_XTABS
203:
204: /* these are here only to let old code compile - they are never set */
205: #define RAW LITOUT
206: #define PASS8 LITOUT
207:
208: /*
209: * Hardware bits.
210: * SHOULD NOT BE HERE.
211: */
212: #define DONE 0200
213: #define IENABLE 0100
214:
215: /*
216: * Modem control commands.
217: */
218: #define DMSET 0
219: #define DMBIS 1
220: #define DMBIC 2
221: #define DMGET 3
222:
223: /*
224: * Fake 'line discipline' switch, for the benefit of old code
225: * that wants to call through it.
226: */
227: struct ldisc_switch {
228: int (*l_read) (struct tty *, io_req_t); /* read */
229: int (*l_write)(struct tty *, io_req_t); /* write */
230: void (*l_rint) (unsigned int, struct tty *); /* character input */
231: boolean_t (*l_modem)(struct tty *, boolean_t); /* modem change */
232: void (*l_start)(struct tty *); /* start output */
233: };
234:
235: extern struct ldisc_switch linesw[];
236:
237: #endif /* _DEVICE_TTY_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.