xref: /original-bsd/sys/sys/tty.h (revision f0fd5f8a)
1 /*	tty.h	4.12	82/12/05	*/
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_char;			/* tty */
61 	char	t_line;			/* glue */
62 	char	t_col;			/* tty */
63 	char	t_ispeed, t_ospeed;	/* device */
64 	char	t_rocount, t_rocol;	/* tty */
65 	struct	ttychars t_chars;	/* tty */
66 /* be careful of tchars & co. */
67 #define	t_erase		t_chars.tc_erase
68 #define	t_kill		t_chars.tc_kill
69 #define	t_intrc		t_chars.tc_intrc
70 #define	t_quitc		t_chars.tc_quitc
71 #define	t_startc	t_chars.tc_startc
72 #define	t_stopc		t_chars.tc_stopc
73 #define	t_eofc		t_chars.tc_eofc
74 #define	t_brkc		t_chars.tc_brkc
75 #define	t_suspc		t_chars.tc_suspc
76 #define	t_dsuspc	t_chars.tc_dsuspc
77 #define	t_rprntc	t_chars.tc_rprntc
78 #define	t_flushc	t_chars.tc_flushc
79 #define	t_werasc	t_chars.tc_werasc
80 #define	t_lnextc	t_chars.tc_lnextc
81 };
82 
83 #define	TTIPRI	28
84 #define	TTOPRI	29
85 
86 /* limits */
87 #define	NSPEEDS	16
88 #define	TTMASK	15
89 #define	OBUFSIZ	100
90 #define	TTYHOG	255
91 #ifdef KERNEL
92 short	tthiwat[NSPEEDS], ttlowat[NSPEEDS];
93 #define	TTHIWAT(tp)	tthiwat[(tp)->t_ospeed&TTMASK]
94 #define	TTLOWAT(tp)	ttlowat[(tp)->t_ospeed&TTMASK]
95 extern	struct ttychars ttydefaults;
96 #endif
97 
98 /* internal state bits */
99 #define	TS_TIMEOUT	0x000001	/* delay timeout in progress */
100 #define	TS_WOPEN	0x000002	/* waiting for open to complete */
101 #define	TS_ISOPEN	0x000004	/* device is open */
102 #define	TS_FLUSH	0x000008	/* outq has been flushed during DMA */
103 #define	TS_CARR_ON	0x000010	/* software copy of carrier-present */
104 #define	TS_BUSY		0x000020	/* output in progress */
105 #define	TS_ASLEEP	0x000040	/* wakeup when output done */
106 #define	TS_XCLUDE	0x000080	/* exclusive-use flag against open */
107 #define	TS_TTSTOP	0x000100	/* output stopped by ctl-s */
108 #define	TS_HUPCLS	0x000200	/* hang up upon last close */
109 #define	TS_TBLOCK	0x000400	/* tandem queue blocked */
110 #define	TS_RCOLL	0x000800	/* collision in read select */
111 #define	TS_WCOLL	0x001000	/* collision in write select */
112 #define	TS_NBIO		0x002000	/* tty in non-blocking mode */
113 #define	TS_ASYNC	0x004000	/* tty in async i/o mode */
114 /* state for intra-line fancy editing work */
115 #define	TS_BKSL		0x010000	/* state for lowercase \ work */
116 #define	TS_QUOT		0x020000	/* last character input was \ */
117 #define	TS_ERASE	0x040000	/* within a \.../ for PRTRUB */
118 #define	TS_LNCH		0x080000	/* next character is literal */
119 #define	TS_TYPEN	0x100000	/* retyping suspended input (PENDIN) */
120 #define	TS_CNTTB	0x200000	/* counting tab width; leave FLUSHO alone */
121 
122 #define	TS_LOCAL	(TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
123 
124 /* define partab character types */
125 #define	ORDINARY	0
126 #define	CONTROL		1
127 #define	BACKSPACE	2
128 #define	NEWLINE		3
129 #define	TAB		4
130 #define	VTAB		5
131 #define	RETURN		6
132