/******************************************************************* * * file : h/sys/tty.h * part#: * internal sequence#: * * ************************************************************ * * " c Copyright Hewlett-Packard Company, 1984.* All * * * rights are reserved. Copying or other reproduction * * * of this program except for archival purposes is * * * prohibited without the prior written consent of * * * Hewlett-Packard Company." * * ************************************************************ * * * Pisces Q-DOS project * Fred Taft * -------------------------------------------------------- * initial 4/20/83 * * Changed TTYHOG from 256 to 896 * Changed TTXOHI from 160 to 256 4/29/83 fdt * * Updated equates to reflect TWG standard 5/27/83 fdt * * Changed TTYHOG to 1024, and changed * TTXOHI to 256 and changed CLSIZE to 48. 6/27/83 fdt * * Added modem control stuff. 8/16/84 fdt * * Changed the t_state field in the tty * structure from short to long, and added * minor dev bit defines. NMTIMER 5 -> 6. 8/22/84 fdt * * Changed mflag typedef from int -> long. 9/10/84 fdt * * * ******************************************************************/ /* New modem structures */ #define NMTIMER 6 typedef unsigned long mflag; /* The following structure is used during timer ioctl's */ struct mtimer { unsigned short m_timers[NMTIMER]; }; /* * A clist structure is the head of a linked list queue of characters. * The routines getc* and putc* manipulate these structures. */ struct clist { int c_cc; /* character count */ struct cblock *c_cf; /* pointer to first */ struct cblock *c_cl; /* pointer to last */ }; /* * A tty structure is needed for each UNIX character device that * is used for normal terminal IO. */ #define NCC 8 /* number of settable control chars */ struct tty { struct clist t_rawq; /* raw input queue */ struct clist t_canq; /* canonical queue */ struct clist t_outq; /* output queue */ struct cblock *t_buf; /* buffer pointer */ int (* t_proc)(); /* routine for device functions */ ushort t_iflag; /* input modes */ ushort t_oflag; /* output modes */ ushort t_cflag; /* control modes */ ushort t_lflag; /* line discipline modes */ long t_state; /* internal state */ short t_pgrp; /* process group name */ char t_line; /* line discipline */ char t_delct; /* delimiter count */ char t_col; /* current column */ char t_row; /* current row */ int t_slcnl; /* shadow registers: line control */ int t_smcnl; /* modem control */ int t_sicnl; /* interrupt control */ unsigned char t_cc[NCC]; /* settable control chars */ char *t_card_ptr; /* points to window common data */ char t_int_lvl; /* interrupt level of card */ char t_int_flag; /* interrupt flags */ unsigned short timers[NMTIMER]; /* modem specific timers */ int scratch_1; /* extra space for expansion */ int scratch_2; /* extra space for expansion */ }; /* * The structure of a clist block */ #define CLSIZE 48 /* number of chars in a clist block */ struct cblock { struct cblock *c_next; /* pointer to next clist block */ char c_first; /* index of first char in block */ char c_last; /* index of last char in block */ char c_data[CLSIZE]; /* data block */ }; extern struct cblock cfree[]; extern struct cblock * getcb(); extern struct cblock * getcf(); extern struct clist ttnulq; /* * The structure of a clist head pointer */ struct chead { struct cblock *c_next; int c_size; }; extern struct chead cfreelist; /* pointer to head of freelist */ struct inter { int cnt; }; /* Modem Control Line Defines */ #define MDRS 00000000004 /* Data Rate Select line */ #define MDTR 00000000040 /* Data Terminal Ready */ #define MRTS 00010000000 /* Request To Send */ #define MDSR 00002000000 /* Data Set Ready */ #define MDCD 00000400000 /* Data Carrier Detect */ #define MRI 00000000010 /* Ring Indicator */ #define MCTS 00004000000 /* Clear To Send */ /* Modem Timer Defines */ #define MTCONNECT 0 #define MTCARRIER 1 #define MTNOACTIVITY 2 #define MTHANGUP 3 /* Minor device bits */ #define CCITT_MODE 0x0001 #define SIMPLE_MODE 0x0002 #define DEV_TTY 0x0010 #define DEV_CUL 0x0020 #define DEV_TTYD 0x0040 /* Indices into control character array */ #define VINTR 0 #define VQUIT 1 #define VERASE 2 #define VKILL 3 #define VEOF 4 #define VEOL 5 #define VMIN 4 #define VTIME 5 /* default control chars */ #define CINTR 0177 /* DEL */ #define CQUIT 034 /* cntl | */ #define CERASE '#' /* # */ #define CKILL '@' /* @ */ #define CEOF 04 /* cntl d */ #define CSTART 021 /* cntl q */ #define CSTOP 023 /* cntl s */ #define TTIPRI 28 /* sleep priority level during input */ #define TTOPRI 29 /* sleep priority level during output */ /* limits */ extern int ttlowat[]; /* lo water table for io */ extern int tthiwat[]; /* hi water table for io */ #define TTYHOG 1024 /* point at which input buffer will be flushed */ #define TTXOLO 60 /* point at which 'xon' will be sent */ #define TTXOHI 256 /* point at which 'xoff' will be sent */ /* input modes */ #define IGNBRK 0000001 /* Ignore incoming break */ #define BRKINT 0000002 /* Signal interrupt on received break */ #define IGNPAR 0000004 /* Ignore characters with parity errors */ #define PARMRK 0000010 /* Mark characters with parity errors */ #define INPCK 0000020 /* Enable input parity checking */ #define ISTRIP 0000040 /* Strip incoming character down to 7 bits */ #define INLCR 0000100 /* Map NL to CR on input */ #define IGNCR 0000200 /* Ignore CR */ #define ICRNL 0000400 /* Map CR to NL on input */ #define IUCLC 0001000 /* Map upper-case to lower_case on input */ #define IXON 0002000 /* Enable start/stop output control */ #define IXANY 0004000 /* Enable any character to restart output */ #define IXOFF 0010000 /* Enable start/stop input control */ #define IENQAK 0020000 /* output modes */ #define OPOST 0000001 /* Enable postprocessing of output */ #define OLCUC 0000002 /* Map lower_case to upper_case on output */ #define ONLCR 0000004 /* Map NL to CR-NL on output */ #define OCRNL 0000010 /* Map CR to NL on output */ #define ONOCR 0000020 /* No CR output at column 0 */ #define ONLRET 0000040 /* NL performs CR function */ #define OFILL 0000100 /* Use fill characters for delays */ #define OFDEL 0000200 /* Fill character is DEL, else NUL */ #define NLDLY 0000400 /* Select new-line delays */ #define NL0 0 #define NL1 0000400 #define CRDLY 0003000 /* Select carriage-return delays */ #define CR0 0 #define CR1 0001000 #define CR2 0002000 #define CR3 0003000 #define TABDLY 0014000 /* Select horizontal-tab delays */ #define TAB0 0 #define TAB1 0004000 #define TAB2 0010000 #define TAB3 0014000 #define BSDLY 0020000 /* Select backspace delays */ #define BS0 0 #define BS1 0020000 #define VTDLY 0040000 /* Select vertical-tab delays */ #define VT0 0 #define VT1 0040000 #define FFDLY 0100000 /* Select form-feed delays */ #define FF0 0 #define FF1 0100000 /* control modes */ #define CBAUD 0000037 #define B0 0 /* hangup */ #define B50 0000001 /* 50 baud */ #define B75 0000002 /* 75 baud */ #define B110 0000003 /* 110 baud */ #define B134 0000004 /* 134.5 baud */ #define B150 0000005 /* 150 baud */ #define B200 0000006 /* 200 baud */ #define B300 0000007 /* 300 baud */ #define B600 0000010 /* 600 baud */ #define B900 0000011 /* 900 baud */ #define B1200 0000012 /* 1200 baud */ #define B1800 0000013 /* 1800 baud */ #define B2400 0000014 /* 2400 baud */ #define B3600 0000015 /* 3600 baud */ #define B4800 0000016 /* 4800 baud */ #define B7200 0000017 /* 7200 baud */ #define B9600 0000020 /* 9600 baud */ #define B19200 0000021 /* 19200 baud */ #define B38400 0000022 /* 38400 baud */ #define EXTA 0000036 /* external baud rate A */ #define EXTB 0000037 /* external baud rate B */ #define CSIZE 0000140 #define CS5 0 /* use 5 data bits */ #define CS6 0000040 /* use 6 data bits */ #define CS7 0000100 /* use 7 data bits */ #define CS8 0000140 /* use 8 data bits */ #define CSTOPB 0000200 /* send 2 stop bits, else 1 */ #define CREAD 0000400 /* enable receiver */ #define PARENB 0001000 /* enable parity */ #define PARODD 0002000 /* odd parity, else even */ #define HUPCL 0004000 /* hangup on last close */ #define CLOCAL 0010000 /* local line, else dial-up */ /* line discipline 0 modes */ #define ISIG 0000001 /* Enable signals */ #define ICANON 0000002 /* Enable canonical input (cooked mode) */ #define XCASE 0000004 /* Canonical upper/lower presentation */ #define ECHO 0000010 /* Enable echo */ #define ECHOE 0000020 /* Echo erase character as BS-SP-BS */ #define ECHOK 0000040 /* Echo NL after kill character */ #define ECHONL 0000100 /* Echo NL */ #define NOFLSH 0000200 /* Disable flush after interrupt or quit */ #define SSPEED 7 /* default speed: 300 baud */ /* Received character error bits */ #define OVERRUN 040000 #define FRERROR 020000 #define PERROR 010000 /* Internal state */ #define TIMEOUT 01 /* Delay timeout in progress */ #define WOPEN 02 /* Waiting for open to complete */ #define ISOPEN 04 /* Device is open */ #define TBLOCK 010 /* Remote system is blocked */ #define CARR_ON 020 /* Software copy of carrier-present */ #define BUSY 040 /* Output in progress */ #define OASLP 0100 /* Wakeup when output done */ #define IASLP 0200 /* Wakeup when input done */ #define TTSTOP 0400 /* Output stopped by ctl-s */ #define EXTPROC 01000 /* External processing */ #define TACT 02000 /* Raw mode read timeout active */ #define ESC 04000 /* Last char received was escape */ #define RTO 010000 /* Raw mode read timeout active */ #define TTIOW 020000 /* Process asleep, waiting 4 output to drain */ #define TTXON 040000 /* Send 'start' char at next chance */ #define TTXOFF 0100000 /* Send 'stop' char at next chance */ #define CCITT 0200000 /* Device open for CCITT modem control */ #define SIMPLE 0400000 /* Device open for Simple modem control */ #define TTYD 01000000 /* Device open/pending for TTYD access */ #define CUL 02000000 /* Device open/pending for CUL access */ #define TTY 04000000 /* Device open for TTY access */ #define TTYD_NDELAY 010000000 /* Non-blocking TTYD open sleazed thru */ #define TTYD_PENDING 020000000 /* CCITT ttyd open is pending */ #define WAIT_FOR_RING 040000000 /* CCITT ttyd open is waiting for ring */ #define OPEN_TO_PENDING 0100000000 /* Open timeout is pending */ #define OPEN_TIMED_OUT 0200000000 /* Open has timed out */ #define CARRIER_TO_PENDING 0400000000 /* Loss of carrier timeout pending */ /* interrupt flags */ #define PEND_TXINT 1 /* Device capable of generating xmit interrupt */ /* l_output status */ #define CPRES 1 /* device commands */ #define T_OUTPUT 0 /* Start interrupt output process */ #define T_TIME 1 /* Terminate delay timeout */ #define T_SUSPEND 2 /* Suspend our output process */ #define T_RESUME 3 /* Resume our output process */ #define T_BLOCK 4 /* Send 'stop' char to remote system */ #define T_UNBLOCK 5 /* Send 'start' char to remote system */ #define T_RFLUSH 6 /* Resume out output process */ #define T_WFLUSH 7 /* Send 'start' char to remote system */ #define T_BREAK 8 /* Send break */ /* * Ioctl control packet */ struct termio { ushort c_iflag; /* input modes */ ushort c_oflag; /* output modes */ ushort c_cflag; /* control modes */ ushort c_lflag; /* line discipline modes */ char c_line; /* line discipline */ unsigned char c_cc[NCC]; /* control chars */ };