home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / tty.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  7.4 KB  |  221 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    tty.h,v $
  29.  * Revision 2.1  92/04/21  17:16:54  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*-
  36.  * Copyright (c) 1982, 1986 The Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms, with or without
  40.  * modification, are permitted provided that the following conditions
  41.  * are met:
  42.  * 1. Redistributions of source code must retain the above copyright
  43.  *    notice, this list of conditions and the following disclaimer.
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in the
  46.  *    documentation and/or other materials provided with the distribution.
  47.  * 3. All advertising materials mentioning features or use of this software
  48.  *    must display the following acknowledgement:
  49.  *    This product includes software developed by the University of
  50.  *    California, Berkeley and its contributors.
  51.  * 4. Neither the name of the University nor the names of its contributors
  52.  *    may be used to endorse or promote products derived from this software
  53.  *    without specific prior written permission.
  54.  *
  55.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  56.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  58.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  59.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65.  * SUCH DAMAGE.
  66.  *
  67.  *    @(#)tty.h    7.10 (Berkeley) 6/26/91
  68.  */
  69.  
  70. #include <sys/termios.h>
  71.  
  72. #ifdef    KERNEL
  73. #include <uxkern/import_mach.h>
  74. #endif    KERNEL
  75.  
  76. /*
  77.  * Clists are character lists, which is a variable length linked list
  78.  * of cblocks, wiht a count of the number of characters in the list.
  79.  */
  80. struct clist {
  81.     int    c_cc;        /* count of characters in queue */
  82.     char    *c_cf;        /* first character/cblock */
  83.     char    *c_cl;        /* last chararacter/cblock */
  84. };
  85.  
  86. /*
  87.  * Per-tty structure.
  88.  *
  89.  * Should be split in two, into device and tty drivers.
  90.  * Glue could be masks of what to echo and circular buffer
  91.  * (low, high, timeout).
  92.  */
  93. struct tty {
  94.     struct    clist t_rawq;        /* queues */
  95.     struct    clist t_canq;
  96.     struct    clist t_outq;
  97.     int    (*t_oproc)();        /* device */
  98.     int    (*t_param)();        /* device */
  99.     struct    proc *t_rsel;        /* tty */
  100.     struct    proc *t_wsel;
  101.     caddr_t    T_LINEP;         /* XXX */
  102.     caddr_t    t_addr;            /* ??? */
  103.     mach_port_t    t_device_port;
  104.     mach_port_t    t_reply_port;
  105.     dev_t    t_dev;            /* device */
  106.     int    t_flags;        /* (compat) some of both */
  107.     int    t_state;        /* some of both */
  108.     struct    session *t_session;    /* tty */
  109.     struct    pgrp *t_pgrp;        /* foreground process group */
  110.     char    t_line;            /* glue */
  111.     short    t_col;            /* tty */
  112.     short    t_rocount, t_rocol;    /* tty */
  113.     short    t_hiwat;        /* hi water mark */
  114.     short    t_lowat;        /* low water mark */
  115.     struct    winsize t_winsize;    /* window size */
  116.     struct    termios t_termios;    /* termios state */
  117. #define    t_iflag        t_termios.c_iflag
  118. #define    t_oflag        t_termios.c_oflag
  119. #define    t_cflag        t_termios.c_cflag
  120. #define    t_lflag        t_termios.c_lflag
  121. #define    t_min        t_termios.c_min
  122. #define    t_time        t_termios.c_time
  123. #define    t_cc        t_termios.c_cc
  124. #define t_ispeed    t_termios.c_ispeed
  125. #define t_ospeed    t_termios.c_ospeed
  126.     long    t_cancc;        /* stats */
  127.     long    t_rawcc;
  128.     long    t_outcc;
  129.     short    t_gen;            /* generation number */
  130. };
  131.  
  132. #define    TTIPRI    25            /* sleep priority for tty reads */
  133. #define    TTOPRI    26            /* sleep priority for tty writes */
  134.  
  135. #define    TTMASK    15
  136. #define    OBUFSIZ    100
  137. #define    TTYHOG    1024
  138.  
  139. #ifdef KERNEL
  140. #define TTMAXHIWAT    roundup(2048, CBSIZE)
  141. #define TTMINHIWAT    roundup(100, CBSIZE)
  142. #define TTMAXLOWAT    256
  143. #define TTMINLOWAT    32
  144. extern    struct ttychars ttydefaults;
  145. #endif /* KERNEL */
  146.  
  147. /* internal state bits */
  148. #define    TS_TIMEOUT    0x000001    /* delay timeout in progress */
  149. #define    TS_WOPEN    0x000002    /* waiting for open to complete */
  150. #define    TS_ISOPEN    0x000004    /* device is open */
  151. #define    TS_FLUSH    0x000008    /* outq has been flushed during DMA */
  152. #define    TS_CARR_ON    0x000010    /* software copy of carrier-present */
  153. #define    TS_BUSY        0x000020    /* output in progress */
  154. #define    TS_ASLEEP    0x000040    /* wakeup when output done */
  155. #define    TS_XCLUDE    0x000080    /* exclusive-use flag against open */
  156. #define    TS_TTSTOP    0x000100    /* output stopped by ctl-s */
  157. /* was    TS_HUPCLS    0x000200      * hang up upon last close */
  158. #define    TS_TBLOCK    0x000400    /* tandem queue blocked */
  159. #define    TS_RCOLL    0x000800    /* collision in read select */
  160. #define    TS_WCOLL    0x001000    /* collision in write select */
  161. #define    TS_ASYNC    0x004000    /* tty in async i/o mode */
  162. /* state for intra-line fancy editing work */
  163. #define    TS_BKSL        0x010000    /* state for lowercase \ work */
  164. #define    TS_ERASE    0x040000    /* within a \.../ for PRTRUB */
  165. #define    TS_LNCH        0x080000    /* next character is literal */
  166. #define    TS_TYPEN    0x100000    /* retyping suspended input (PENDIN) */
  167. #define    TS_CNTTB    0x200000    /* counting tab width, ignore FLUSHO */
  168.  
  169. #define TS_ONDELAY    0x400000
  170. #define TS_RQUEUED    0x800000
  171.  
  172. #define    TS_LOCAL    (TS_BKSL|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
  173.  
  174. /* define partab character types */
  175. #define    ORDINARY    0
  176. #define    CONTROL        1
  177. #define    BACKSPACE    2
  178. #define    NEWLINE        3
  179. #define    TAB        4
  180. #define    VTAB        5
  181. #define    RETURN        6
  182.  
  183. struct speedtab {
  184.         int sp_speed;
  185.         int sp_code;
  186. };
  187. /*
  188.  * Flags on character passed to ttyinput
  189.  */
  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 or BREAK condition */
  194. #define TTY_PE          0x02000000      /* Parity error */
  195.  
  196. /*
  197.  * Is tp controlling terminal for p
  198.  */
  199. #define isctty(p, tp)    ((p)->p_session == (tp)->t_session && \
  200.              (p)->p_flag&SCTTY)
  201. /*
  202.  * Is p in background of tp
  203.  */
  204. #define isbackground(p, tp)    (isctty((p), (tp)) && \
  205.                 (p)->p_pgrp != (tp)->t_pgrp)
  206. /*
  207.  * Modem control commands (driver).
  208.  */
  209. #define    DMSET        0
  210. #define    DMBIS        1
  211. #define    DMBIC        2
  212. #define    DMGET        3
  213.  
  214. #ifdef KERNEL
  215. /* symbolic sleep message strings */
  216. extern     char ttyin[], ttyout[], ttopen[], ttclos[], ttybg[], ttybuf[];
  217. #endif
  218.  
  219. #define TTHIWAT(tp) (tp)->t_hiwat
  220. #define TTLOWAT(tp) (tp)->t_lowat
  221.