home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / tty.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-18  |  4.6 KB  |  174 lines

  1. /*
  2.  *    @(#) tty.h 2.3 88/05/18 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987, 1988.
  5.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987, 1988.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  */
  10.  
  11. /*
  12.  * A clist structure is the head of a linked list queue of characters.
  13.  * The routines getc* and putc* manipulate these structures.
  14.  */
  15.  
  16. #include "termio.h"
  17.  
  18. struct clist {
  19.     int    c_cc;        /* character count */
  20.     struct cblock *c_cf;    /* pointer to first */
  21.     struct cblock *c_cl;    /* pointer to last */
  22. };
  23.  
  24. /* Macro to find cblock structure given pointer into it    */
  25. #define CMATCH(pointer)        (cfree + (pointer - cfree))
  26.  
  27. /* Character control block for interrupt level control    */
  28.  
  29. struct ccblock {
  30.     unsigned char *c_ptr;    /* buffer address    */
  31.     ushort    c_count;    /* character count    */
  32.     ushort    c_size;        /* buffer size        */
  33. };
  34.  
  35. /*
  36.  * A tty structure is needed for each UNIX character device that
  37.  * is used for normal terminal IO.
  38.  */
  39. #define    NCC    8
  40. struct tty {
  41.     struct    clist t_rawq;    /* raw input queue */
  42.     struct    clist t_canq;    /* canonical queue */
  43.     struct    clist t_outq;    /* output queue */
  44.     struct    ccblock    t_tbuf;    /* tx control block */
  45.     struct    ccblock t_rbuf;    /* rx control block */
  46. #ifdef M_I386
  47.     int    (*t_proc)();/* routine for device functions */
  48. #else
  49.     int    (far *t_proc)();/* routine for device functions */
  50. #endif
  51.     ushort    t_iflag;    /* input modes */
  52.     ushort    t_oflag;    /* output modes */
  53.     ushort    t_cflag;    /* control modes */
  54.     ushort    t_lflag;    /* line discipline modes */
  55.     short    t_state;    /* internal state */
  56.     short    t_pgrp;        /* process group name */
  57.     char    t_line;        /* line discipline */
  58.     char    t_delct;    /* delimiter count */
  59.     char    t_mstate;    /* emapping state (t_xmp valid if non-null) */
  60.     char    t_yyy;        /* reserved (was t_mchar:saved emapping char) */
  61.     char    t_col;        /* current column */
  62.     char    t_merr;        /* emapping error flag */
  63.     struct    xmap *t_xmp;    /* ptr to struct for emap and nmap routines */
  64.     char    t_xstate;    /* extended state */    
  65.     char    t_dstat;    /* used by line disciplines */
  66.     unsigned char    t_schar;/* save timeout char instead of using lflag */
  67.     char    t_xxx;        /* reserved */
  68.     unsigned char    t_cc[NCC+2];    /* settable control chars */
  69. };
  70.  
  71. /*
  72.  * The structure of a clist block
  73.  */
  74. #define    CLSIZE        32
  75. #define    CLFSIZE        ((CLSIZE + 7) / 8)
  76. struct cblock {
  77.     struct cblock  *c_next;
  78.     unsigned char    c_first;
  79.     unsigned char    c_last;
  80.     unsigned char    c_data[CLSIZE];
  81.     unsigned char     c_dflags[CLFSIZE];
  82. };
  83.  
  84. extern struct cblock cfree[];
  85. extern struct cblock * getcb();
  86. extern struct cblock * getcf();
  87. extern struct clist ttnulq;
  88.  
  89. struct chead {
  90.     struct cblock *c_next;
  91.     int    c_size;
  92.     int    c_flag;
  93. };
  94. extern struct chead cfreelist;
  95.  
  96. struct inter {
  97.     int    cnt;
  98. };
  99.  
  100. #define    QESC    0400    /* queue escape */    
  101. #define QDELAY    0400    /* delay output */
  102.  
  103. #define    TTIPRI    28
  104. #define    TTOPRI    29
  105.  
  106. /* limits */
  107. extern int ttlowat[], tthiwat[], ttyhog;
  108. #define    TTYHOG    256
  109. #define    TTXOLO    60
  110. #define    TTXOHI    180
  111. #define    TTECHI    80
  112.  
  113. #define    TTHIWAT(tp)    tthiwat[(tp)->t_cflag & CBAUD]
  114. #define    TTLOWAT(tp)    ttlowat[(tp)->t_cflag & CBAUD]
  115.  
  116. /* Hardware bits */
  117. #define    DONE    0200
  118. #define    IENABLE    0100
  119. #define    OVERRUN    040000
  120. #define    FRERROR    020000
  121. #define    PERROR    010000
  122.  
  123. /* Internal state */
  124. #define    TIMEOUT    01        /* Delay timeout in progress */
  125. #define    WOPEN    02        /* Waiting for open to complete */
  126. #define    ISOPEN    04        /* Device is open */
  127. #define    TBLOCK    010
  128. #define    CARR_ON    020        /* Software copy of carrier-present */
  129. #define    BUSY    040        /* Output in progress */
  130. #define    OASLP    0100        /* Wakeup when output done */
  131. #define    IASLP    0200        /* Wakeup when input done */
  132. #define    TTSTOP    0400        /* Output stopped by ctl-s */
  133. #define    EXTPROC    01000        /* External processing */
  134. #define    TACT    02000
  135. #define    CLESC    04000        /* Last char escape */
  136. #define    RTO    010000        /* Raw Timeout */
  137. #define    TTIOW    020000
  138. #define    TTXON    040000
  139. #define    TTXOFF    0100000
  140.  
  141. /* Extended internal state */
  142. #define    EXTDLY    01        /* External delay processing */
  143. #define TRCOLL    02        /* Collision in select (read fd) */
  144. #define TWCOLL    04        /* Collision in select (write fd) */
  145. #define TECOLL    010        /* Collision in select (exception fd) */
  146.  
  147. /* l_output status */
  148. #define    CPRES    0100000
  149.  
  150. /* device commands */
  151. #define    T_OUTPUT    0
  152. #define    T_TIME        1
  153. #define    T_SUSPEND    2
  154. #define    T_RESUME    3
  155. #define    T_BLOCK        4
  156. #define    T_UNBLOCK    5
  157. #define    T_RFLUSH    6
  158. #define    T_WFLUSH    7
  159. #define    T_BREAK        8
  160. #define    T_INPUT        9
  161. #define    T_PARM        11
  162. #define    T_SWTCH        12
  163.  
  164. /*
  165.  *    device report
  166.  */
  167. #define    L_BUF    0
  168. #define    L_BREAK    3
  169.  
  170. /* Extract minor device bits not associated with modem control */
  171. #define UNMODEM(dev)    (dev & 0x7f)
  172. /* does this dev have modem support */
  173. #define ISMODEM(dev)    ((dev & 0x80) == 0)
  174.