1 /* 2 * Copyright 1991-1998 by Open Software Foundation, Inc. 3 * All Rights Reserved 4 * 5 * Permission to use, copy, modify, and distribute this software and 6 * its documentation for any purpose and without fee is hereby granted, 7 * provided that the above copyright notice appears in all copies and 8 * that both the copyright notice and this permission notice appear in 9 * supporting documentation. 10 * 11 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 12 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 * FOR A PARTICULAR PURPOSE. 14 * 15 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 16 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 17 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 18 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 19 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 /* 22 * MkLinux 23 */ 24 /* CMU_HIST */ 25 /* 26 * Revision 2.6.3.2 92/04/30 11:49:25 bernadat 27 * 16-Apr-92 emcmanusat gr.osf.org 28 * Define TQ_FLUSHED. 29 * [92/04/22 09:59:57 bernadat] 30 * 31 * Revision 2.6.3.1 92/03/28 10:05:02 jeffreyh 32 * 04-Mar-92 emcmanus at gr.osf.org 33 * Support for out-of-band events: definitions for character quoting 34 * in the input queue, new tty fields to store events. 35 * [92/03/10 07:56:12 bernadat] 36 * 37 * Revision 2.6 91/07/09 23:16:12 danner 38 * Added omron tty specific flags; conditionalized under luna88k. 39 * [91/05/25 danner] 40 * 41 * Revision 2.5 91/05/14 16:02:00 mrt 42 * Correcting copyright 43 * 44 * Revision 2.4 91/02/05 17:10:26 mrt 45 * Changed to new Mach copyright 46 * [91/01/31 17:30:52 mrt] 47 * 48 * Revision 2.3 90/08/27 21:55:44 dbg 49 * Re-created to avoid ownership problems. 50 * [90/07/09 dbg] 51 * 52 */ 53 /* CMU_ENDHIST */ 54 55 /* 56 *(C)UNIX System Laboratories, Inc. all or some portions of this file are 57 *derived from material licensed to the University of California by 58 *American Telephone and Telegraph Co. or UNIX System Laboratories, 59 *Inc. and are reproduced herein with the permission of UNIX System 60 *Laboratories, Inc. 61 */ 62 63 /* 64 * Mach Operating System 65 * Copyright (c) 1991,1990 Carnegie Mellon University 66 * All Rights Reserved. 67 * 68 * Permission to use, copy, modify and distribute this software and its 69 * documentation is hereby granted, provided that both the copyright 70 * notice and this permission notice appear in all copies of the 71 * software, derivative works or modified versions, and any portions 72 * thereof, and that both notices appear in supporting documentation. 73 * 74 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 75 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 76 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 77 * 78 * Carnegie Mellon requests users of this software to return to 79 * 80 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 81 * School of Computer Science 82 * Carnegie Mellon University 83 * Pittsburgh PA 15213-3890 84 * 85 * any improvements or extensions that they make and grant Carnegie Mellon 86 * the rights to redistribute these changes. 87 */ 88 /* 89 */ 90 /* 91 * Author: David B. Golub, Carnegie Mellon University 92 * Date: 7/90 93 * 94 * Compatibility TTY structure for existing TTY device drivers. 95 */ 96 97 #ifndef _DEVICE_TTY_H_ 98 #define _DEVICE_TTY_H_ 99 100 #include <kern/lock.h> 101 #include <kern/queue.h> 102 #include <mach/port.h> 103 104 #include <device/io_req.h> 105 #include <device/device_types.h> 106 #ifdef luna88k 107 #include <luna88k/jtermio.h> 108 #endif 109 #include <device/tty_status.h> 110 #include <device/cirbuf.h> 111 #include <device/buf.h> 112 113 struct tty { 114 decl_simple_lock_data(,t_lock) 115 struct cirbuf t_inq; /* input buffer */ 116 struct cirbuf t_outq; /* output buffer */ 117 char * t_addr; /* device pointer */ 118 int t_dev; /* device number */ 119 void (*t_start)( /* routine to start output */ 120 struct tty * tp); 121 #define t_oproc t_start 122 void (*t_stop)( /* routine to stop output */ 123 struct tty * tp, 124 int flags); 125 int (*t_mctl)( /* (optional) routine to control 126 modem signals */ 127 struct tty * tp, 128 int bits, 129 int how); 130 int t_ispeed; /* input speed */ 131 int t_ospeed; /* output speed */ 132 char t_breakc; /* character to deliver when 'break' 133 condition received */ 134 int t_flags; /* mode flags */ 135 int t_state; /* current state */ 136 int t_line; /* fake line discipline number, 137 for old drivers - always 0 */ 138 int t_outofband; /* current out-of-band events */ 139 int t_outofbandarg; /* arg to first out-of-band event */ 140 int t_nquoted; /* number of quoted chars in inq */ 141 int t_hiwater; /* baud-rate limited high water mark */ 142 int t_lowater; /* baud-rate limited low water mark */ 143 queue_head_t t_delayed_read; /* pending read requests */ 144 queue_head_t t_delayed_write;/* pending write requests */ 145 queue_head_t t_delayed_open; /* pending open requests */ 146 147 io_return_t (*t_getstat)( /* routine to get status */ 148 dev_t dev, 149 dev_flavor_t flavor, 150 dev_status_t data, 151 natural_t * count); 152 #ifdef luna 153 struct jterm t_jt; 154 short t_jstate; 155 char t_term; /* terminal type */ 156 char t_tmflag; /* t_tmflag */ 157 unsigned short t_omron; /* OMRON extended flags */ 158 int *t_kfptr; 159 #endif /* luna */ 160 io_return_t (*t_setstat)( /* routine to set status */ 161 dev_t dev, 162 dev_flavor_t flavor, 163 dev_status_t data, 164 natural_t count); 165 dev_ops_t t_tops; /* another device to possibly 166 push through */ 167 }; 168 typedef struct tty *tty_t; 169 170 /* 171 * Common TTY service routines 172 */ 173 extern io_return_t char_open( 174 dev_t dev, 175 struct tty * tp, 176 dev_mode_t mode, 177 io_req_t ior); 178 extern io_return_t char_read( 179 struct tty * tp, 180 io_req_t ior); 181 extern io_return_t char_write( 182 struct tty * tp, 183 io_req_t ior); 184 extern void tty_queue_completion( 185 queue_t qh); 186 extern boolean_t tty_queueempty( 187 struct tty * tp, 188 int queue); 189 190 #define tt_open_wakeup(tp) \ 191 (tty_queue_completion(&(tp)->t_delayed_open)) 192 #define tt_write_wakeup(tp) \ 193 (tty_queue_completion(&(tp)->t_delayed_write)) 194 195 /* 196 * Structure used to store baud rate specific information 197 */ 198 struct baud_rate_info { 199 int br_rate; 200 int br_info; 201 }; 202 typedef struct baud_rate_info *baud_rate_info_t; 203 204 extern int baud_rate_get_info(int, baud_rate_info_t); 205 206 #define OBUFSIZ 100 207 #define TTMINBUF 90 208 209 /* internal state bits */ 210 #define TS_INIT 0x00000001 /* tty structure initialized */ 211 #define TS_TIMEOUT 0x00000002 /* delay timeout in progress */ 212 #define TS_WOPEN 0x00000004 /* waiting for open to complete */ 213 #define TS_ISOPEN 0x00000008 /* device is open */ 214 #define TS_FLUSH 0x00000010 /* outq has been flushed during DMA */ 215 #define TS_CARR_ON 0x00000020 /* software copy of carrier-present */ 216 #define TS_BUSY 0x00000040 /* output in progress */ 217 #define TS_ASLEEP 0x00000080 /* wakeup when output done */ 218 219 #define TS_TTSTOP 0x00000100 /* output stopped by ctl-s */ 220 #define TS_HUPCLS 0x00000200 /* hang up upon last close */ 221 #define TS_TBLOCK 0x00000400 /* tandem queue blocked */ 222 223 #define TS_NBIO 0x00001000 /* tty in non-blocking mode */ 224 #define TS_ONDELAY 0x00002000 /* device is open; software copy of 225 * carrier is not present */ 226 #define TS_MIN 0x00004000 /* buffer input chars, if possible */ 227 #define TS_MIN_TO 0x00008000 /* timeout for the above is active */ 228 229 #define TS_OUT 0x00010000 /* tty in use for dialout only */ 230 #define TS_RTS_DOWN 0x00020000 /* modem pls stop */ 231 232 #define TS_TRANSLATE 0x00100000 /* translation device enabled */ 233 #define TS_KDB 0x00200000 /* should enter kdb on ALT */ 234 235 /* flags - old names defined in terms of new ones */ 236 237 #define TANDEM TF_TANDEM 238 #define ODDP TF_ODDP 239 #define EVENP TF_EVENP 240 #define ANYP (ODDP|EVENP) 241 #define MDMBUF TF_MDMBUF 242 #define LITOUT TF_LITOUT 243 #define NOHANG TF_NOHANG 244 245 #define ECHO TF_ECHO 246 #define CRMOD TF_CRMOD 247 #define XTABS TF_XTABS 248 #define CRTSCTS TF_CRTSCTS 249 250 /* these are here only to let old code compile - they are never set */ 251 #define RAW LITOUT 252 #define PASS8 LITOUT 253 254 /* 255 * Hardware bits. 256 * SHOULD NOT BE HERE. 257 */ 258 #define DONE 0200 259 #define IENABLE 0100 260 261 /* 262 * Modem control commands. 263 */ 264 #define DMSET 0 265 #define DMBIS 1 266 #define DMBIC 2 267 #define DMGET 3 268 269 /* 270 * Fake 'line discipline' switch, for the benefit of old code 271 * that wants to call through it. 272 */ 273 struct ldisc_switch { 274 int (*l_read)( /* read */ 275 struct tty * tp, 276 struct uio * uio); 277 int (*l_write)( /* write */ 278 struct tty * tp, 279 struct uio * uio); 280 void (*l_rint)( /* single character input */ 281 unsigned int ch, 282 struct tty * tp); 283 int (*l_modem)( /* modem change */ 284 struct tty * tp, 285 int flag); 286 void (*l_start)(void);/* start output */ 287 }; 288 289 extern struct ldisc_switch linesw[]; 290 291 /* 292 * Character quoting, so we can sneak out-of-band events like break into 293 * the input queue. 294 */ 295 #define TTY_QUOTEC ((char)0377) 296 enum {TQ_QUOTEC, TQ_BREAK, TQ_BAD_PARITY, TQ_FLUSHED}; 297 /* Things that follow TTY_QUOTEC. */ 298 299 extern void ttychars( 300 struct tty * tp); 301 extern void ttydrain( 302 struct tty * tp); 303 extern void ttyclose( 304 struct tty * tp); 305 extern boolean_t tty_portdeath( 306 struct tty * tp, 307 ipc_port_t port); 308 extern io_return_t tty_get_status( 309 struct tty * tp, 310 dev_flavor_t flavor, 311 dev_status_t data, 312 mach_msg_type_number_t * count); 313 extern io_return_t tty_set_status( 314 struct tty * tp, 315 dev_flavor_t flavor, 316 dev_status_t data, 317 mach_msg_type_number_t count); 318 extern boolean_t ttymodem( 319 struct tty * tp, 320 int flag); 321 extern void ttyoutput( 322 unsigned c, 323 struct tty * tp); 324 extern void ttyinput( 325 unsigned int ch, 326 struct tty * tp); 327 extern void ttybreak( 328 int ch, 329 struct tty * tp); 330 extern void ttyinputbadparity( 331 int ch, 332 struct tty * tp); 333 extern void ttrstrt( 334 struct tty * tp); 335 extern void ttstart( 336 struct tty * tp); 337 extern void ttyflush( 338 struct tty * tp, 339 int rw); 340 extern int TTLOWAT( 341 struct tty * tp); 342 extern void tty_cts( 343 struct tty * tp, 344 boolean_t cts_up); 345 346 #endif /* _DEVICE_TTY_H_ */ 347 348