|
|
1.1 root 1: /*
2: * Kernel portion of typewriter structure.
3: */
4: #ifndef __SYS_KTTY_H__
5: #define __SYS_KTTY_H__
6:
7: #include <common/feature.h>
8: #include <kernel/timeout.h>
9: #include <sys/types.h>
10: #include <sys/poll.h>
11: #include <sys/clist.h>
12: #include <sgtty.h>
13: #if _I386
14: #include <termio.h>
15: #endif
16:
17: #define NCIB 256 /* Input buffer */
18: #define OHILIM 128 /* Output buffer hi water mark */
19: #define OLOLIM 40 /* Output buffer lo water mark */
20: #define IHILIM 512 /* Input buffer hi water mark */
21: #define ILOLIM 40 /* Input buffer lo water mark */
22: #define ITSLIM (IHILIM-(IHILIM/4)) /* Input buffer tandem stop mark */
23: #define ESC '\\' /* Some characters */
24:
25: typedef struct tty {
26: CQUEUE t_oq; /* Output queue */
27: CQUEUE t_iq; /* Input queue */
28: char *t_ddp; /* Device specific */
29: int (*t_start)(); /* Start function */
30: int (*t_param)(); /* Load parameters function */
31: char t_dispeed; /* Default input speed */
32: char t_dospeed; /* Default output speed */
33: int t_open; /* Open count */
34: int t_flags; /* Flags */
35: char t_nfill; /* Number of fill characters */
36: char t_fillb; /* The fill character */
37: int t_ibx; /* Input buffer index */
38: char t_ib[NCIB]; /* Input buffer */
39: int t_hpos; /* Horizontal position */
40: int t_opos; /* Original horizontal position */
41: struct sgttyb t_sgttyb;/* Stty/gtty information */
42: struct tchars t_tchars;/* Tchars information */
43: #if _I386
44: struct termio t_termio;
45: #endif
46: int t_group; /* Process group */
47: int t_escape; /* Pending escape count */
48: event_t t_ipolls; /* List of input polls enabled on device */
49: event_t t_opolls; /* List of output polls enabled on device */
50: TIM t_rawtim; /* Raw timing struct */
51: int t_cs_sel; /* 0 for resident drivers, CS for loadable */
52: #if _I386
53: TIM t_vtime; /* VTIME timing struct */
54: TIM t_sbrk; /* TCSBRK timing struct */
55: #endif
56: } TTY;
57:
58: /*
59: * Test macros for various conditions related to the terminal settings; the
60: * tests are related to conditions at the granularity of the System V modes,
61: * so for Coherent-286 the conditions are synthesized from the old V7 modes.
62: */
63:
64: #define _IS_BREAK_CHAR(tp,c) ((tp)->t_tchars.t_brkc == (c))
65:
66: /*
67: * The following are not part of S5 sgtty.
68: */
69:
70: #define _IS_RAW_INPUT_MODE(tp) (((tp)->t_sgttyb.sg_flags & RAWIN) != 0)
71: #define _IS_CRT_MODE(tp) (((tp)->t_sgttyb.sg_flags & CRT) != 0)
72:
73: #if _I386
74:
75: #define _IS_EOF_CHAR(tp,c) ((tp)->t_termio.c_cc [VEOF] == (c))
76: #define _IS_ERASE_CHAR(tp,c) ((tp)->t_termio.c_cc [VERASE] == (c))
77: #define _IS_INTERRUPT_CHAR(tp,c) \
78: ((tp)->t_termio.c_cc [VINTR] == (c))
79: #define _IS_KILL_CHAR(tp,c) ((tp)->t_termio.c_cc [VKILL] == (c))
80: #define _IS_QUIT_CHAR(tp,c) ((tp)->t_termio.c_cc [VQUIT] == (c))
81: #define _IS_START_CHAR(tp,c) (CSTART == (c))
82: #define _IS_STOP_CHAR(tp,c) (CSTOP == (c))
83:
84: #define _IS_CANON_MODE(tp) (((tp)->t_termio.c_lflag & ICANON) != 0)
85: #define _IS_ECHO_MODE(tp) (((tp)->t_termio.c_lflag & ECHO) != 0)
86: #define _IS_ICRNL_MODE(tp) (((tp)->t_termio.c_iflag & ICRNL) != 0)
87: #define _IS_IGNCR_MODE(tp) (((tp)->t_termio.c_iflag & IGNCR) != 0)
88: #define _IS_ISIG_MODE(tp) (((tp)->t_termio.c_lflag & ISIG) != 0)
89: #define _IS_ISTRIP_MODE(tp) (((tp)->t_termio.c_iflag & ISTRIP) != 0)
90: #define _IS_IXON_MODE(tp) (((tp)->t_termio.c_iflag & IXON) != 0)
91: #define _IS_IXANY_MODE(tp) (((tp)->t_termio.c_iflag & IXANY) != 0)
92: #define _IS_OCRNL_MODE(tp) (((tp)->t_termio.c_oflag & OCRNL) != 0)
93: #define _IS_ONLCR_MODE(tp) (((tp)->t_termio.c_oflag & ONLCR) != 0)
94: #define _IS_RAW_OUT_MODE(tp) (((tp)->t_termio.c_oflag & OPOST) == 0)
95: #define _IS_TANDEM_MODE(tp) (((tp)->t_termio.c_iflag & IXOFF) != 0)
96: #define _IS_XTABS_MODE(tp) (((tp)->t_termio.c_oflag & TABDLY) == TAB3)
97:
98: #else /* if ! _I386 */
99:
100: #define _IS_EOF_CHAR(tp,c) ((tp)->t_tchars.t_eofc == (c))
101: #define _IS_INTRRUPT_CHAR(tp,c) ((tp)->t_tchars.t_intrc == (c))
102: #define _IS_QUIT_CHAR(tp,c) ((tp)->t_tchars.t_quitc == (c))
103: #define _IS_START_CHAR(tp,c) ((tp)->t_tchars.t_startc == (c))
104: #define _IS_STOP_CHAR(tp,c) ((tp)->t_tchars.t_stopc == (c))
105: #define _IS_ERASE_CHAR(tp,c) (((tp)->t_sgttyb.sg_erase == (c))
106: #define _IS_KILL_CHAR(tp,c) (((tp)->t_sgttyb.sg_kill == (c))
107:
108: #define _IS_CANON_MODE(tp) ((tp)->t_sgttyb.sg_flags & \
109: (RAWIN | CBREAK)) == 0)
110: #define _IS_ECHO_MODE(tp) (((tp)->t_sgttyb.sg_flags & ECHO) != 0)
111: #define _IS_ICRNL_MODE(tp) (((tp)->t_sgttyb.sg_flags & CRMOD) != 0)
112: #define _IS_IGNCR_MODE(tp) 0
113: #define _IS_ISIG_MODE(tp) (! _IS_RAW_INPUT_MODE (tp))
114: #define _IS_ISTRIP_MODE(tp) (! _IS_RAW_INPUT_MODE (tp))
115: #define _IS_IXON_MODE(tp) (! _IS_RAW_INPUT_MODE (tp))
116: #define _IS_OCRNL_MODE(tp) 0
117: #define _IS_ONLCR_MODE(tp) (((tp)->t_sgttyb.sg_flags & CRMOD) != 0)
118: #define _IS_RAW_OUTPUT_MODE(tp) (((tp)->t_sgttyb.sg_flags & RAWOUT) != 0)
119: #define _IS_TANDEM_MODE(tp) (((tp)->t_sgttyb.sg_flags & TANDEM) != 0)
120: #define _IS_XTABS_MODE(tp) (((tp)->t_sgttyb.sg_flags & XTABS) != 0)
121:
122: #endif /* ! _I386 */
123:
124: #endif /* ! defined (__SYS_KTTY_H__) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.