root/include/linux/tty.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * 'tty.h' defines some structures used by tty_io.c and some defines.
   3  *
   4  * NOTE! Don't touch this without checking that nothing in rs_io.s or
   5  * con_io.s breaks. Some constants are hardwired into the system (mainly
   6  * offsets into 'tty_queue'
   7  */
   8 
   9 #ifndef _TTY_H
  10 #define _TTY_H
  11 
  12 #define MAX_CONSOLES    8
  13 #define NR_SERIALS      4
  14 #define NR_PTYS         4
  15 
  16 extern int NR_CONSOLES;
  17 
  18 #include <termios.h>
  19 
  20 #define TTY_BUF_SIZE 2048
  21 
  22 struct tty_queue {
  23         unsigned long data;
  24         unsigned long head;
  25         unsigned long tail;
  26         struct task_struct * proc_list;
  27         char buf[TTY_BUF_SIZE];
  28 };
  29 
  30 #define IS_A_CONSOLE(min)       (((min) & 0xC0) == 0x00)
  31 #define IS_A_SERIAL(min)        (((min) & 0xC0) == 0x40)
  32 #define IS_A_PTY(min)           ((min) & 0x80)
  33 #define IS_A_PTY_MASTER(min)    (((min) & 0xC0) == 0x80)
  34 #define IS_A_PTY_SLAVE(min)     (((min) & 0xC0) == 0xC0)
  35 #define PTY_OTHER(min)          ((min) ^ 0x40)
  36 
  37 #define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
  38 #define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
  39 #define EMPTY(a) ((a)->head == (a)->tail)
  40 #define LEFT(a) (((a)->tail-(a)->head-1)&(TTY_BUF_SIZE-1))
  41 #define LAST(a) ((a)->buf[(TTY_BUF_SIZE-1)&((a)->head-1)])
  42 #define FULL(a) (!LEFT(a))
  43 #define CHARS(a) (((a)->head-(a)->tail)&(TTY_BUF_SIZE-1))
  44 #define GETCH(queue,c) \
  45 (void)({c=(queue)->buf[(queue)->tail];INC((queue)->tail);})
  46 #define PUTCH(c,queue) \
  47 (void)({(queue)->buf[(queue)->head]=(c);INC((queue)->head);})
  48 
  49 #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
  50 #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
  51 #define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
  52 #define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
  53 #define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
  54 #define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
  55 #define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
  56 #define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
  57 
  58 struct tty_struct {
  59         struct termios termios;
  60         int pgrp;
  61         int session;
  62         int stopped;
  63         int busy;
  64         struct winsize winsize;
  65         void (*write)(struct tty_struct * tty);
  66         struct tty_queue *read_q;
  67         struct tty_queue *write_q;
  68         struct tty_queue *secondary;
  69         };
  70 
  71 /*
  72  * so that interrupts won't be able to mess up the
  73  * queues, copy_to_cooked must be atomic with repect
  74  * to itself, as must tty->write.
  75  */
  76 #define TTY_WRITE_BUSY 1
  77 #define TTY_READ_BUSY 2
  78 
  79 #define TTY_WRITE_FLUSH(tty) \
  80 do { \
  81         cli(); \
  82         if (!EMPTY((tty)->write_q) && !(TTY_WRITE_BUSY & (tty)->busy)) { \
  83                 (tty)->busy |= TTY_WRITE_BUSY; \
  84                 sti(); \
  85                 (tty)->write((tty)); \
  86                 cli(); \
  87                 (tty)->busy &= ~TTY_WRITE_BUSY; \
  88         } \
  89         sti(); \
  90 } while (0)
  91 
  92 #define TTY_READ_FLUSH(tty) \
  93 do { \
  94         cli(); \
  95         if (!EMPTY((tty)->read_q) && !(TTY_READ_BUSY & (tty)->busy)) { \
  96                 (tty)->busy |= TTY_READ_BUSY; \
  97                 sti(); \
  98                 copy_to_cooked((tty)); \
  99                 cli(); \
 100                 (tty)->busy &= ~TTY_READ_BUSY; \
 101         } \
 102         sti(); \
 103 } while (0)
 104 
 105 extern struct tty_struct tty_table[];
 106 extern int fg_console;
 107 extern unsigned long video_num_columns;
 108 extern unsigned long video_num_lines;
 109 
 110 
 111 #define TTY_TABLE(nr) \
 112 (tty_table + ((nr) ? (((nr) < 64)? (nr)-1:(nr)) : fg_console))
 113 
 114 /*      intr=^C         quit=^|         erase=del       kill=^U
 115         eof=^D          vtime=\0        vmin=\1         sxtc=\0
 116         start=^Q        stop=^S         susp=^Z         eol=\0
 117         reprint=^R      discard=^U      werase=^W       lnext=^V
 118         eol2=\0
 119 */
 120 #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
 121 
 122 extern void rs_init(void);
 123 extern void lp_init(void);
 124 extern void con_init(void);
 125 extern void tty_init(void);
 126 
 127 extern int tty_ioctl(struct inode *, struct file *, unsigned int, unsigned int);
 128 
 129 extern void rs_write(struct tty_struct * tty);
 130 extern void con_write(struct tty_struct * tty);
 131 extern void mpty_write(struct tty_struct * tty);
 132 extern void spty_write(struct tty_struct * tty);
 133 
 134 extern void serial_open(unsigned int line);
 135 
 136 void copy_to_cooked(struct tty_struct * tty);
 137 
 138 void update_screen(int new_console);
 139 
 140 #endif

/* [previous][next][first][last][top][bottom][index][help] */