Annotation of Net2/sys/tty.h, revision 1.1.1.3

1.1       root        1: /*-
                      2:  * Copyright (c) 1982, 1986 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. All advertising materials mentioning features or use of this software
                     14:  *    must display the following acknowledgement:
                     15:  *     This product includes software developed by the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
1.1.1.3 ! root       33:  *     from: @(#)tty.h 7.10 (Berkeley) 6/26/91
        !            34:  *     tty.h,v 1.10 1993/07/19 05:52:27 mycroft Exp
1.1       root       35:  */
                     36: 
1.1.1.3 ! root       37: #ifndef _SYS_TTY_H_
        !            38: #define _SYS_TTY_H_
        !            39: 
1.1       root       40: #include <sys/termios.h>
1.1.1.3 ! root       41: #include <sys/select.h>                        /* for struct selinfo */
1.1       root       42: 
1.1.1.3 ! root       43: #ifndef REAL_CLISTS
1.1       root       44: /*
1.1.1.3 ! root       45:  * Clists are actually ring buffers. The c_cc, c_cf, c_cl fields have
        !            46:  * exactly the same behaviour as in true clists.
        !            47:  * if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
        !            48:  * (but, saves memory and cpu time)
        !            49:  * 
        !            50:  * *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside tty_subr.c!!!
        !            51:  */
        !            52: struct clist {
        !            53:        int     c_cc;           /* count of characters in queue */
        !            54:        int     c_cn;           /* total ring buffer length */
        !            55:        u_char  *c_cf;          /* points to first character */
        !            56:        u_char  *c_cl;          /* points to next open character */
        !            57:        u_char  *c_cs;          /* start of ring buffer */
        !            58:        u_char  *c_ce;          /* c_ce + c_len */
        !            59:        u_char  *c_cq;          /* N bits/bytes long, see tty_subr.c */
        !            60: };
        !            61: #else
        !            62: /*
        !            63:  * Clists are character lists, which is a variable length linked list
        !            64:  * of cblocks, wiht a count of the number of characters in the list.
1.1       root       65:  */
1.1.1.3 ! root       66: struct clist {
        !            67:        int     c_cc;
        !            68:        u_char  *c_cf;
        !            69:        u_char  *c_cl;
1.1       root       70: };
1.1.1.3 ! root       71: #endif
1.1.1.2   root       72: 
1.1       root       73: /*
                     74:  * Per-tty structure.
                     75:  *
                     76:  * Should be split in two, into device and tty drivers.
                     77:  * Glue could be masks of what to echo and circular buffer
                     78:  * (low, high, timeout).
                     79:  */
                     80: struct tty {
1.1.1.3 ! root       81:        struct  clist t_rawq;           /* queues */
        !            82:        struct  clist t_canq;
        !            83:        struct  clist t_outq;
        !            84:        int     (*t_oproc) __P((struct tty *tp));       /* device */
1.1       root       85:        int     (*t_param)();           /* device */
1.1.1.3 ! root       86:        struct selinfo t_rsel;          /* tty */
        !            87:        struct selinfo t_wsel;
1.1       root       88:        caddr_t T_LINEP;                /* XXX */
                     89:        caddr_t t_addr;                 /* ??? */
                     90:        dev_t   t_dev;                  /* device */
                     91:        int     t_flags;                /* (compat) some of both */
                     92:        int     t_state;                /* some of both */
                     93:        struct  session *t_session;     /* tty */
                     94:        struct  pgrp *t_pgrp;           /* foreground process group */
                     95:        char    t_line;                 /* glue */
                     96:        short   t_col;                  /* tty */
                     97:        short   t_rocount, t_rocol;     /* tty */
                     98:        short   t_hiwat;                /* hi water mark */
                     99:        short   t_lowat;                /* low water mark */
                    100:        struct  winsize t_winsize;      /* window size */
                    101:        struct  termios t_termios;      /* termios state */
                    102: #define        t_iflag         t_termios.c_iflag
                    103: #define        t_oflag         t_termios.c_oflag
                    104: #define        t_cflag         t_termios.c_cflag
                    105: #define        t_lflag         t_termios.c_lflag
                    106: #define        t_min           t_termios.c_min
                    107: #define        t_time          t_termios.c_time
                    108: #define        t_cc            t_termios.c_cc
                    109: #define t_ispeed       t_termios.c_ispeed
                    110: #define t_ospeed       t_termios.c_ospeed
                    111:        long    t_cancc;                /* stats */
                    112:        long    t_rawcc;
                    113:        long    t_outcc;
                    114:        short   t_gen;                  /* generation number */
1.1.1.2   root      115:        short   t_mask;                 /* interrupt mask */
1.1       root      116: };
                    117: 
                    118: #define        TTIPRI  25                      /* sleep priority for tty reads */
                    119: #define        TTOPRI  26                      /* sleep priority for tty writes */
                    120: 
                    121: #define        TTMASK  15
                    122: #define        OBUFSIZ 100
                    123: #define        TTYHOG  1024
                    124: 
                    125: #ifdef KERNEL
1.1.1.3 ! root      126: #define TTMAXHIWAT     roundup(2048, CBSIZE)
        !           127: #define TTMINHIWAT     roundup(100, CBSIZE)
1.1       root      128: #define TTMAXLOWAT     256
                    129: #define TTMINLOWAT     32
                    130: extern struct ttychars ttydefaults;
                    131: #endif /* KERNEL */
                    132: 
                    133: /* internal state bits */
                    134: #define        TS_TIMEOUT      0x000001        /* delay timeout in progress */
                    135: #define        TS_WOPEN        0x000002        /* waiting for open to complete */
                    136: #define        TS_ISOPEN       0x000004        /* device is open */
                    137: #define        TS_FLUSH        0x000008        /* outq has been flushed during DMA */
                    138: #define        TS_CARR_ON      0x000010        /* software copy of carrier-present */
                    139: #define        TS_BUSY         0x000020        /* output in progress */
                    140: #define        TS_ASLEEP       0x000040        /* wakeup when output done */
                    141: #define        TS_XCLUDE       0x000080        /* exclusive-use flag against open */
                    142: #define        TS_TTSTOP       0x000100        /* output stopped by ctl-s */
                    143: /* was TS_HUPCLS       0x000200         * hang up upon last close */
                    144: #define        TS_TBLOCK       0x000400        /* tandem queue blocked */
1.1.1.3 ! root      145: /* was TS_RCOLL        0x000800         * collision in read select */
        !           146: /* was TS_WCOLL        0x001000         * collision in write select */
1.1       root      147: #define        TS_ASYNC        0x004000        /* tty in async i/o mode */
                    148: /* state for intra-line fancy editing work */
                    149: #define        TS_BKSL         0x010000        /* state for lowercase \ work */
                    150: #define        TS_ERASE        0x040000        /* within a \.../ for PRTRUB */
                    151: #define        TS_LNCH         0x080000        /* next character is literal */
                    152: #define        TS_TYPEN        0x100000        /* retyping suspended input (PENDIN) */
                    153: #define        TS_CNTTB        0x200000        /* counting tab width, ignore FLUSHO */
                    154: 
                    155: #define        TS_LOCAL        (TS_BKSL|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
                    156: 
                    157: /* define partab character types */
                    158: #define        ORDINARY        0
                    159: #define        CONTROL         1
                    160: #define        BACKSPACE       2
                    161: #define        NEWLINE         3
                    162: #define        TAB             4
                    163: #define        VTAB            5
                    164: #define        RETURN          6
                    165: 
                    166: struct speedtab {
                    167:         int sp_speed;
                    168:         int sp_code;
                    169: };
                    170: /*
                    171:  * Flags on character passed to ttyinput
                    172:  */
                    173: #define TTY_CHARMASK    0x000000ff      /* Character mask */
                    174: #define TTY_QUOTE       0x00000100      /* Character quoted */
                    175: #define TTY_ERRORMASK   0xff000000      /* Error mask */
                    176: #define TTY_FE          0x01000000      /* Framing error or BREAK condition */
                    177: #define TTY_PE          0x02000000      /* Parity error */
                    178: 
                    179: /*
                    180:  * Is tp controlling terminal for p
                    181:  */
                    182: #define isctty(p, tp)  ((p)->p_session == (tp)->t_session && \
                    183:                         (p)->p_flag&SCTTY)
                    184: /*
                    185:  * Is p in background of tp
                    186:  */
                    187: #define isbackground(p, tp)    (isctty((p), (tp)) && \
                    188:                                (p)->p_pgrp != (tp)->t_pgrp)
                    189: /*
1.1.1.3 ! root      190:  * Empty queue
        !           191:  */
        !           192: #define flushq(qq) { \
        !           193:         register struct clist *q = qq; \
        !           194:         if (q->c_cc) \
        !           195:                 ndflush(q, q->c_cc); \
        !           196: }
        !           197: /*
1.1       root      198:  * Modem control commands (driver).
                    199:  */
                    200: #define        DMSET           0
                    201: #define        DMBIS           1
                    202: #define        DMBIC           2
                    203: #define        DMGET           3
                    204: 
                    205: #ifdef KERNEL
                    206: /* symbolic sleep message strings */
                    207: extern  char ttyin[], ttyout[], ttopen[], ttclos[], ttybg[], ttybuf[];
1.1.1.3 ! root      208: 
        !           209: #ifdef __STDC__
        !           210: struct uio;
        !           211: #endif
        !           212: 
        !           213: /* clist stuff */
        !           214: void   cinit           __P((void));
        !           215: int    clalloc         __P((struct clist *clp, int size, int quot));
        !           216: void   clfree          __P((struct clist *clp));
        !           217: int    getc            __P((struct clist *clp));
        !           218: int    q_to_b          __P((struct clist *clp, u_char *cp, int count));
        !           219: int    ndqb            __P((struct clist *clp, int flag));
        !           220: void   ndflush         __P((struct clist *clp, int count));
        !           221: int    putc            __P((int c, struct clist *clp));
        !           222: int    b_to_q          __P((u_char *cp, int count, struct clist *clp));
        !           223: u_char *nextc          __P((struct clist *clp, u_char *cp, int *c));
        !           224: u_char *firstc         __P((struct clist *clp, int *c));
        !           225: int    unputc          __P((struct clist *clp));
        !           226: void   catq            __P((struct clist *from, struct clist *to));
        !           227: 
        !           228: int    ttioctl         __P((struct tty *tp, int com, caddr_t data, int flag));
        !           229: void   ttsetwater      __P((struct tty *tp));
        !           230: void   ttstart         __P((struct tty *tp));
        !           231: int    ttspeedtab      __P((int speed, struct speedtab *table));
        !           232: void   ttwakeup        __P((struct tty *tp));
        !           233: int    ttnread         __P((struct tty *tp));
        !           234: int    ttcompat        __P((struct tty *tp, int com, caddr_t data, int flag));
        !           235: void   ttyrub          __P((int c, struct tty *tp));
        !           236: void   ttyrubo         __P((struct tty *tp, int cnt));
        !           237: void   ttyretype       __P((struct tty *tp));
        !           238: void   ttyecho         __P((int c, struct tty *tp));
        !           239: void   ttyoutstr       __P((char *cp, struct tty *tp));
        !           240: int    ttywait         __P((struct tty *tp));
        !           241: void   ttyflush        __P((struct tty *tp, int rw));
        !           242: void   ttyblock        __P((struct tty *tp));
        !           243: void   ttychars        __P((struct tty *tp));
        !           244: int    ttyclose        __P((struct tty *tp));
        !           245: void   ttypend         __P((struct tty *tp));
        !           246: int    ttysleep        __P((struct tty *tp, caddr_t chan, int pri,
        !           247:                             char *wmesg, int timo));
        !           248: void   ttyinfo         __P((struct tty *tp));
        !           249: 
        !           250: struct tty *ttymalloc  __P((void));
        !           251: void   ttyfree         __P((struct tty *));
        !           252: 
        !           253: int    ttyopen __P((dev_t dev, struct tty *tp));
        !           254: void   ttylclose __P((struct tty *tp, int flag));
        !           255: int    ttread __P((struct tty *tp, struct uio *uio, int flag));
        !           256: int    ttwrite __P((struct tty *tp, struct uio *uio, int flag));
        !           257: void   ttyinput __P((int data, struct tty *tp));
        !           258: void   ttstart __P((struct tty *tp));
        !           259: int    ttymodem __P((struct tty *tp, int flag));
        !           260: 
        !           261: /* XXX slip stuff for the line discipline init in tty_conf.c */
        !           262: int    slopen __P((dev_t dev, struct tty *tp));
        !           263: void   slclose __P((struct tty *tp, int flag));
        !           264: int    sltioctl __P((struct tty *vp, int cmd, caddr_t data, int flag));
        !           265: void   slinput __P((int data, struct tty *tp));
        !           266: void   slstart __P((struct tty *tp));
1.1       root      267: #endif
1.1.1.3 ! root      268: 
        !           269: #endif /* !_SYS_TTY_H_ */

unix.superglobalmegacorp.com

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