1 #ifndef _LINUX_TTY_H
2 #define _LINUX_TTY_H
3
4
5
6
7
8 #ifdef __KERNEL__
9 #include <linux/fs.h>
10 #include <linux/termios.h>
11 #include <linux/tqueue.h>
12 #include <linux/tty_driver.h>
13 #include <linux/tty_ldisc.h>
14
15 #include <asm/system.h>
16
17
18
19
20
21
22
23
24 #define MIN_NR_CONSOLES 1
25 #define MAX_NR_CONSOLES 63
26 #define MAX_NR_USER_CONSOLES 63
27
28
29 #define NR_PTYS 64
30 #define NR_LDISCS 16
31
32
33
34
35
36 struct screen_info {
37 unsigned char orig_x;
38 unsigned char orig_y;
39 unsigned char unused1[2];
40 unsigned short orig_video_page;
41 unsigned char orig_video_mode;
42 unsigned char orig_video_cols;
43 unsigned short orig_video_ega_ax;
44 unsigned short orig_video_ega_bx;
45 unsigned short orig_video_ega_cx;
46 unsigned char orig_video_lines;
47 };
48
49 extern struct screen_info screen_info;
50
51 #define ORIG_X (screen_info.orig_x)
52 #define ORIG_Y (screen_info.orig_y)
53 #define ORIG_VIDEO_PAGE (screen_info.orig_video_page)
54 #define ORIG_VIDEO_MODE (screen_info.orig_video_mode)
55 #define ORIG_VIDEO_COLS (screen_info.orig_video_cols)
56 #define ORIG_VIDEO_EGA_AX (screen_info.orig_video_ega_ax)
57 #define ORIG_VIDEO_EGA_BX (screen_info.orig_video_ega_bx)
58 #define ORIG_VIDEO_EGA_CX (screen_info.orig_video_ega_cx)
59 #define ORIG_VIDEO_LINES (screen_info.orig_video_lines)
60
61 #define VIDEO_TYPE_MDA 0x10
62 #define VIDEO_TYPE_CGA 0x11
63 #define VIDEO_TYPE_EGAM 0x20
64 #define VIDEO_TYPE_EGAC 0x21
65
66
67
68
69
70
71 #define __DISABLED_CHAR '\0'
72
73
74
75
76
77
78 #define TTY_FLIPBUF_SIZE 512
79
80 struct tty_flip_buffer {
81 struct tq_struct tqueue;
82 unsigned char char_buf[2*TTY_FLIPBUF_SIZE];
83 char flag_buf[2*TTY_FLIPBUF_SIZE];
84 char *char_buf_ptr;
85 unsigned char *flag_buf_ptr;
86 int count;
87 int buf_num;
88 };
89
90
91
92
93
94 #define TTY_NORMAL 0
95 #define TTY_BREAK 1
96 #define TTY_FRAME 2
97 #define TTY_PARITY 3
98 #define TTY_OVERRUN 4
99
100 #define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR])
101 #define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT])
102 #define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE])
103 #define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL])
104 #define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF])
105 #define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME])
106 #define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN])
107 #define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC])
108 #define START_CHAR(tty) ((tty)->termios->c_cc[VSTART])
109 #define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP])
110 #define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP])
111 #define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL])
112 #define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT])
113 #define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD])
114 #define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE])
115 #define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT])
116 #define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2])
117
118 #define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f))
119 #define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f))
120 #define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f))
121 #define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f))
122
123 #define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK)
124 #define I_BRKINT(tty) _I_FLAG((tty),BRKINT)
125 #define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR)
126 #define I_PARMRK(tty) _I_FLAG((tty),PARMRK)
127 #define I_INPCK(tty) _I_FLAG((tty),INPCK)
128 #define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP)
129 #define I_INLCR(tty) _I_FLAG((tty),INLCR)
130 #define I_IGNCR(tty) _I_FLAG((tty),IGNCR)
131 #define I_ICRNL(tty) _I_FLAG((tty),ICRNL)
132 #define I_IUCLC(tty) _I_FLAG((tty),IUCLC)
133 #define I_IXON(tty) _I_FLAG((tty),IXON)
134 #define I_IXANY(tty) _I_FLAG((tty),IXANY)
135 #define I_IXOFF(tty) _I_FLAG((tty),IXOFF)
136 #define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL)
137
138 #define O_OPOST(tty) _O_FLAG((tty),OPOST)
139 #define O_OLCUC(tty) _O_FLAG((tty),OLCUC)
140 #define O_ONLCR(tty) _O_FLAG((tty),ONLCR)
141 #define O_OCRNL(tty) _O_FLAG((tty),OCRNL)
142 #define O_ONOCR(tty) _O_FLAG((tty),ONOCR)
143 #define O_ONLRET(tty) _O_FLAG((tty),ONLRET)
144 #define O_OFILL(tty) _O_FLAG((tty),OFILL)
145 #define O_OFDEL(tty) _O_FLAG((tty),OFDEL)
146 #define O_NLDLY(tty) _O_FLAG((tty),NLDLY)
147 #define O_CRDLY(tty) _O_FLAG((tty),CRDLY)
148 #define O_TABDLY(tty) _O_FLAG((tty),TABDLY)
149 #define O_BSDLY(tty) _O_FLAG((tty),BSDLY)
150 #define O_VTDLY(tty) _O_FLAG((tty),VTDLY)
151 #define O_FFDLY(tty) _O_FLAG((tty),FFDLY)
152
153 #define C_BAUD(tty) _C_FLAG((tty),CBAUD)
154 #define C_CSIZE(tty) _C_FLAG((tty),CSIZE)
155 #define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB)
156 #define C_CREAD(tty) _C_FLAG((tty),CREAD)
157 #define C_PARENB(tty) _C_FLAG((tty),PARENB)
158 #define C_PARODD(tty) _C_FLAG((tty),PARODD)
159 #define C_HUPCL(tty) _C_FLAG((tty),HUPCL)
160 #define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL)
161 #define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD)
162 #define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS)
163
164 #define L_ISIG(tty) _L_FLAG((tty),ISIG)
165 #define L_ICANON(tty) _L_FLAG((tty),ICANON)
166 #define L_XCASE(tty) _L_FLAG((tty),XCASE)
167 #define L_ECHO(tty) _L_FLAG((tty),ECHO)
168 #define L_ECHOE(tty) _L_FLAG((tty),ECHOE)
169 #define L_ECHOK(tty) _L_FLAG((tty),ECHOK)
170 #define L_ECHONL(tty) _L_FLAG((tty),ECHONL)
171 #define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH)
172 #define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP)
173 #define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL)
174 #define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT)
175 #define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE)
176 #define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO)
177 #define L_PENDIN(tty) _L_FLAG((tty),PENDIN)
178 #define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN)
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194 struct tty_struct {
195 int magic;
196 struct tty_driver driver;
197 struct tty_ldisc ldisc;
198 struct termios *termios, *termios_locked;
199 int pgrp;
200 int session;
201 dev_t device;
202 int flags;
203 int count;
204 struct winsize winsize;
205 unsigned char stopped:1, hw_stopped:1, packet:1;
206 unsigned char ctrl_status;
207
208 struct tty_struct *link;
209 struct fasync_struct *fasync;
210 struct tty_flip_buffer flip;
211 int max_flip_cnt;
212 struct wait_queue *write_wait;
213 struct wait_queue *read_wait;
214 void *disc_data;
215 void *driver_data;
216
217 #define N_TTY_BUF_SIZE 4096
218
219
220
221
222
223 unsigned int column;
224 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
225 unsigned short minimum_to_wake;
226 unsigned overrun_time;
227 int num_overrun;
228 int process_char_map[256/32];
229 char *read_buf;
230 int read_head;
231 int read_tail;
232 int read_cnt;
233 int read_flags[N_TTY_BUF_SIZE/32];
234 int canon_data;
235 unsigned long canon_head;
236 unsigned int canon_column;
237 };
238
239
240 #define TTY_MAGIC 0x5401
241
242
243
244
245
246
247
248
249
250 #define TTY_THROTTLED 0
251 #define TTY_IO_ERROR 1
252 #define TTY_SLAVE_CLOSED 2
253 #define TTY_EXCLUSIVE 3
254 #define TTY_DEBUG 4
255 #define TTY_DO_WRITE_WAKEUP 5
256 #define TTY_PUSH 6
257
258 #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
259
260 extern void tty_write_flush(struct tty_struct *);
261
262 extern struct termios tty_std_termios;
263 extern struct tty_struct * redirect;
264 extern struct tty_ldisc ldiscs[];
265 extern int fg_console;
266 extern struct wait_queue * keypress_wait;
267
268
269
270
271
272
273
274 #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
275
276 extern long rs_init(long);
277 extern long lp_init(long);
278 extern long con_init(long);
279 extern long pty_init(long);
280 extern long tty_init(long);
281
282 extern int tty_paranoia_check(struct tty_struct *tty, dev_t device,
283 const char *routine);
284 extern char *_tty_name(struct tty_struct *tty, char *buf);
285 extern char *tty_name(struct tty_struct *tty);
286 extern void wait_until_sent(struct tty_struct * tty, int timeout);
287 extern int tty_check_change(struct tty_struct * tty);
288 extern void stop_tty(struct tty_struct * tty);
289 extern void start_tty(struct tty_struct * tty);
290 extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
291 extern int tty_register_driver(struct tty_driver *driver);
292 extern int tty_unregister_driver(struct tty_driver *driver);
293 extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
294 int buflen);
295
296 extern int is_orphaned_pgrp(int pgrp);
297 extern int is_ignored(int sig);
298 extern int tty_signal(int sig, struct tty_struct *tty);
299 extern void tty_hangup(struct tty_struct * tty);
300 extern void tty_vhangup(struct tty_struct * tty);
301 extern void tty_unhangup(struct file *filp);
302 extern int tty_hung_up_p(struct file * filp);
303 extern void do_SAK(struct tty_struct *tty);
304 extern void disassociate_ctty(int priv);
305
306
307 extern struct tty_ldisc tty_ldisc_N_TTY;
308
309
310 extern int n_tty_ioctl(struct tty_struct * tty, struct file * file,
311 unsigned int cmd, unsigned long arg);
312
313
314
315 extern int rs_open(struct tty_struct * tty, struct file * filp);
316
317
318
319 extern int pty_open(struct tty_struct * tty, struct file * filp);
320
321
322
323 extern int con_open(struct tty_struct * tty, struct file * filp);
324 extern void update_screen(int new_console);
325
326
327
328 extern int vt_ioctl(struct tty_struct *tty, struct file * file,
329 unsigned int cmd, unsigned long arg);
330
331 #endif
332 #endif