[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/tty.h

Version: -  FREEBSD  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1982, 1986, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  * (c) UNIX System Laboratories, Inc.
    5  * All or some portions of this file are derived from material licensed
    6  * to the University of California by American Telephone and Telegraph
    7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
    8  * the permission of UNIX System Laboratories, Inc.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *      This product includes software developed by the University of
   21  *      California, Berkeley and its contributors.
   22  * 4. Neither the name of the University nor the names of its contributors
   23  *    may be used to endorse or promote products derived from this software
   24  *    without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   36  * SUCH DAMAGE.
   37  *
   38  *      @(#)tty.h       8.6 (Berkeley) 1/21/94
   39  * $FreeBSD: src/sys/sys/tty.h,v 1.34.4.1 1999/09/05 08:23:08 peter Exp $
   40  */
   41 
   42 #ifndef _SYS_TTY_H_
   43 #define _SYS_TTY_H_
   44 
   45 #include <sys/termios.h>
   46 #include <sys/select.h>         /* For struct selinfo. */
   47 
   48 /*
   49  * Clists are character lists, which is a variable length linked list
   50  * of cblocks, with a count of the number of characters in the list.
   51  */
   52 struct clist {
   53         int     c_cc;           /* Number of characters in the clist. */
   54         int     c_cbcount;      /* Number of cblocks. */
   55         int     c_cbmax;        /* Max # cblocks allowed for this clist. */
   56         int     c_cbreserved;   /* # cblocks reserved for this clist. */
   57         char    *c_cf;          /* Pointer to the first cblock. */
   58         char    *c_cl;          /* Pointer to the last cblock. */
   59 };
   60 
   61 /*
   62  * Per-tty structure.
   63  *
   64  * Should be split in two, into device and tty drivers.
   65  * Glue could be masks of what to echo and circular buffer
   66  * (low, high, timeout).
   67  */
   68 struct tty {
   69         struct  clist t_rawq;           /* Device raw input queue. */
   70         long    t_rawcc;                /* Raw input queue statistics. */
   71         struct  clist t_canq;           /* Device canonical queue. */
   72         long    t_cancc;                /* Canonical queue statistics. */
   73         struct  clist t_outq;           /* Device output queue. */
   74         long    t_outcc;                /* Output queue statistics. */
   75         int     t_line;                 /* Interface to device drivers. */
   76         dev_t   t_dev;                  /* Device. */
   77         int     t_state;                /* Device and driver (TS*) state. */
   78         int     t_flags;                /* Tty flags. */
   79         int     t_timeout;              /* Timeout for ttywait() */
   80         struct  pgrp *t_pgrp;           /* Foreground process group. */
   81         struct  session *t_session;     /* Enclosing session. */
   82         struct  selinfo t_rsel;         /* Tty read/oob select. */
   83         struct  selinfo t_wsel;         /* Tty write select. */
   84         struct  termios t_termios;      /* Termios state. */
   85         struct  winsize t_winsize;      /* Window size. */
   86                                         /* Start output. */
   87         void    (*t_oproc) __P((struct tty *));
   88                                         /* Stop output. */
   89         void    (*t_stop) __P((struct tty *, int));
   90                                         /* Set hardware state. */
   91         int     (*t_param) __P((struct tty *, struct termios *));
   92         void    *t_sc;                  /* XXX: net/if_sl.c:sl_softc. */
   93         int     t_column;               /* Tty output column. */
   94         int     t_rocount, t_rocol;     /* Tty. */
   95         int     t_hiwat;                /* High water mark. */
   96         int     t_lowat;                /* Low water mark. */
   97         int     t_gen;                  /* Generation number. */
   98 };
   99 
  100 #define t_cc            t_termios.c_cc
  101 #define t_cflag         t_termios.c_cflag
  102 #define t_iflag         t_termios.c_iflag
  103 #define t_ispeed        t_termios.c_ispeed
  104 #define t_lflag         t_termios.c_lflag
  105 #define t_min           t_termios.c_min
  106 #define t_oflag         t_termios.c_oflag
  107 #define t_ospeed        t_termios.c_ospeed
  108 #define t_time          t_termios.c_time
  109 
  110 #define TTIPRI  25                      /* Sleep priority for tty reads. */
  111 #define TTOPRI  26                      /* Sleep priority for tty writes. */
  112 
  113 /*
  114  * User data unfortunately has to be copied through buffers on the way to
  115  * and from clists.  The buffers are on the stack so their sizes must be
  116  * fairly small.
  117  */
  118 #define IBUFSIZ 384                     /* Should be >= max value of MIN. */
  119 #define OBUFSIZ 100
  120 
  121 #ifndef TTYHOG
  122 #define TTYHOG  1024
  123 #endif
  124 
  125 #ifdef KERNEL
  126 #define TTMAXHIWAT      roundup(2048, CBSIZE)
  127 #define TTMINHIWAT      roundup(100, CBSIZE)
  128 #define TTMAXLOWAT      256
  129 #define TTMINLOWAT      32
  130 #endif
  131 
  132 /* These flags are kept in t_state. */
  133 #define TS_SO_OLOWAT    0x00001         /* Wake up when output <= low water. */
  134 #define TS_ASYNC        0x00002         /* Tty in async I/O mode. */
  135 #define TS_BUSY         0x00004         /* Draining output. */
  136 #define TS_CARR_ON      0x00008         /* Carrier is present. */
  137 #define TS_FLUSH        0x00010         /* Outq has been flushed during DMA. */
  138 #define TS_ISOPEN       0x00020         /* Open has completed. */
  139 #define TS_TBLOCK       0x00040         /* Further input blocked. */
  140 #define TS_TIMEOUT      0x00080         /* Wait for output char processing. */
  141 #define TS_TTSTOP       0x00100         /* Output paused. */
  142 #ifdef notyet
  143 #define TS_WOPEN        0x00200         /* Open in progress. */
  144 #endif
  145 #define TS_XCLUDE       0x00400         /* Tty requires exclusivity. */
  146 
  147 /* State for intra-line fancy editing work. */
  148 #define TS_BKSL         0x00800         /* State for lowercase \ work. */
  149 #define TS_CNTTB        0x01000         /* Counting tab width, ignore FLUSHO. */
  150 #define TS_ERASE        0x02000         /* Within a \.../ for PRTRUB. */
  151 #define TS_LNCH         0x04000         /* Next character is literal. */
  152 #define TS_TYPEN        0x08000         /* Retyping suspended input (PENDIN). */
  153 #define TS_LOCAL        (TS_BKSL | TS_CNTTB | TS_ERASE | TS_LNCH | TS_TYPEN)
  154 
  155 /* Extras. */
  156 #define TS_CAN_BYPASS_L_RINT 0x010000   /* Device in "raw" mode. */
  157 #define TS_CONNECTED    0x020000        /* Connection open. */
  158 #define TS_SNOOP        0x040000        /* Device is being snooped on. */
  159 #define TS_SO_OCOMPLETE 0x080000        /* Wake up when output completes. */
  160 #define TS_ZOMBIE       0x100000        /* Connection lost. */
  161 
  162 /* Hardware flow-control-invoked bits. */
  163 #define TS_CAR_OFLOW    0x200000        /* For MDMBUF (XXX handle in driver). */
  164 #ifdef notyet
  165 #define TS_CTS_OFLOW    0x400000        /* For CCTS_OFLOW. */
  166 #define TS_DSR_OFLOW    0x800000        /* For CDSR_OFLOW. */
  167 #endif
  168 
  169 /* Character type information. */
  170 #define ORDINARY        0
  171 #define CONTROL         1
  172 #define BACKSPACE       2
  173 #define NEWLINE         3
  174 #define TAB             4
  175 #define VTAB            5
  176 #define RETURN          6
  177 
  178 struct speedtab {
  179         int sp_speed;                   /* Speed. */
  180         int sp_code;                    /* Code. */
  181 };
  182 
  183 /* Modem control commands (driver). */
  184 #define DMSET           0
  185 #define DMBIS           1
  186 #define DMBIC           2
  187 #define DMGET           3
  188 
  189 /* Flags on a character passed to ttyinput. */
  190 #define TTY_CHARMASK    0x000000ff      /* Character mask */
  191 #define TTY_QUOTE       0x00000100      /* Character quoted */
  192 #define TTY_ERRORMASK   0xff000000      /* Error mask */
  193 #define TTY_FE          0x01000000      /* Framing error */
  194 #define TTY_PE          0x02000000      /* Parity error */
  195 #define TTY_OE          0x04000000      /* Overrun error */
  196 #define TTY_BI          0x08000000      /* Break condition */
  197 
  198 /* Is tp controlling terminal for p? */
  199 #define isctty(p, tp)                                                   \
  200         ((p)->p_session == (tp)->t_session && (p)->p_flag & P_CONTROLT)
  201 
  202 /* Is p in background of tp? */
  203 #define isbackground(p, tp)                                             \
  204         (isctty((p), (tp)) && (p)->p_pgrp != (tp)->t_pgrp)
  205 
  206 /* Unique sleep addresses. */
  207 #define TSA_CARR_ON(tp)         ((void *)&(tp)->t_rawq)
  208 #define TSA_HUP_OR_INPUT(tp)    ((void *)&(tp)->t_rawq.c_cf)
  209 #define TSA_OCOMPLETE(tp)       ((void *)&(tp)->t_outq.c_cl)
  210 #define TSA_OLOWAT(tp)          ((void *)&(tp)->t_outq)
  211 #define TSA_PTC_READ(tp)        ((void *)&(tp)->t_outq.c_cf)
  212 #define TSA_PTC_WRITE(tp)       ((void *)&(tp)->t_rawq.c_cl)
  213 #define TSA_PTS_READ(tp)        ((void *)&(tp)->t_canq)
  214 
  215 #ifdef KERNEL
  216 extern  struct tty *constty;    /* Temporary virtual console. */
  217 
  218 int      b_to_q __P((char *cp, int cc, struct clist *q));
  219 void     catq __P((struct clist *from, struct clist *to));
  220 void     clist_alloc_cblocks __P((struct clist *q, int ccmax, int ccres));
  221 void     clist_free_cblocks __P((struct clist *q));
  222 /* void  clist_init __P((void)); */ /* defined in systm.h for main() */
  223 int      getc __P((struct clist *q));
  224 void     ndflush __P((struct clist *q, int cc));
  225 int      ndqb __P((struct clist *q, int flag));
  226 char    *nextc __P((struct clist *q, char *cp, int *c));
  227 int      putc __P((int c, struct clist *q));
  228 int      q_to_b __P((struct clist *q, char *cp, int cc));
  229 int      unputc __P((struct clist *q));
  230 
  231 int     ttcompat __P((struct tty *tp, int com, caddr_t data, int flag));
  232 int     ttsetcompat __P((struct tty *tp, int *com, caddr_t data, struct termios *term));
  233 
  234 void     termioschars __P((struct termios *t));
  235 int      tputchar __P((int c, struct tty *tp));
  236 int      ttioctl __P((struct tty *tp, int com, void *data, int flag));
  237 int      ttread __P((struct tty *tp, struct uio *uio, int flag));
  238 void     ttrstrt __P((void *tp));
  239 int      ttyselect __P((struct tty *tp, int rw, struct proc *p));
  240 int      ttselect __P((dev_t dev, int rw, struct proc *p));
  241 void     ttsetwater __P((struct tty *tp));
  242 int      ttspeedtab __P((int speed, struct speedtab *table));
  243 int      ttstart __P((struct tty *tp));
  244 void     ttwakeup __P((struct tty *tp));
  245 int      ttwrite __P((struct tty *tp, struct uio *uio, int flag));
  246 void     ttwwakeup __P((struct tty *tp));
  247 void     ttyblock __P((struct tty *tp));
  248 void     ttychars __P((struct tty *tp));
  249 int      ttycheckoutq __P((struct tty *tp, int wait));
  250 int      ttyclose __P((struct tty *tp));
  251 void     ttyflush __P((struct tty *tp, int rw));
  252 void     ttyinfo __P((struct tty *tp));
  253 int      ttyinput __P((int c, struct tty *tp));
  254 int      ttylclose __P((struct tty *tp, int flag));
  255 int      ttymodem __P((struct tty *tp, int flag));
  256 int      ttyopen __P((dev_t device, struct tty *tp));
  257 int      ttysleep __P((struct tty *tp,
  258             void *chan, int pri, char *wmesg, int timeout));
  259 int      ttywait __P((struct tty *tp));
  260 struct tty *ttymalloc __P((void));
  261 void     ttyfree __P((struct tty *));
  262 
  263 #endif /* KERNEL */
  264 
  265 #endif /* !_SYS_TTY_H_ */

Cache object: 3af2dc879f1fb267de23baa75b5245b8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.