Annotation of 40BSD/sys/h/tty.h, revision 1.1.1.1

1.1       root        1: /*     tty.h   4.1     11/9/80 */
                      2: 
                      3: #include <sgtty.h>
                      4: #include <sys/ioctl.h>
                      5: 
                      6: /*
                      7:  * A clist structure is the head
                      8:  * of a linked list queue of characters.
                      9:  * The characters are stored in
                     10:  * blocks containing a link and CBSIZE (param.h)
                     11:  * characters.  The routines getc, putc, ... in prim.c
                     12:  * manipulate these structures.
                     13:  */
                     14: struct clist
                     15: {
                     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:  * A tty structure is needed for
                     23:  * each UNIX character device that
                     24:  * is used for normal terminal IO.
                     25:  * The routines in tty.c handle the
                     26:  * common code associated with
                     27:  * these structures.  The definition
                     28:  * and device dependent code is in
                     29:  * each driver. (cons.c, dh.c, dz.c, kl.c)
                     30:  */
                     31: struct tty
                     32: {
                     33:        union {
                     34:                struct {
                     35:                        struct  clist T_rawq;
                     36:                        struct  clist T_canq;
                     37:                } t_t;
                     38: #define        t_rawq  t_nu.t_t.T_rawq         /* raw characters or partial line */
                     39: #define        t_canq  t_nu.t_t.T_canq         /* complete input lines */
                     40:                struct {
                     41:                        struct  buf *T_bufp;
                     42:                        char    *T_cp;
                     43:                        int     T_inbuf;
                     44:                        int     T_rec;
                     45:                } t_n;
                     46: #define        t_bufp  t_nu.t_n.T_bufp         /* buffer allocated to protocol */
                     47: #define        t_cp    t_nu.t_n.T_cp           /* pointer into the ripped off buffer */
                     48: #define        t_inbuf t_nu.t_n.T_inbuf        /* number chars in the buffer */
                     49: #define        t_rec   t_nu.t_n.T_rec          /* have a complete record */
                     50:        } t_nu;
                     51:        struct  clist t_outq;   /* output list to device */
                     52:        int     (*t_oproc)();   /* routine to start output */
                     53:        int     (*t_iproc)();   /* routine to start input */
                     54:        struct chan *t_chan;    /* destination channel */
                     55:        caddr_t t_linep;        /* aux line discipline pointer */
                     56:        caddr_t t_addr;         /* device address */
                     57:        dev_t   t_dev;          /* device number */
                     58:        short   t_flags;        /* mode, settable by ioctl call */
                     59:        short   t_state;        /* internal state, not visible externally */
                     60:        short   t_pgrp;         /* process group name */
                     61:        char    t_delct;        /* number of delimiters in raw q */
                     62:        char    t_line;         /* line discipline */
                     63:        char    t_col;          /* printing column of device */
                     64:        char    t_erase;        /* erase character */
                     65:        char    t_kill;         /* kill character */
                     66:        char    t_char;         /* character temporary */
                     67:        char    t_ispeed;       /* input speed */
                     68:        char    t_ospeed;       /* output speed */
                     69: /* begin local */
                     70:        char    t_rocount;      /* chars input since a ttwrite() */
                     71:        char    t_rocol;        /* t_col when first input this line */
                     72:        struct  ltchars t_lchr; /* local special characters */
                     73:        short   t_local;        /* local mode word */
                     74:        short   t_lstate;       /* local state bits */
                     75: /* end local */
                     76:        union {
                     77:                struct tchars t_chr;
                     78:                struct clist t_ctlq;
                     79:        } t_un;
                     80: };
                     81: 
                     82: #define        tun     tp->t_un.t_chr
                     83: #define        tlun    tp->t_lchr
                     84: 
                     85: #define        TTIPRI  28
                     86: #define        TTOPRI  29
                     87: 
                     88: #define        CTRL(c) ('c'&037)
                     89: 
                     90: /* default special characters */
                     91: #define        CERASE  '#'
                     92: #define        CEOT    CTRL(d)
                     93: #define        CKILL   '@'
                     94: #define        CQUIT   034             /* FS, cntl shift L */
                     95: #define        CINTR   0177            /* DEL */
                     96: #define        CSTOP   CTRL(s)
                     97: #define        CSTART  CTRL(q)
                     98: #define        CBRK    0377
                     99: 
                    100: /* limits */
                    101: #define        NSPEEDS 16
                    102: #define        TTMASK  15
                    103: #ifdef KERNEL
                    104: short  tthiwat[NSPEEDS], ttlowat[NSPEEDS];
                    105: #define        TTHIWAT(tp)     tthiwat[(tp)->t_ospeed&TTMASK]
                    106: #define        TTLOWAT(tp)     ttlowat[(tp)->t_ospeed&TTMASK]
                    107: #endif
                    108: #define        TTYHOG  256
                    109: 
                    110: /* hardware bits */
                    111: #define        DONE    0200
                    112: #define        IENABLE 0100
                    113: 
                    114: /* internal state bits */
                    115: #define        TIMEOUT 01              /* delay timeout in progress */
                    116: #define        WOPEN   02              /* waiting for open to complete */
                    117: #define        ISOPEN  04              /* device is open */
                    118: #define        FLUSH   010             /* outq has been flushed during DMA */
                    119: #define        CARR_ON 020             /* software copy of carrier-present */
                    120: #define        BUSY    040             /* output in progress */
                    121: #define        ASLEEP  0100            /* wakeup when output done */
                    122: #define        XCLUDE  0200            /* exclusive-use flag against open */
                    123: #define        TTSTOP  0400            /* output stopped by ctl-s */
                    124: #define        HUPCLS  01000           /* hang up upon last close */
                    125: #define        TBLOCK  02000           /* tandem queue blocked */
                    126: #define        SPEEDS  04000           /* t_ispeed and t_ospeed used by driver */
                    127: #define        PROTO1  010000          /* reserved for line discipline */
                    128: #define        EXTPROC 020000          /* external processor (kmc) */
                    129: #define        FSLEEP  040000          /* Wakeup on input framing */
                    130: #define        CNTLQ   0100000         /* interpret t_un as clist */
                    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: 
                    141: /* define dmctl actions */
                    142: #define        DMSET           0
                    143: #define        DMBIS           1
                    144: #define        DMBIC           2

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.