00001 #ifndef _LINUX_TTY_H
00002 #define _LINUX_TTY_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #define MIN_NR_CONSOLES 1
00013 #define MAX_NR_CONSOLES 63
00014 #define MAX_NR_USER_CONSOLES 63
00015
00016
00017
00018 #ifdef __KERNEL__
00019 #include <linux/config.h>
00020 #include <linux/fs.h>
00021 #include <linux/major.h>
00022 #include <linux/termios.h>
00023 #include <linux/tqueue.h>
00024 #include <linux/tty_driver.h>
00025 #include <linux/tty_ldisc.h>
00026 #include <linux/serialP.h>
00027
00028 #include <asm/system.h>
00029
00030
00031
00032
00033
00034
00035
00036
00037 #define NR_PTYS 256
00038 #define NR_LDISCS 16
00039
00040
00041
00042
00043
00044
00045 #ifdef CONFIG_UNIX98_PTYS
00046 # define UNIX98_NR_MAJORS ((CONFIG_UNIX98_PTY_COUNT+NR_PTYS-1)/NR_PTYS)
00047 # if UNIX98_NR_MAJORS <= 0
00048 # undef CONFIG_UNIX98_PTYS
00049 # elif UNIX98_NR_MAJORS > UNIX98_PTY_MAJOR_COUNT
00050 # error Too many Unix98 ptys defined
00051 # undef UNIX98_NR_MAJORS
00052 # define UNIX98_NR_MAJORS UNIX98_PTY_MAJOR_COUNT
00053 # endif
00054 #endif
00055
00056
00057
00058
00059
00060 struct screen_info {
00061 unsigned char orig_x;
00062 unsigned char orig_y;
00063 unsigned short dontuse1;
00064 unsigned short orig_video_page;
00065 unsigned char orig_video_mode;
00066 unsigned char orig_video_cols;
00067 unsigned short unused2;
00068 unsigned short orig_video_ega_bx;
00069 unsigned short unused3;
00070 unsigned char orig_video_lines;
00071 unsigned char orig_video_isVGA;
00072 unsigned short orig_video_points;
00073
00074
00075 unsigned short lfb_width;
00076 unsigned short lfb_height;
00077 unsigned short lfb_depth;
00078 unsigned long lfb_base;
00079 unsigned long lfb_size;
00080 unsigned short dontuse2, dontuse3;
00081 unsigned short lfb_linelength;
00082 unsigned char red_size;
00083 unsigned char red_pos;
00084 unsigned char green_size;
00085 unsigned char green_pos;
00086 unsigned char blue_size;
00087 unsigned char blue_pos;
00088 unsigned char rsvd_size;
00089 unsigned char rsvd_pos;
00090 unsigned short vesapm_seg;
00091 unsigned short vesapm_off;
00092 unsigned short pages;
00093
00094 };
00095
00096 extern struct screen_info screen_info;
00097
00098 #define ORIG_X (screen_info.orig_x)
00099 #define ORIG_Y (screen_info.orig_y)
00100 #define ORIG_VIDEO_MODE (screen_info.orig_video_mode)
00101 #define ORIG_VIDEO_COLS (screen_info.orig_video_cols)
00102 #define ORIG_VIDEO_EGA_BX (screen_info.orig_video_ega_bx)
00103 #define ORIG_VIDEO_LINES (screen_info.orig_video_lines)
00104 #define ORIG_VIDEO_ISVGA (screen_info.orig_video_isVGA)
00105 #define ORIG_VIDEO_POINTS (screen_info.orig_video_points)
00106
00107 #define VIDEO_TYPE_MDA 0x10
00108 #define VIDEO_TYPE_CGA 0x11
00109 #define VIDEO_TYPE_EGAM 0x20
00110 #define VIDEO_TYPE_EGAC 0x21
00111 #define VIDEO_TYPE_VGAC 0x22
00112 #define VIDEO_TYPE_VLFB 0x23
00113
00114 #define VIDEO_TYPE_TGAC 0x40
00115
00116 #define VIDEO_TYPE_SUN 0x50
00117 #define VIDEO_TYPE_SUNPCI 0x51
00118
00119 #define VIDEO_TYPE_PMAC 0x60
00120
00121 #define VIDEO_TYPE_SGI 0x70
00122 #define VIDEO_TYPE_MIPS_G364 0x71
00123
00124
00125
00126
00127
00128
00129 #define __DISABLED_CHAR '\0'
00130
00131
00132
00133
00134
00135
00136 #define TTY_FLIPBUF_SIZE 512
00137
00138 struct tty_flip_buffer {
00139 struct tq_struct tqueue;
00140 struct semaphore pty_sem;
00141 char *char_buf_ptr;
00142 unsigned char *flag_buf_ptr;
00143 int count;
00144 int buf_num;
00145 unsigned char char_buf[2*TTY_FLIPBUF_SIZE];
00146 char flag_buf[2*TTY_FLIPBUF_SIZE];
00147 unsigned char slop[4];
00148 };
00149
00150
00151
00152 #define PTY_BUF_SIZE 4*TTY_FLIPBUF_SIZE
00153
00154
00155
00156
00157
00158 #define TTY_NORMAL 0
00159 #define TTY_BREAK 1
00160 #define TTY_FRAME 2
00161 #define TTY_PARITY 3
00162 #define TTY_OVERRUN 4
00163
00164 #define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR])
00165 #define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT])
00166 #define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE])
00167 #define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL])
00168 #define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF])
00169 #define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME])
00170 #define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN])
00171 #define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC])
00172 #define START_CHAR(tty) ((tty)->termios->c_cc[VSTART])
00173 #define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP])
00174 #define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP])
00175 #define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL])
00176 #define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT])
00177 #define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD])
00178 #define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE])
00179 #define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT])
00180 #define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2])
00181
00182 #define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f))
00183 #define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f))
00184 #define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f))
00185 #define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f))
00186
00187 #define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK)
00188 #define I_BRKINT(tty) _I_FLAG((tty),BRKINT)
00189 #define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR)
00190 #define I_PARMRK(tty) _I_FLAG((tty),PARMRK)
00191 #define I_INPCK(tty) _I_FLAG((tty),INPCK)
00192 #define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP)
00193 #define I_INLCR(tty) _I_FLAG((tty),INLCR)
00194 #define I_IGNCR(tty) _I_FLAG((tty),IGNCR)
00195 #define I_ICRNL(tty) _I_FLAG((tty),ICRNL)
00196 #define I_IUCLC(tty) _I_FLAG((tty),IUCLC)
00197 #define I_IXON(tty) _I_FLAG((tty),IXON)
00198 #define I_IXANY(tty) _I_FLAG((tty),IXANY)
00199 #define I_IXOFF(tty) _I_FLAG((tty),IXOFF)
00200 #define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL)
00201
00202 #define O_OPOST(tty) _O_FLAG((tty),OPOST)
00203 #define O_OLCUC(tty) _O_FLAG((tty),OLCUC)
00204 #define O_ONLCR(tty) _O_FLAG((tty),ONLCR)
00205 #define O_OCRNL(tty) _O_FLAG((tty),OCRNL)
00206 #define O_ONOCR(tty) _O_FLAG((tty),ONOCR)
00207 #define O_ONLRET(tty) _O_FLAG((tty),ONLRET)
00208 #define O_OFILL(tty) _O_FLAG((tty),OFILL)
00209 #define O_OFDEL(tty) _O_FLAG((tty),OFDEL)
00210 #define O_NLDLY(tty) _O_FLAG((tty),NLDLY)
00211 #define O_CRDLY(tty) _O_FLAG((tty),CRDLY)
00212 #define O_TABDLY(tty) _O_FLAG((tty),TABDLY)
00213 #define O_BSDLY(tty) _O_FLAG((tty),BSDLY)
00214 #define O_VTDLY(tty) _O_FLAG((tty),VTDLY)
00215 #define O_FFDLY(tty) _O_FLAG((tty),FFDLY)
00216
00217 #define C_BAUD(tty) _C_FLAG((tty),CBAUD)
00218 #define C_CSIZE(tty) _C_FLAG((tty),CSIZE)
00219 #define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB)
00220 #define C_CREAD(tty) _C_FLAG((tty),CREAD)
00221 #define C_PARENB(tty) _C_FLAG((tty),PARENB)
00222 #define C_PARODD(tty) _C_FLAG((tty),PARODD)
00223 #define C_HUPCL(tty) _C_FLAG((tty),HUPCL)
00224 #define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL)
00225 #define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD)
00226 #define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS)
00227
00228 #define L_ISIG(tty) _L_FLAG((tty),ISIG)
00229 #define L_ICANON(tty) _L_FLAG((tty),ICANON)
00230 #define L_XCASE(tty) _L_FLAG((tty),XCASE)
00231 #define L_ECHO(tty) _L_FLAG((tty),ECHO)
00232 #define L_ECHOE(tty) _L_FLAG((tty),ECHOE)
00233 #define L_ECHOK(tty) _L_FLAG((tty),ECHOK)
00234 #define L_ECHONL(tty) _L_FLAG((tty),ECHONL)
00235 #define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH)
00236 #define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP)
00237 #define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL)
00238 #define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT)
00239 #define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE)
00240 #define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO)
00241 #define L_PENDIN(tty) _L_FLAG((tty),PENDIN)
00242 #define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN)
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 struct tty_struct {
00259 int magic;
00260 struct tty_driver driver;
00261 struct tty_ldisc ldisc;
00262 struct termios *termios, *termios_locked;
00263 int pgrp;
00264 int session;
00265 kdev_t device;
00266 unsigned long flags;
00267 int count;
00268 struct winsize winsize;
00269 unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
00270 unsigned char low_latency:1, warned:1;
00271 unsigned char ctrl_status;
00272
00273 struct tty_struct *link;
00274 struct fasync_struct *fasync;
00275 struct tty_flip_buffer flip;
00276 int max_flip_cnt;
00277 int alt_speed;
00278 struct wait_queue *write_wait;
00279 struct wait_queue *read_wait;
00280 struct wait_queue *poll_wait;
00281 struct tq_struct tq_hangup;
00282 void *disc_data;
00283 void *driver_data;
00284
00285 #define N_TTY_BUF_SIZE 4096
00286
00287
00288
00289
00290
00291 unsigned int column;
00292 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
00293 unsigned char closing:1;
00294 unsigned short minimum_to_wake;
00295 unsigned overrun_time;
00296 int num_overrun;
00297 unsigned long process_char_map[256/(8*sizeof(unsigned long))];
00298 char *read_buf;
00299 int read_head;
00300 int read_tail;
00301 int read_cnt;
00302 unsigned long read_flags[N_TTY_BUF_SIZE/(8*sizeof(unsigned long))];
00303 int canon_data;
00304 unsigned long canon_head;
00305 unsigned int canon_column;
00306 struct semaphore atomic_read;
00307 struct semaphore atomic_write;
00308 spinlock_t read_lock;
00309 };
00310
00311
00312 #define TTY_MAGIC 0x5401
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322 #define TTY_THROTTLED 0
00323 #define TTY_IO_ERROR 1
00324 #define TTY_OTHER_CLOSED 2
00325 #define TTY_EXCLUSIVE 3
00326 #define TTY_DEBUG 4
00327 #define TTY_DO_WRITE_WAKEUP 5
00328 #define TTY_PUSH 6
00329 #define TTY_CLOSING 7
00330 #define TTY_DONT_FLIP 8
00331 #define TTY_HW_COOK_OUT 14
00332 #define TTY_HW_COOK_IN 15
00333 #define TTY_PTY_LOCK 16
00334 #define TTY_NO_WRITE_SPLIT 17
00335
00336 #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
00337
00338 extern void tty_write_flush(struct tty_struct *);
00339
00340 extern struct termios tty_std_termios;
00341 extern struct tty_struct * redirect;
00342 extern struct tty_ldisc ldiscs[];
00343 extern int fg_console, last_console, want_console;
00344
00345 extern int kmsg_redirect;
00346
00347 extern unsigned long con_init(unsigned long);
00348
00349 extern int rs_init(void);
00350 extern int lp_init(void);
00351 extern int pty_init(void);
00352 extern int tty_init(void);
00353 extern int mxser_init(void);
00354 extern int moxa_init(void);
00355 extern int ip2_init(void);
00356 extern int pcxe_init(void);
00357 extern int pc_init(void);
00358 extern int vcs_init(void);
00359 extern int rp_init(void);
00360 extern int cy_init(void);
00361 extern int stl_init(void);
00362 extern int stli_init(void);
00363 extern int riscom8_init(void);
00364 extern int specialix_init(void);
00365 extern int espserial_init(void);
00366 extern int macserial_init(void);
00367 extern int mgsl_init(void);
00368 extern int n_hdlc_init(void);
00369
00370 extern int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
00371 const char *routine);
00372 extern char *tty_name(struct tty_struct *tty, char *buf);
00373 extern void tty_wait_until_sent(struct tty_struct * tty, long timeout);
00374 extern int tty_check_change(struct tty_struct * tty);
00375 extern void stop_tty(struct tty_struct * tty);
00376 extern void start_tty(struct tty_struct * tty);
00377 extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
00378 extern int tty_register_driver(struct tty_driver *driver);
00379 extern int tty_unregister_driver(struct tty_driver *driver);
00380 extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
00381 int buflen);
00382 extern void tty_write_message(struct tty_struct *tty, char *msg);
00383
00384 extern int is_orphaned_pgrp(int pgrp);
00385 extern int is_ignored(int sig);
00386 extern int tty_signal(int sig, struct tty_struct *tty);
00387 extern void tty_hangup(struct tty_struct * tty);
00388 extern void tty_vhangup(struct tty_struct * tty);
00389 extern void tty_unhangup(struct file *filp);
00390 extern int tty_hung_up_p(struct file * filp);
00391 extern void do_SAK(struct tty_struct *tty);
00392 extern void disassociate_ctty(int priv);
00393 extern void tty_flip_buffer_push(struct tty_struct *tty);
00394 extern int tty_get_baud_rate(struct tty_struct *tty);
00395
00396
00397 extern struct tty_ldisc tty_ldisc_N_TTY;
00398
00399
00400 extern int n_tty_ioctl(struct tty_struct * tty, struct file * file,
00401 unsigned int cmd, unsigned long arg);
00402
00403
00404
00405 extern long serial_console_init(long kmem_start, long kmem_end);
00406
00407
00408
00409 extern int pcxe_open(struct tty_struct *tty, struct file *filp);
00410
00411
00412
00413 extern void console_print(const char *);
00414
00415
00416
00417 extern int vt_ioctl(struct tty_struct *tty, struct file * file,
00418 unsigned int cmd, unsigned long arg);
00419
00420 #endif
00421 #endif