--- Net2/sys/tty.h 2018/04/24 18:03:57 1.1.1.1 +++ Net2/sys/tty.h 2018/04/24 18:16:05 1.1.1.3 @@ -30,20 +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 + * 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 +/* + * 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. */ struct clist { - int c_cc; /* count of characters in queue */ - char *c_cf; /* first character/cblock */ - char *c_cl; /* last chararacter/cblock */ + int c_cc; + u_char *c_cf; + u_char *c_cl; }; +#endif /* * Per-tty structure. @@ -56,10 +81,10 @@ struct tty { struct clist t_rawq; /* queues */ struct clist t_canq; struct clist t_outq; - int (*t_oproc)(); /* device */ + int (*t_oproc) __P((struct tty *tp)); /* device */ int (*t_param)(); /* device */ - struct proc *t_rsel; /* tty */ - struct proc *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 */ @@ -87,6 +112,7 @@ struct tty { long t_rawcc; long t_outcc; short t_gen; /* generation number */ + short t_mask; /* interrupt mask */ }; #define TTIPRI 25 /* sleep priority for tty reads */ @@ -116,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 */ @@ -161,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 @@ -171,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_ */