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