1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1998 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 /* 31 * University Copyright- Copyright (c) 1982, 1986, 1988 32 * The Regents of the University of California 33 * All Rights Reserved 34 * 35 * University Acknowledgment- Portions of this document are derived from 36 * software developed by the University of California, Berkeley, and its 37 * contributors. 38 */ 39 40 #ifndef _SYS_TTY_H 41 #define _SYS_TTY_H 42 43 #pragma ident "%Z%%M% %I% %E% SMI" 44 45 #include <sys/ttychars.h> 46 #include <sys/ttydev.h> 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 /* 53 * A clist structure is the head of a linked list queue of characters. 54 * The routines getc* and putc* manipulate these structures. 55 */ 56 57 struct clist { 58 int c_cc; /* character count */ 59 struct cblock *c_cf; /* pointer to first */ 60 struct cblock *c_cl; /* pointer to last */ 61 }; 62 63 /* Macro to find clist structure given pointer into it */ 64 #define CMATCH(pointer) (char *)(cfree + (pointer - cfree)) 65 66 /* Character control block for interrupt level control */ 67 68 struct ccblock { 69 caddr_t c_ptr; /* buffer address */ 70 ushort_t c_count; /* character count */ 71 ushort_t c_size; /* buffer size */ 72 }; 73 74 /* 75 * A tty structure is needed for each UNIX character device that 76 * is used for normal terminal IO. 77 */ 78 #define NCC 8 79 struct tty { 80 struct clist t_rawq; /* raw input queue */ 81 struct clist t_canq; /* canonical queue */ 82 struct clist t_outq; /* output queue */ 83 struct ccblock t_tbuf; /* tx control block */ 84 struct ccblock t_rbuf; /* rx control block */ 85 int (* t_proc)(); /* routine for device functions */ 86 ushort_t t_iflag; /* input modes */ 87 ushort_t t_oflag; /* output modes */ 88 ushort_t t_cflag; /* control modes */ 89 ushort_t t_lflag; /* line discipline modes */ 90 short t_state; /* internal state */ 91 o_pid_t t_pgrp; /* process group name */ 92 char t_line; /* line discipline */ 93 char t_delct; /* delimiter count */ 94 char t_term; /* terminal type */ 95 char t_tmflag; /* terminal flags */ 96 char t_col; /* current column */ 97 char t_row; /* current row */ 98 char t_vrow; /* variable row */ 99 char t_lrow; /* last physical row */ 100 char t_hqcnt; /* no. high queue packets on t_outq */ 101 char t_dstat; 102 /* used by terminal handlers and line disciplines */ 103 unsigned char t_cc[NCC]; /* settable control chars */ 104 }; 105 106 /* 107 * The structure of a clist block 108 */ 109 #define CLSIZE 64 110 struct cblock { 111 struct cblock *c_next; 112 char c_first; 113 char c_last; 114 char c_data[CLSIZE]; 115 }; 116 117 extern struct cblock *cfree; 118 extern struct cblock *getcb(); 119 extern struct cblock *getcf(); 120 extern struct clist ttnulq; 121 extern int cfreecnt; 122 123 struct chead { 124 struct cblock *c_next; 125 int c_size; 126 int c_flag; 127 }; 128 extern struct chead cfreelist; 129 130 struct inter { 131 int cnt; 132 }; 133 134 #define QESC 0200 /* queue escape */ 135 #define HQEND 01 /* high queue end */ 136 137 #define TTIPRI 28 138 #define TTOPRI 29 139 140 #ifdef u3b15 141 /* 142 * following defs allow for job control in both vpm and 143 * stand-alone tty environments 144 */ 145 #define VPMTTY 1 146 #define SATTY 2 147 #endif 148 149 /* limits */ 150 extern int ttlowat[], tthiwat[]; 151 #define TTYHOG 256 152 #define TTXOLO 132 153 #define TTXOHI 180 154 155 /* Hardware bits */ 156 #define DONE 0200 157 #define IENABLE 0100 158 #define OVERRUN 040000 159 #define FRERROR 020000 160 #define PERROR 010000 161 162 /* Internal state */ 163 #define TIMEOUT 01 /* Delay timeout in progress */ 164 #define WOPEN 02 /* Waiting for open to complete */ 165 #define ISOPEN 04 /* Device is open */ 166 #define TBLOCK 010 167 #define CARR_ON 020 /* Software copy of carrier-present */ 168 #define BUSY 040 /* Output in progress */ 169 #define OASLP 0100 /* Wakeup when output done */ 170 #define IASLP 0200 /* Wakeup when input done */ 171 #define TTSTOP 0400 /* Output stopped by ctl-s */ 172 #define EXTPROC 01000 /* External processing */ 173 #define TACT 02000 174 #define CLESC 04000 /* Last char escape */ 175 #define RTO 010000 /* Raw Timeout */ 176 #define TTIOW 020000 177 #define TTXON 040000 178 #define TTXOFF 0100000 179 180 /* l_output status */ 181 #define CPRES 0100000 182 183 /* device commands */ 184 #define T_OUTPUT 0 185 #define T_TIME 1 186 #define T_SUSPEND 2 187 #define T_RESUME 3 188 #define T_BLOCK 4 189 #define T_UNBLOCK 5 190 #define T_RFLUSH 6 191 #define T_WFLUSH 7 192 #define T_BREAK 8 193 #define T_INPUT 9 194 #define T_DISCONNECT 10 195 #define T_PARM 11 196 #define T_SWTCH 12 197 198 /* 199 * Terminal flags (set in t_tmflgs). 200 */ 201 202 #define SNL 1 /* non-standard new-line needed */ 203 #define ANL 2 /* automatic new-line */ 204 #define LCF 4 /* Special treatment of last col, row */ 205 #define TERM_CTLECHO 010 /* Echo terminal control characters */ 206 #define TERM_INVIS 020 /* do not send escape sequences to user */ 207 #define QLOCKB 040 /* high queue locked for base level */ 208 #define QLOCKI 0100 /* high queue locked for interrupts */ 209 #define TERM_BIT 0200 /* Bit reserved for terminal drivers. */ 210 /* Usually used to indicate that an esc */ 211 /* character has arrived and that the */ 212 /* next character is special. */ 213 /* This bit is the same as the TM_SET */ 214 /* bit which may never be set by a user */ 215 /* 216 * device reports 217 */ 218 #define L_BUF 0 219 #define L_BREAK 3 220 221 #ifdef __cplusplus 222 } 223 #endif 224 225 #endif /* _SYS_TTY_H */ 226