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