--- Net2/sys/tty.h 2018/04/24 18:10:12 1.1.1.2 +++ Net2/sys/tty.h 2018/04/24 18:16:05 1.1.1.3 @@ -30,55 +30,45 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)tty.h 7.10 (Berkeley) 6/26/91 - * $Header: /var/lib/cvsd/net2/Net2/sys/tty.h,v 1.1.1.2 2018/04/24 18:10:12 root Exp $ - * - * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE - * -------------------- ----- ---------------------- - * CURRENT PATCH LEVEL: 2 00061 - * -------------------- ----- ---------------------- - * - * 18 Aug 92 Stephen McKay Fixed RB_LEN macro - * 11 Dec 92 Williams Jolitz Fixed tty handling - * -------------------- ----- ---------------------- - * + * from: @(#)tty.h 7.10 (Berkeley) 6/26/91 + * tty.h,v 1.10 1993/07/19 05:52:27 mycroft Exp */ +#ifndef _SYS_TTY_H_ +#define _SYS_TTY_H_ + #include +#include /* for struct selinfo */ +#ifndef REAL_CLISTS /* - * Ring buffers provide a contiguous, dense storage for - * character data used by the tty driver. + * Clists are actually ring buffers. The c_cc, c_cf, c_cl fields have + * exactly the same behaviour as in true clists. + * if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality + * (but, saves memory and cpu time) + * + * *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside tty_subr.c!!! + */ +struct clist { + int c_cc; /* count of characters in queue */ + int c_cn; /* total ring buffer length */ + u_char *c_cf; /* points to first character */ + u_char *c_cl; /* points to next open character */ + u_char *c_cs; /* start of ring buffer */ + u_char *c_ce; /* c_ce + c_len */ + u_char *c_cq; /* N bits/bytes long, see tty_subr.c */ +}; +#else +/* + * Clists are character lists, which is a variable length linked list + * of cblocks, wiht a count of the number of characters in the list. */ -#define RBSZ 1024 - -struct ringb { - char *rb_hd; /* head of buffer segment to be read */ - char *rb_tl; /* tail of buffer segment to be written */ - char rb_buf[RBSZ]; /* segment contents */ +struct clist { + int c_cc; + u_char *c_cf; + u_char *c_cl; }; - -#define RB_SUCC(rbp, p) \ - ((p) >= (rbp)->rb_buf + RBSZ - 1 ? (rbp)->rb_buf : (p) + 1) - -#define RB_ROLLOVER(rbp, p) \ - ((p) > (rbp)->rb_buf + RBSZ - 1 ? (rbp)->rb_buf : (p)) - -#define RB_PRED(rbp, p) \ - ((p) <= (rbp)->rb_buf ? (rbp)->rb_buf + RBSZ - 1 : (p) - 1) - -#define RB_LEN(rp) \ - ((rp)->rb_hd <= (rp)->rb_tl ? (rp)->rb_tl - (rp)->rb_hd : \ - RBSZ - ((rp)->rb_hd - (rp)->rb_tl)) - -#define RB_CONTIGPUT(rp) \ - (RB_PRED(rp, (rp)->rb_hd) < (rp)->rb_tl ? \ - (rp)->rb_buf + RBSZ - (rp)->rb_tl : \ - RB_PRED(rp, (rp)->rb_hd) - (rp)->rb_tl) - -#define RB_CONTIGGET(rp) \ - ((rp)->rb_hd <= (rp)->rb_tl ? (rp)->rb_tl - (rp)->rb_hd : \ - (rp)->rb_buf + RBSZ - (rp)->rb_hd) +#endif /* * Per-tty structure. @@ -88,10 +78,13 @@ struct ringb { * (low, high, timeout). */ struct tty { - int (*t_oproc)(); /* device */ + struct clist t_rawq; /* queues */ + struct clist t_canq; + struct clist t_outq; + int (*t_oproc) __P((struct tty *tp)); /* device */ int (*t_param)(); /* device */ - pid_t t_rsel; /* tty */ - pid_t t_wsel; + struct selinfo t_rsel; /* tty */ + struct selinfo t_wsel; caddr_t T_LINEP; /* XXX */ caddr_t t_addr; /* ??? */ dev_t t_dev; /* device */ @@ -120,9 +113,6 @@ struct tty { long t_outcc; short t_gen; /* generation number */ short t_mask; /* interrupt mask */ - struct ringb t_raw; /* ring buffers */ - struct ringb t_can; - struct ringb t_out; }; #define TTIPRI 25 /* sleep priority for tty reads */ @@ -133,8 +123,8 @@ struct tty { #define TTYHOG 1024 #ifdef KERNEL -#define TTMAXHIWAT (RBSZ/2) /* XXX */ -#define TTMINHIWAT 128 +#define TTMAXHIWAT roundup(2048, CBSIZE) +#define TTMINHIWAT roundup(100, CBSIZE) #define TTMAXLOWAT 256 #define TTMINLOWAT 32 extern struct ttychars ttydefaults; @@ -152,8 +142,8 @@ extern struct ttychars ttydefaults; #define TS_TTSTOP 0x000100 /* output stopped by ctl-s */ /* was TS_HUPCLS 0x000200 * hang up upon last close */ #define TS_TBLOCK 0x000400 /* tandem queue blocked */ -#define TS_RCOLL 0x000800 /* collision in read select */ -#define TS_WCOLL 0x001000 /* collision in write select */ +/* was TS_RCOLL 0x000800 * collision in read select */ +/* was TS_WCOLL 0x001000 * collision in write select */ #define TS_ASYNC 0x004000 /* tty in async i/o mode */ /* state for intra-line fancy editing work */ #define TS_BKSL 0x010000 /* state for lowercase \ work */ @@ -197,6 +187,14 @@ struct speedtab { #define isbackground(p, tp) (isctty((p), (tp)) && \ (p)->p_pgrp != (tp)->t_pgrp) /* + * Empty queue + */ +#define flushq(qq) { \ + register struct clist *q = qq; \ + if (q->c_cc) \ + ndflush(q, q->c_cc); \ +} +/* * Modem control commands (driver). */ #define DMSET 0 @@ -207,4 +205,65 @@ struct speedtab { #ifdef KERNEL /* symbolic sleep message strings */ extern char ttyin[], ttyout[], ttopen[], ttclos[], ttybg[], ttybuf[]; + +#ifdef __STDC__ +struct uio; +#endif + +/* clist stuff */ +void cinit __P((void)); +int clalloc __P((struct clist *clp, int size, int quot)); +void clfree __P((struct clist *clp)); +int getc __P((struct clist *clp)); +int q_to_b __P((struct clist *clp, u_char *cp, int count)); +int ndqb __P((struct clist *clp, int flag)); +void ndflush __P((struct clist *clp, int count)); +int putc __P((int c, struct clist *clp)); +int b_to_q __P((u_char *cp, int count, struct clist *clp)); +u_char *nextc __P((struct clist *clp, u_char *cp, int *c)); +u_char *firstc __P((struct clist *clp, int *c)); +int unputc __P((struct clist *clp)); +void catq __P((struct clist *from, struct clist *to)); + +int ttioctl __P((struct tty *tp, int com, caddr_t data, int flag)); +void ttsetwater __P((struct tty *tp)); +void ttstart __P((struct tty *tp)); +int ttspeedtab __P((int speed, struct speedtab *table)); +void ttwakeup __P((struct tty *tp)); +int ttnread __P((struct tty *tp)); +int ttcompat __P((struct tty *tp, int com, caddr_t data, int flag)); +void ttyrub __P((int c, struct tty *tp)); +void ttyrubo __P((struct tty *tp, int cnt)); +void ttyretype __P((struct tty *tp)); +void ttyecho __P((int c, struct tty *tp)); +void ttyoutstr __P((char *cp, struct tty *tp)); +int ttywait __P((struct tty *tp)); +void ttyflush __P((struct tty *tp, int rw)); +void ttyblock __P((struct tty *tp)); +void ttychars __P((struct tty *tp)); +int ttyclose __P((struct tty *tp)); +void ttypend __P((struct tty *tp)); +int ttysleep __P((struct tty *tp, caddr_t chan, int pri, + char *wmesg, int timo)); +void ttyinfo __P((struct tty *tp)); + +struct tty *ttymalloc __P((void)); +void ttyfree __P((struct tty *)); + +int ttyopen __P((dev_t dev, struct tty *tp)); +void ttylclose __P((struct tty *tp, int flag)); +int ttread __P((struct tty *tp, struct uio *uio, int flag)); +int ttwrite __P((struct tty *tp, struct uio *uio, int flag)); +void ttyinput __P((int data, struct tty *tp)); +void ttstart __P((struct tty *tp)); +int ttymodem __P((struct tty *tp, int flag)); + +/* XXX slip stuff for the line discipline init in tty_conf.c */ +int slopen __P((dev_t dev, struct tty *tp)); +void slclose __P((struct tty *tp, int flag)); +int sltioctl __P((struct tty *vp, int cmd, caddr_t data, int flag)); +void slinput __P((int data, struct tty *tp)); +void slstart __P((struct tty *tp)); #endif + +#endif /* !_SYS_TTY_H_ */