xref: /original-bsd/sys/sys/tty.h (revision e5dafb11)
1 /*	tty.h	4.11	82/03/15	*/
2 
3 #ifdef KERNEL
4 #include "../h/ioctl.h"
5 #else
6 #include <sys/ioctl.h>
7 #endif
8 #include <sgtty.h>
9 
10 /*
11  * A clist structure is the head of a linked list queue of characters.
12  * The characters are stored in blocks containing a link and CBSIZE (param.h)
13  * characters.  The routines in prim.c manipulate these structures.
14  */
15 struct clist {
16 	int	c_cc;		/* character count */
17 	char	*c_cf;		/* pointer to first char */
18 	char	*c_cl;		/* pointer to last char */
19 };
20 
21 /*
22  * Per-tty structre.
23  *
24  * Should be split in two, into device and tty drivers.
25  * Glue could be masks of what to echo and circular buffer
26  * (low, high, timeout).
27  */
28 struct tty
29 {
30 	union {
31 		struct {
32 			struct	clist T_rawq;
33 			struct	clist T_canq;
34 		} t_t;
35 #define	t_rawq	t_nu.t_t.T_rawq		/* raw characters or partial line */
36 #define	t_canq	t_nu.t_t.T_canq		/* raw characters or partial line */
37 		struct {
38 			struct	buf *T_bufp;
39 			char	*T_cp;
40 			int	T_inbuf;
41 			int	T_rec;
42 		} t_n;
43 #define	t_bufp	t_nu.t_n.T_bufp		/* buffer allocated to protocol */
44 #define	t_cp	t_nu.t_n.T_cp		/* pointer into the ripped off buffer */
45 #define	t_inbuf	t_nu.t_n.T_inbuf	/* number chars in the buffer */
46 #define	t_rec	t_nu.t_n.T_rec		/* have a complete record */
47 	} t_nu;
48 	struct	clist t_outq;		/* device */
49 	int	(*t_oproc)();		/* device */
50 	struct	proc *t_rsel;		/* tty */
51 	struct	proc *t_wsel;
52 				caddr_t	T_LINEP;	/* ### */
53 	caddr_t	t_addr;			/* ??? */
54 	dev_t	t_dev;			/* device */
55 	short	t_flags;		/* some of both */
56 	short	t_state;		/* some of both */
57 	short	t_pgrp;			/* tty */
58 	char	t_delct;		/* tty */
59 	char	t_line;			/* glue */
60 	char	t_col;			/* tty */
61 	char	t_erase, t_kill;	/* tty */
62 	char	t_char;			/* tty */
63 	char	t_ispeed, t_ospeed;	/* device */
64 /* begin local */
65 	char	t_rocount, t_rocol;	/* tty */
66 	struct	ltchars t_lchr;		/* tty */
67 	short	t_local;		/* tty */
68 	short	t_lstate;		/* tty */
69 /* end local */
70 	union {
71 		struct tchars t_chr;	/* tty */
72 		struct clist T_CTLQ;
73 	} t_un;
74 };
75 
76 #define	tun	tp->t_un.t_chr
77 #define	tlun	tp->t_lchr
78 
79 #define	TTIPRI	28
80 #define	TTOPRI	29
81 
82 #define	CTRL(c)	('c'&037)
83 
84 /* default special characters */
85 #define	CERASE	'#'
86 #define	CEOT	CTRL(d)
87 #define	CKILL	'@'
88 #define	CQUIT	034		/* FS, cntl shift L */
89 #define	CINTR	0177		/* DEL */
90 #define	CSTOP	CTRL(s)
91 #define	CSTART	CTRL(q)
92 #define	CBRK	0377
93 
94 /* limits */
95 #define	NSPEEDS	16
96 #define	TTMASK	15
97 #ifdef KERNEL
98 short	tthiwat[NSPEEDS], ttlowat[NSPEEDS];
99 #define	TTHIWAT(tp)	tthiwat[(tp)->t_ospeed&TTMASK]
100 #define	TTLOWAT(tp)	ttlowat[(tp)->t_ospeed&TTMASK]
101 #endif
102 #define	TTYHOG	255
103 
104 /* hardware bits */
105 #define	DONE	0200
106 #define	IENABLE	0100
107 
108 /* internal state bits */
109 #define	TS_TIMEOUT	000001		/* delay timeout in progress */
110 #define	TS_WOPEN	000002		/* waiting for open to complete */
111 #define	TS_ISOPEN	000004		/* device is open */
112 #define	TS_FLUSH	000010		/* outq has been flushed during DMA */
113 #define	TS_CARR_ON	000020		/* software copy of carrier-present */
114 #define	TS_BUSY		000040		/* output in progress */
115 #define	TS_ASLEEP	000100		/* wakeup when output done */
116 #define	TS_XCLUDE	000200		/* exclusive-use flag against open */
117 #define	TS_TTSTOP	000400		/* output stopped by ctl-s */
118 #define	TS_HUPCLS	001000		/* hang up upon last close */
119 #define	TS_TBLOCK	002000		/* tandem queue blocked */
120 #define	TS_RCOLL	004000		/* collision in read select */
121 #define	TS_WCOLL	010000		/* collision in write select */
122 #define	TS_NBIO		020000		/* tty in non-blocking mode */
123 #define	TS_ASYNC	040000		/* tty in async i/o mode */
124 
125 /* define partab character types */
126 #define	ORDINARY	0
127 #define	CONTROL		1
128 #define	BACKSPACE	2
129 #define	NEWLINE		3
130 #define	TAB		4
131 #define	VTAB		5
132 #define	RETURN		6
133 
134 /* define dmctl actions */
135 #define	DMSET		0
136 #define	DMBIS		1
137 #define	DMBIC		2
138 #define	DMGET		3
139