1 /* tty.h 6.1 83/07/29 */ 2 3 #ifdef KERNEL 4 #include "../h/ttychars.h" 5 #include "../h/ttydev.h" 6 #else 7 #include <sys/ttychars.h> 8 #include <sys/ttydev.h> 9 #endif 10 11 /* 12 * A clist structure is the head of a linked list queue 13 * of characters. The characters are stored in blocks 14 * containing a link and CBSIZE (param.h) characters. 15 * The routines in tty_subr.c manipulate these structures. 16 */ 17 struct clist { 18 int c_cc; /* character count */ 19 char *c_cf; /* pointer to first char */ 20 char *c_cl; /* pointer to last char */ 21 }; 22 23 /* 24 * Per-tty structure. 25 * 26 * Should be split in two, into device and tty drivers. 27 * Glue could be masks of what to echo and circular buffer 28 * (low, high, timeout). 29 */ 30 struct tty { 31 union { 32 struct { 33 struct clist T_rawq; 34 struct clist T_canq; 35 } t_t; 36 #define t_rawq t_nu.t_t.T_rawq /* raw characters or partial line */ 37 #define t_canq t_nu.t_t.T_canq /* raw characters or partial line */ 38 struct { 39 struct buf *T_bufp; 40 char *T_cp; 41 int T_inbuf; 42 int T_rec; 43 } t_n; 44 #define t_bufp t_nu.t_n.T_bufp /* buffer allocated to protocol */ 45 #define t_cp t_nu.t_n.T_cp /* pointer into the ripped off buffer */ 46 #define t_inbuf t_nu.t_n.T_inbuf /* number chars in the buffer */ 47 #define t_rec t_nu.t_n.T_rec /* have a complete record */ 48 } t_nu; 49 struct clist t_outq; /* device */ 50 int (*t_oproc)(); /* device */ 51 struct proc *t_rsel; /* tty */ 52 struct proc *t_wsel; 53 caddr_t T_LINEP; /* ### */ 54 caddr_t t_addr; /* ??? */ 55 dev_t t_dev; /* device */ 56 int t_flags; /* some of both */ 57 int t_state; /* some of both */ 58 short t_pgrp; /* tty */ 59 char t_delct; /* tty */ 60 char t_line; /* glue */ 61 char t_col; /* tty */ 62 char t_ispeed, t_ospeed; /* device */ 63 char t_rocount, t_rocol; /* tty */ 64 struct ttychars t_chars; /* tty */ 65 /* be careful of tchars & co. */ 66 #define t_erase t_chars.tc_erase 67 #define t_kill t_chars.tc_kill 68 #define t_intrc t_chars.tc_intrc 69 #define t_quitc t_chars.tc_quitc 70 #define t_startc t_chars.tc_startc 71 #define t_stopc t_chars.tc_stopc 72 #define t_eofc t_chars.tc_eofc 73 #define t_brkc t_chars.tc_brkc 74 #define t_suspc t_chars.tc_suspc 75 #define t_dsuspc t_chars.tc_dsuspc 76 #define t_rprntc t_chars.tc_rprntc 77 #define t_flushc t_chars.tc_flushc 78 #define t_werasc t_chars.tc_werasc 79 #define t_lnextc t_chars.tc_lnextc 80 }; 81 82 #define TTIPRI 28 83 #define TTOPRI 29 84 85 /* limits */ 86 #define NSPEEDS 16 87 #define TTMASK 15 88 #define OBUFSIZ 100 89 #define TTYHOG 255 90 #ifdef KERNEL 91 short tthiwat[NSPEEDS], ttlowat[NSPEEDS]; 92 #define TTHIWAT(tp) tthiwat[(tp)->t_ospeed&TTMASK] 93 #define TTLOWAT(tp) ttlowat[(tp)->t_ospeed&TTMASK] 94 extern struct ttychars ttydefaults; 95 #endif 96 97 /* internal state bits */ 98 #define TS_TIMEOUT 0x000001 /* delay timeout in progress */ 99 #define TS_WOPEN 0x000002 /* waiting for open to complete */ 100 #define TS_ISOPEN 0x000004 /* device is open */ 101 #define TS_FLUSH 0x000008 /* outq has been flushed during DMA */ 102 #define TS_CARR_ON 0x000010 /* software copy of carrier-present */ 103 #define TS_BUSY 0x000020 /* output in progress */ 104 #define TS_ASLEEP 0x000040 /* wakeup when output done */ 105 #define TS_XCLUDE 0x000080 /* exclusive-use flag against open */ 106 #define TS_TTSTOP 0x000100 /* output stopped by ctl-s */ 107 #define TS_HUPCLS 0x000200 /* hang up upon last close */ 108 #define TS_TBLOCK 0x000400 /* tandem queue blocked */ 109 #define TS_RCOLL 0x000800 /* collision in read select */ 110 #define TS_WCOLL 0x001000 /* collision in write select */ 111 #define TS_NBIO 0x002000 /* tty in non-blocking mode */ 112 #define TS_ASYNC 0x004000 /* tty in async i/o mode */ 113 /* state for intra-line fancy editing work */ 114 #define TS_BKSL 0x010000 /* state for lowercase \ work */ 115 #define TS_QUOT 0x020000 /* last character input was \ */ 116 #define TS_ERASE 0x040000 /* within a \.../ for PRTRUB */ 117 #define TS_LNCH 0x080000 /* next character is literal */ 118 #define TS_TYPEN 0x100000 /* retyping suspended input (PENDIN) */ 119 #define TS_CNTTB 0x200000 /* counting tab width; leave FLUSHO alone */ 120 121 #define TS_LOCAL (TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB) 122 123 /* define partab character types */ 124 #define ORDINARY 0 125 #define CONTROL 1 126 #define BACKSPACE 2 127 #define NEWLINE 3 128 #define TAB 4 129 #define VTAB 5 130 #define RETURN 6 131