This source file includes following definitions.
- set_bit
- clear_bit
1 #ifndef _LINUX_TTY_H
2 #define _LINUX_TTY_H
3
4
5
6
7
8 #include <linux/termios.h>
9
10 #include <asm/system.h>
11
12 #define NR_CONSOLES 8
13
14
15
16
17
18 struct screen_info {
19 unsigned char orig_x;
20 unsigned char orig_y;
21 unsigned char unused1[2];
22 unsigned short orig_video_page;
23 unsigned char orig_video_mode;
24 unsigned char orig_video_cols;
25 unsigned short orig_video_ega_ax;
26 unsigned short orig_video_ega_bx;
27 unsigned short orig_video_ega_cx;
28 unsigned char orig_video_lines;
29 };
30
31 extern struct screen_info screen_info;
32
33 #define ORIG_X (screen_info.orig_x)
34 #define ORIG_Y (screen_info.orig_y)
35 #define ORIG_VIDEO_PAGE (screen_info.orig_video_page)
36 #define ORIG_VIDEO_MODE (screen_info.orig_video_mode)
37 #define ORIG_VIDEO_COLS (screen_info.orig_video_cols)
38 #define ORIG_VIDEO_EGA_AX (screen_info.orig_video_ega_ax)
39 #define ORIG_VIDEO_EGA_BX (screen_info.orig_video_ega_bx)
40 #define ORIG_VIDEO_EGA_CX (screen_info.orig_video_ega_cx)
41 #define ORIG_VIDEO_LINES (screen_info.orig_video_lines)
42
43 #define VIDEO_TYPE_MDA 0x10
44 #define VIDEO_TYPE_CGA 0x11
45 #define VIDEO_TYPE_EGAM 0x20
46 #define VIDEO_TYPE_EGAC 0x21
47
48
49
50
51
52
53 #define __DISABLED_CHAR '\0'
54
55
56
57
58
59
60
61 #define TTY_BUF_SIZE 1024
62
63 struct tty_queue {
64 unsigned long data;
65 unsigned long head;
66 unsigned long tail;
67 struct wait_queue * proc_list;
68 unsigned char buf[TTY_BUF_SIZE];
69 };
70
71 struct serial_struct {
72 int type;
73 int line;
74 int port;
75 int irq;
76 int flags;
77 int xmit_fifo_size;
78 int custom_divisor;
79 int reserved[8];
80 };
81
82
83
84
85 #define PORT_UNKNOWN 0
86 #define PORT_8250 1
87 #define PORT_16450 2
88 #define PORT_16550 3
89 #define PORT_16550A 4
90
91
92
93
94 #define ASYNC_NOSCRATCH 0x0001
95 #define ASYNC_FOURPORT 0x0002
96
97 #define ASYNC_SPD_MASK 0x0030
98 #define ASYNC_SPD_HI 0x0010
99 #define ASYNC_SPD_VHI 0x0020
100 #define ASYNC_SPD_CUST 0x0030
101
102 #define IS_A_CONSOLE(min) (((min) & 0xC0) == 0x00)
103 #define IS_A_SERIAL(min) (((min) & 0xC0) == 0x40)
104 #define IS_A_PTY(min) ((min) & 0x80)
105 #define IS_A_PTY_MASTER(min) (((min) & 0xC0) == 0x80)
106 #define IS_A_PTY_SLAVE(min) (((min) & 0xC0) == 0xC0)
107 #define PTY_OTHER(min) ((min) ^ 0x40)
108
109 #define SL_TO_DEV(line) ((line) | 0x40)
110 #define DEV_TO_SL(min) ((min) & 0x3F)
111
112 #define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
113 #define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
114 #define EMPTY(a) ((a)->head == (a)->tail)
115 #define LEFT(a) (((a)->tail-(a)->head-1)&(TTY_BUF_SIZE-1))
116 #define LAST(a) ((a)->buf[(TTY_BUF_SIZE-1)&((a)->head-1)])
117 #define FULL(a) (!LEFT(a))
118 #define CHARS(a) (((a)->head-(a)->tail)&(TTY_BUF_SIZE-1))
119
120 extern void put_tty_queue(char c, struct tty_queue * queue);
121 extern int get_tty_queue(struct tty_queue * queue);
122
123 #define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR])
124 #define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT])
125 #define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE])
126 #define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL])
127 #define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF])
128 #define START_CHAR(tty) ((tty)->termios->c_cc[VSTART])
129 #define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP])
130 #define SUSPEND_CHAR(tty) ((tty)->termios->c_cc[VSUSP])
131
132 #define _L_FLAG(tty,f) ((tty)->termios->c_lflag & f)
133 #define _I_FLAG(tty,f) ((tty)->termios->c_iflag & f)
134 #define _O_FLAG(tty,f) ((tty)->termios->c_oflag & f)
135
136 #define L_CANON(tty) _L_FLAG((tty),ICANON)
137 #define L_ISIG(tty) _L_FLAG((tty),ISIG)
138 #define L_ECHO(tty) _L_FLAG((tty),ECHO)
139 #define L_ECHOE(tty) _L_FLAG((tty),ECHOE)
140 #define L_ECHOK(tty) _L_FLAG((tty),ECHOK)
141 #define L_ECHONL(tty) _L_FLAG((tty),ECHONL)
142 #define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL)
143 #define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE)
144 #define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP)
145
146 #define I_UCLC(tty) _I_FLAG((tty),IUCLC)
147 #define I_NLCR(tty) _I_FLAG((tty),INLCR)
148 #define I_CRNL(tty) _I_FLAG((tty),ICRNL)
149 #define I_NOCR(tty) _I_FLAG((tty),IGNCR)
150 #define I_IXON(tty) _I_FLAG((tty),IXON)
151 #define I_STRP(tty) _I_FLAG((tty),ISTRIP)
152
153 #define O_POST(tty) _O_FLAG((tty),OPOST)
154 #define O_NLCR(tty) _O_FLAG((tty),ONLCR)
155 #define O_CRNL(tty) _O_FLAG((tty),OCRNL)
156 #define O_NLRET(tty) _O_FLAG((tty),ONLRET)
157 #define O_LCUC(tty) _O_FLAG((tty),OLCUC)
158
159 #define C_SPEED(tty) ((tty)->termios->c_cflag & CBAUD)
160 #define C_HUP(tty) (C_SPEED((tty)) == B0)
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176 struct tty_struct {
177 struct termios *termios;
178 int pgrp;
179 int session;
180 unsigned char stopped:1, status_changed:1, packet:1;
181 unsigned char ctrl_status;
182 short line;
183 int flags;
184 int count;
185 struct winsize winsize;
186 int (*open)(struct tty_struct * tty, struct file * filp);
187 void (*close)(struct tty_struct * tty, struct file * filp);
188 void (*write)(struct tty_struct * tty);
189 int (*ioctl)(struct tty_struct *tty, struct file * file,
190 unsigned int cmd, unsigned int arg);
191 void (*throttle)(struct tty_struct * tty, int status);
192 struct tty_struct *link;
193 struct tty_queue read_q;
194 struct tty_queue write_q;
195 struct tty_queue secondary;
196 };
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214 #define TTY_THROTTLE_SQ_FULL 1
215 #define TTY_THROTTLE_SQ_AVAIL 2
216 #define TTY_THROTTLE_RQ_FULL 3
217 #define TTY_THROTTLE_RQ_AVAIL 4
218
219
220
221
222
223
224 #define SQ_THRESHOLD_LW 0
225 #define SQ_THRESHOLD_HW 768
226 #define RQ_THRESHOLD_LW 64
227 #define RQ_THRESHOLD_HW 768
228
229
230
231
232
233
234
235
236
237
238 #define TTY_WRITE_BUSY 0
239 #define TTY_READ_BUSY 1
240 #define TTY_CR_PENDING 2
241 #define TTY_SQ_THROTTLED 3
242 #define TTY_RQ_THROTTLED 4
243
244
245
246
247
248
249 extern inline int set_bit(int nr,int * addr)
250 {
251 char ok;
252
253 __asm__ __volatile__("btsl %1,%2\n\tsetb %0":
254 "=q" (ok):"r" (nr),"m" (*(addr)));
255 return ok;
256 }
257
258 extern inline int clear_bit(int nr, int * addr)
259 {
260 char ok;
261
262 __asm__ __volatile__("btrl %1,%2\n\tsetnb %0":
263 "=q" (ok):"r" (nr),"m" (*(addr)));
264 return ok;
265 }
266
267 #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
268 #define TTY_READ_FLUSH(tty) tty_read_flush((tty))
269
270 extern void tty_write_flush(struct tty_struct *);
271 extern void tty_read_flush(struct tty_struct *);
272
273 extern struct tty_struct *tty_table[];
274 extern struct tty_struct * redirect;
275 extern int fg_console;
276 extern unsigned long video_num_columns;
277 extern unsigned long video_num_lines;
278 extern struct wait_queue * keypress_wait;
279
280 #define TTY_TABLE_IDX(nr) ((nr) ? (nr) : (fg_console+1))
281 #define TTY_TABLE(nr) (tty_table[TTY_TABLE_IDX(nr)])
282
283
284
285
286
287
288
289 #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
290
291 extern long rs_init(long);
292 extern long lp_init(long);
293 extern long con_init(long);
294 extern long tty_init(long);
295
296 extern void flush_input(struct tty_struct * tty);
297 extern void flush_output(struct tty_struct * tty);
298 extern void wait_until_sent(struct tty_struct * tty);
299 extern void copy_to_cooked(struct tty_struct * tty);
300
301 extern int tty_ioctl(struct inode *, struct file *, unsigned int, unsigned int);
302 extern int is_orphaned_pgrp(int pgrp);
303 extern int is_ignored(int sig);
304 extern int tty_signal(int sig, struct tty_struct *tty);
305 extern int kill_pg(int pgrp, int sig, int priv);
306
307
308
309 extern void rs_write(struct tty_struct * tty);
310 extern void con_write(struct tty_struct * tty);
311 extern void mpty_write(struct tty_struct * tty);
312 extern void spty_write(struct tty_struct * tty);
313
314
315
316 extern int rs_open(struct tty_struct * tty, struct file * filp);
317 extern void change_speed(unsigned int line);
318
319
320
321 extern int pty_open(struct tty_struct * tty, struct file * filp);
322
323
324
325 extern int con_open(struct tty_struct * tty, struct file * filp);
326 extern void update_screen(int new_console);
327 extern void blank_screen(void);
328 extern void unblank_screen(void);
329
330
331
332 extern int vt_ioctl(struct tty_struct *tty, struct file * file,
333 unsigned int cmd, unsigned int arg);
334
335 #endif