root/include/linux/tty_driver.h

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

INCLUDED FROM


   1 #ifndef _LINUX_TTY_DRIVER_H
   2 #define _LINUX_TTY_DRIVER_H
   3 
   4 /*
   5  * This structure defines the interface between the low-level tty
   6  * driver and the tty routines.  The following routines can be
   7  * defined; unless noted otherwise, they are optional, and can be
   8  * filled in with a null pointer.
   9  *
  10  * int  (*open)(struct tty_struct * tty, struct file * filp);
  11  *
  12  *      This routine is called when a particular tty device is opened.
  13  *      This routine is mandatory; if this routine is not filled in,
  14  *      the attempted open will fail with ENODEV.
  15  *     
  16  * void (*close)(struct tty_struct * tty, struct file * filp);
  17  *
  18  *      This routine is called when a particular tty device is closed.
  19  *
  20  * int (*write)(struct tty_struct * tty, int from_user,
  21  *               unsigned char *buf, int count);
  22  *
  23  *      This routine is called by the kernel to write a series of
  24  *      characters to the tty device.  The characters may come from
  25  *      user space or kernel space.  This routine will return the
  26  *      number of characters actually accepted for writing.  This
  27  *      routine is mandatory.
  28  *
  29  * void (*put_char)(struct tty_struct *tty, unsigned char ch);
  30  *
  31  *      This routine is called by the kernel to write a single
  32  *      character to the tty device.  If the kernel uses this routine,
  33  *      it must call the flush_chars() routine (if defined) when it is
  34  *      done stuffing characters into the driver.  If there is no room
  35  *      in the queue, the character is ignored.
  36  *
  37  * void (*flush_chars)(struct tty_struct *tty);
  38  *
  39  *      This routine is called by the kernel after it has written a
  40  *      series of characters to the tty device using put_char().  
  41  * 
  42  * int  (*write_room)(struct tty_struct *tty);
  43  *
  44  *      This routine returns the numbers of characters the tty driver
  45  *      will accept for queueing to be writen.  This number is subject
  46  *      to change as output buffers get emptied, or if the output flow
  47  *      control is acted.
  48  * 
  49  * int  (*ioctl)(struct tty_struct *tty, struct file * file,
  50  *          unsigned int cmd, unsigned long arg);
  51  *
  52  *      This routine allows the tty driver to implement
  53  *      device-specific iotctl's.  If the ioctl number passed in cmd
  54  *      is not recognized by the driver, it should return ENOIOCTLCMD.
  55  * 
  56  * void (*set_termios)(struct tty_struct *tty, struct termios * old);
  57  *
  58  *      This routine allows the tty driver to be notified when
  59  *      device's termios settings have changed.  
  60  * 
  61  * void (*throttle)(struct tty_struct * tty);
  62  *
  63  *      This routine notifies the tty driver that input buffers for
  64  *      the line discpline are close to full, and it should somehow
  65  *      signal that no more characters should be sent to the tty.
  66  * 
  67  * void (*unthrottle)(struct tty_struct * tty);
  68  *
  69  *      This routine notifies the tty drivers that it should signals
  70  *      that characters can now be sent to the tty without fear of
  71  *      overrunning the input buffers of the line discplines.
  72  * 
  73  * void (*stop)(struct tty_struct *tty);
  74  *
  75  *      This routine notfies the tty driver that it should stop
  76  *      outputting characters to the tty device.  
  77  * 
  78  * void (*start)(struct tty_struct *tty);
  79  *
  80  *      This routine notifies the tty driver that it resume sending
  81  *      characters to the tty device.
  82  * 
  83  * void (*hangup)(struct tty_struct *tty);
  84  *
  85  *      This routine notifies the tty driver that it should hangup the
  86  *      tty device.
  87  * 
  88  */
  89 
  90 #include <linux/fs.h>
  91 
  92 struct tty_driver {
  93         int     magic;          /* magic number for this structure */
  94         char    *name;
  95         int     name_base;      /* offset of printed name */
  96         short   major;          /* major device number */
  97         short   minor_start;    /* start of minor device number*/
  98         short   num;            /* number of devices */
  99         short   type;           /* type of tty driver */
 100         short   subtype;        /* subtype of tty driver */
 101         struct termios init_termios; /* Initial termios */
 102         int     flags;          /* tty driver flags */
 103         int     *refcount;      /* for loadable tty drivers */
 104         struct tty_driver *other; /* only used for the PTY driver */
 105 
 106         /*
 107          * Pointer to the tty data structures
 108          */
 109         struct tty_struct **table;
 110         struct termios **termios;
 111         struct termios **termios_locked;
 112         
 113         /*
 114          * Interface routines from the upper tty layer to the tty
 115          * driver.
 116          */
 117         int  (*open)(struct tty_struct * tty, struct file * filp);
 118         void (*close)(struct tty_struct * tty, struct file * filp);
 119         int  (*write)(struct tty_struct * tty, int from_user,
 120                       unsigned char *buf, int count);
 121         void (*put_char)(struct tty_struct *tty, unsigned char ch);
 122         void (*flush_chars)(struct tty_struct *tty);
 123         int  (*write_room)(struct tty_struct *tty);
 124         int  (*chars_in_buffer)(struct tty_struct *tty);
 125         int  (*ioctl)(struct tty_struct *tty, struct file * file,
 126                     unsigned int cmd, unsigned long arg);
 127         void (*set_termios)(struct tty_struct *tty, struct termios * old);
 128         void (*throttle)(struct tty_struct * tty);
 129         void (*unthrottle)(struct tty_struct * tty);
 130         void (*stop)(struct tty_struct *tty);
 131         void (*start)(struct tty_struct *tty);
 132         void (*hangup)(struct tty_struct *tty);
 133         void (*flush_buffer)(struct tty_struct *tty);
 134 
 135         /*
 136          * linked list pointers
 137          */
 138         struct tty_driver *next;
 139         struct tty_driver *prev;
 140 };
 141 
 142 /* tty driver magic number */
 143 #define TTY_DRIVER_MAGIC                0x5402
 144 
 145 /*
 146  * tty driver flags
 147  * 
 148  * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
 149  *      termios setting when the last process has closed the device.
 150  *      Used for PTY's, in particular.
 151  * 
 152  * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will
 153  *      guarantee never not to set any special character handling
 154  *      flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR ||
 155  *      !INPCK)).  That is, if there is no reason for the driver to
 156  *      send notifications of parity and break characters up to the
 157  *      line driver, it won't do so.  This allows the line driver to
 158  *      optimize for this case if this flag is set.  (Note that there
 159  *      is also a promise, if the above case is true, not to signal
 160  *      overruns, either.)
 161  */
 162 #define TTY_DRIVER_INSTALLED            0x0001
 163 #define TTY_DRIVER_RESET_TERMIOS        0x0002
 164 #define TTY_DRIVER_REAL_RAW             0x0004
 165 
 166 /* tty driver types */
 167 #define TTY_DRIVER_TYPE_SYSTEM          0x0001
 168 #define TTY_DRIVER_TYPE_CONSOLE         0x0002
 169 #define TTY_DRIVER_TYPE_SERIAL          0x0003
 170 #define TTY_DRIVER_TYPE_PTY             0x0004
 171 
 172 /* system subtypes (magic, used by tty_io.c) */
 173 #define SYSTEM_TYPE_TTY                 0x0001
 174 #define SYSTEM_TYPE_CONSOLE             0x0002
 175 
 176 /* pty subtypes (magic, used by tty_io.c) */
 177 #define PTY_TYPE_MASTER                 0x0001
 178 #define PTY_TYPE_SLAVE                  0x0002
 179 
 180 #endif /* #ifdef _LINUX_TTY_DRIVER_H */

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