1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)tty.h 7.2 (Berkeley) 10/18/88 7 */ 8 9 #ifdef KERNEL 10 #include "ttychars.h" 11 #include "ttydev.h" 12 #include "termios.h" 13 #else 14 #include <sys/ttychars.h> 15 #include <sys/ttydev.h> 16 #include <sys/termios.h> 17 #endif 18 19 /* 20 * A clist structure is the head of a linked list queue 21 * of characters. The characters are stored in blocks 22 * containing a link and CBSIZE (param.h) characters. 23 * The routines in tty_subr.c manipulate these structures. 24 */ 25 struct clist { 26 int c_cc; /* character count */ 27 char *c_cf; /* pointer to first char */ 28 char *c_cl; /* pointer to last char */ 29 }; 30 31 /* 32 * Per-tty structure. 33 * 34 * Should be split in two, into device and tty drivers. 35 * Glue could be masks of what to echo and circular buffer 36 * (low, high, timeout). 37 */ 38 struct tty { 39 union { 40 struct { 41 struct clist T_rawq; 42 struct clist T_canq; 43 } t_t; 44 #define t_rawq t_nu.t_t.T_rawq /* raw characters or partial line */ 45 #define t_canq t_nu.t_t.T_canq /* canonicalized lines */ 46 struct { 47 struct buf *T_bufp; 48 char *T_cp; 49 int T_inbuf; 50 int T_rec; 51 } t_n; 52 #define t_bufp t_nu.t_n.T_bufp /* buffer allocated to protocol */ 53 #define t_cp t_nu.t_n.T_cp /* pointer into the ripped off buffer */ 54 #define t_inbuf t_nu.t_n.T_inbuf /* number chars in the buffer */ 55 #define t_rec t_nu.t_n.T_rec /* have a complete record */ 56 } t_nu; 57 struct clist t_outq; /* device */ 58 int (*t_oproc)(); /* device */ 59 int (*t_param)(); /* device */ 60 struct proc *t_rsel; /* tty */ 61 struct proc *t_wsel; 62 caddr_t T_LINEP; /* ### */ 63 caddr_t t_addr; /* ??? */ 64 dev_t t_dev; /* device */ 65 int t_flags; /* (old) some of both */ 66 int t_state; /* some of both */ 67 struct session *t_session; /* tty */ 68 pid_t t_pgid; /* tty */ 69 char t_delct; /* tty */ 70 char t_line; /* glue */ 71 char t_col; /* tty */ 72 char t_rocount, t_rocol; /* tty */ 73 short t_hiwat; /* hi water mark */ 74 short t_lowat; /* low water mark */ 75 struct winsize t_winsize; /* window size */ 76 struct termios t_termios; /* termios state */ 77 #define t_iflag t_termios.c_iflag 78 #define t_oflag t_termios.c_oflag 79 #define t_cflag t_termios.c_cflag 80 #define t_lflag t_termios.c_lflag 81 #define t_min t_termios.c_min 82 #define t_time t_termios.c_time 83 #define t_cc t_termios.c_cc 84 #define t_ispeed t_termios.c_ispeed 85 #define t_ospeed t_termios.c_ospeed 86 long t_cancc; /* stats */ 87 long t_rawcc; 88 long t_outcc; 89 }; 90 91 #define TTIPRI 28 92 #define TTOPRI 29 93 94 /* limits */ 95 #define NSPEEDS 16 96 #define TTMASK 15 97 #define OBUFSIZ 100 98 #define TTYHOG 255 99 #ifdef KERNEL 100 #define TTMAXHIWAT roundup(2048, CBSIZE) 101 #define TTMINHIWAT roundup(100, CBSIZE) 102 #define TTMAXLOWAT 256 103 #define TTMINLOWAT 32 104 extern struct ttychars ttydefaults; 105 #endif /*KERNEL*/ 106 107 /* internal state bits */ 108 #define TS_TIMEOUT 0x000001 /* delay timeout in progress */ 109 #define TS_WOPEN 0x000002 /* waiting for open to complete */ 110 #define TS_ISOPEN 0x000004 /* device is open */ 111 #define TS_FLUSH 0x000008 /* outq has been flushed during DMA */ 112 #define TS_CARR_ON 0x000010 /* software copy of carrier-present */ 113 #define TS_BUSY 0x000020 /* output in progress */ 114 #define TS_ASLEEP 0x000040 /* wakeup when output done */ 115 #define TS_XCLUDE 0x000080 /* exclusive-use flag against open */ 116 #define TS_TTSTOP 0x000100 /* output stopped by ctl-s */ 117 #define TS_HUPCLS 0x000200 /* hang up upon last close */ 118 #define TS_TBLOCK 0x000400 /* tandem queue blocked */ 119 #define TS_RCOLL 0x000800 /* collision in read select */ 120 #define TS_WCOLL 0x001000 /* collision in write select */ 121 #define TS_NBIO 0x002000 /* tty in non-blocking mode */ 122 #define TS_ASYNC 0x004000 /* tty in async i/o mode */ 123 /* state for intra-line fancy editing work */ 124 #define TS_BKSL 0x010000 /* state for lowercase \ work */ 125 #define TS_ERASE 0x040000 /* within a \.../ for PRTRUB */ 126 #define TS_LNCH 0x080000 /* next character is literal */ 127 #define TS_TYPEN 0x100000 /* retyping suspended input (PENDIN) */ 128 #define TS_CNTTB 0x200000 /* counting tab width, leave FLUSHO alone */ 129 130 #define TS_LOCAL (TS_BKSL|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB) 131 132 /* define partab character types */ 133 #define ORDINARY 0 134 #define CONTROL 1 135 #define BACKSPACE 2 136 #define NEWLINE 3 137 #define TAB 4 138 #define VTAB 5 139 #define RETURN 6 140