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
9
10
11
12 #include <linux/termios.h>
13
14 #include <asm/system.h>
15
16 #define NR_CONSOLES 8
17 #define NR_SERIALS 4
18 #define NR_PTYS 4
19
20
21
22
23
24 struct screen_info {
25 unsigned char orig_x;
26 unsigned char orig_y;
27 unsigned char unused1[2];
28 unsigned short orig_video_page;
29 unsigned char orig_video_mode;
30 unsigned char orig_video_cols;
31 unsigned short orig_video_ega_ax;
32 unsigned short orig_video_ega_bx;
33 unsigned short orig_video_ega_cx;
34 unsigned char orig_video_lines;
35 };
36
37 extern struct screen_info screen_info;
38
39 #define ORIG_X (screen_info.orig_x)
40 #define ORIG_Y (screen_info.orig_y)
41 #define ORIG_VIDEO_PAGE (screen_info.orig_video_page)
42 #define ORIG_VIDEO_MODE (screen_info.orig_video_mode)
43 #define ORIG_VIDEO_COLS (screen_info.orig_video_cols)
44 #define ORIG_VIDEO_EGA_AX (screen_info.orig_video_ega_ax)
45 #define ORIG_VIDEO_EGA_BX (screen_info.orig_video_ega_bx)
46 #define ORIG_VIDEO_EGA_CX (screen_info.orig_video_ega_cx)
47 #define ORIG_VIDEO_LINES (screen_info.orig_video_lines)
48
49 #define VIDEO_TYPE_MDA 0x10
50 #define VIDEO_TYPE_CGA 0x11
51 #define VIDEO_TYPE_EGAM 0x20
52 #define VIDEO_TYPE_EGAC 0x21
53
54
55
56
57
58
59 #define __DISABLED_CHAR '\0'
60
61 #define TTY_BUF_SIZE 2048
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 unsigned short type;
73 unsigned short line;
74 unsigned short port;
75 unsigned short irq;
76 struct tty_struct * tty;
77 };
78
79
80
81
82 #define PORT_UNKNOWN 0
83 #define PORT_8250 1
84 #define PORT_16450 2
85 #define PORT_16550 3
86 #define PORT_16550A 4
87
88 #define IS_A_CONSOLE(min) (((min) & 0xC0) == 0x00)
89 #define IS_A_SERIAL(min) (((min) & 0xC0) == 0x40)
90 #define IS_A_PTY(min) ((min) & 0x80)
91 #define IS_A_PTY_MASTER(min) (((min) & 0xC0) == 0x80)
92 #define IS_A_PTY_SLAVE(min) (((min) & 0xC0) == 0xC0)
93 #define PTY_OTHER(min) ((min) ^ 0x40)
94
95 #define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
96 #define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
97 #define EMPTY(a) ((a)->head == (a)->tail)
98 #define LEFT(a) (((a)->tail-(a)->head-1)&(TTY_BUF_SIZE-1))
99 #define LAST(a) ((a)->buf[(TTY_BUF_SIZE-1)&((a)->head-1)])
100 #define FULL(a) (!LEFT(a))
101 #define CHARS(a) (((a)->head-(a)->tail)&(TTY_BUF_SIZE-1))
102
103 extern void put_tty_queue(char c, struct tty_queue * queue);
104 extern int get_tty_queue(struct tty_queue * queue);
105
106 #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
107 #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
108 #define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
109 #define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
110 #define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
111 #define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
112 #define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
113 #define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
114
115 #define _L_FLAG(tty,f) ((tty)->termios.c_lflag & f)
116 #define _I_FLAG(tty,f) ((tty)->termios.c_iflag & f)
117 #define _O_FLAG(tty,f) ((tty)->termios.c_oflag & f)
118
119 #define L_CANON(tty) _L_FLAG((tty),ICANON)
120 #define L_ISIG(tty) _L_FLAG((tty),ISIG)
121 #define L_ECHO(tty) _L_FLAG((tty),ECHO)
122 #define L_ECHOE(tty) _L_FLAG((tty),ECHOE)
123 #define L_ECHOK(tty) _L_FLAG((tty),ECHOK)
124 #define L_ECHONL(tty) _L_FLAG((tty),ECHONL)
125 #define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL)
126 #define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE)
127 #define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP)
128
129 #define I_UCLC(tty) _I_FLAG((tty),IUCLC)
130 #define I_NLCR(tty) _I_FLAG((tty),INLCR)
131 #define I_CRNL(tty) _I_FLAG((tty),ICRNL)
132 #define I_NOCR(tty) _I_FLAG((tty),IGNCR)
133 #define I_IXON(tty) _I_FLAG((tty),IXON)
134 #define I_STRP(tty) _I_FLAG((tty),ISTRIP)
135
136 #define O_POST(tty) _O_FLAG((tty),OPOST)
137 #define O_NLCR(tty) _O_FLAG((tty),ONLCR)
138 #define O_CRNL(tty) _O_FLAG((tty),OCRNL)
139 #define O_NLRET(tty) _O_FLAG((tty),ONLRET)
140 #define O_LCUC(tty) _O_FLAG((tty),OLCUC)
141
142 #define C_SPEED(tty) ((tty)->termios.c_cflag & CBAUD)
143 #define C_HUP(tty) (C_SPEED((tty)) == B0)
144
145 struct tty_struct {
146 struct termios termios;
147 int pgrp;
148 int session;
149 int stopped;
150 int flags;
151 int count;
152 struct winsize winsize;
153 void (*write)(struct tty_struct * tty);
154 struct tty_struct *link;
155 struct tty_queue *read_q;
156 struct tty_queue *write_q;
157 struct tty_queue *secondary;
158 };
159
160
161
162
163
164
165
166
167 #define TTY_WRITE_BUSY 0
168 #define TTY_READ_BUSY 1
169 #define TTY_CR_PENDING 2
170
171
172
173
174
175
176 extern inline int set_bit(int nr,int * addr)
177 {
178 char ok;
179
180 __asm__ __volatile__("btsl %1,%2\n\tsetb %0":
181 "=q" (ok):"r" (nr),"m" (*(addr)));
182 return ok;
183 }
184
185 extern inline int clear_bit(int nr, int * addr)
186 {
187 char ok;
188
189 __asm__ __volatile__("btrl %1,%2\n\tsetnb %0":
190 "=q" (ok):"r" (nr),"m" (*(addr)));
191 return ok;
192 }
193
194 #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
195 #define TTY_READ_FLUSH(tty) tty_read_flush((tty))
196
197 extern void tty_write_flush(struct tty_struct *);
198 extern void tty_read_flush(struct tty_struct *);
199
200 extern struct tty_struct tty_table[];
201 extern struct serial_struct serial_table[];
202 extern struct tty_struct * redirect;
203 extern int fg_console;
204 extern unsigned long video_num_columns;
205 extern unsigned long video_num_lines;
206
207
208 #define TTY_TABLE(nr) \
209 (tty_table + ((nr) ? (((nr) < 64)? (nr)-1:(nr)) : fg_console))
210
211
212
213
214
215
216
217 #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
218
219 extern long rs_init(long);
220 extern long lp_init(long);
221 extern long con_init(long);
222 extern long tty_init(long);
223
224 extern void flush_input(struct tty_struct * tty);
225 extern void flush_output(struct tty_struct * tty);
226 extern void wait_until_sent(struct tty_struct * tty);
227 extern void copy_to_cooked(struct tty_struct * tty);
228
229 extern int tty_ioctl(struct inode *, struct file *, unsigned int, unsigned int);
230 extern int is_orphaned_pgrp(int pgrp);
231 extern int is_ignored(int sig);
232 extern int tty_signal(int sig, struct tty_struct *tty);
233 extern int kill_pg(int pgrp, int sig, int priv);
234
235
236
237 extern void rs_write(struct tty_struct * tty);
238 extern void con_write(struct tty_struct * tty);
239 extern void mpty_write(struct tty_struct * tty);
240 extern void spty_write(struct tty_struct * tty);
241
242
243
244 extern int serial_open(unsigned int line, struct file * filp);
245 extern void serial_close(unsigned int line, struct file * filp);
246 extern void change_speed(unsigned int line);
247 extern void send_break(unsigned int line);
248 extern int get_serial_info(unsigned int, struct serial_struct *);
249 extern int set_serial_info(unsigned int, struct serial_struct *);
250
251
252
253 extern int pty_open(unsigned int dev, struct file * filp);
254 extern void pty_close(unsigned int dev, struct file * filp);
255
256
257
258 void update_screen(int new_console);
259 void blank_screen(void);
260 void unblank_screen(void);
261
262 #endif