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 queuing to be written.  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 ioctl'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.  Note that a
  60  *      well-designed tty driver should be prepared to accept the case
  61  *      where old == NULL, and try to do something rational.
  62  *
  63  * void (*set_ldisc)(struct tty_struct *tty);
  64  *
  65  *      This routine allows the tty driver to be notified when the
  66  *      device's termios settings have changed.
  67  * 
  68  * void (*throttle)(struct tty_struct * tty);
  69  *
  70  *      This routine notifies the tty driver that input buffers for
  71  *      the line discipline are close to full, and it should somehow
  72  *      signal that no more characters should be sent to the tty.
  73  * 
  74  * void (*unthrottle)(struct tty_struct * tty);
  75  *
  76  *      This routine notifies the tty drivers that it should signals
  77  *      that characters can now be sent to the tty without fear of
  78  *      overrunning the input buffers of the line disciplines.
  79  * 
  80  * void (*stop)(struct tty_struct *tty);
  81  *
  82  *      This routine notifies the tty driver that it should stop
  83  *      outputting characters to the tty device.  
  84  * 
  85  * void (*start)(struct tty_struct *tty);
  86  *
  87  *      This routine notifies the tty driver that it resume sending
  88  *      characters to the tty device.
  89  * 
  90  * void (*hangup)(struct tty_struct *tty);
  91  *
  92  *      This routine notifies the tty driver that it should hangup the
  93  *      tty device.
  94  * 
  95  */
  96 
  97 #include <linux/fs.h>
  98 
  99 struct tty_driver {
 100         int     magic;          /* magic number for this structure */
 101         char    *name;
 102         int     name_base;      /* offset of printed name */
 103         short   major;          /* major device number */
 104         short   minor_start;    /* start of minor device number*/
 105         short   num;            /* number of devices */
 106         short   type;           /* type of tty driver */
 107         short   subtype;        /* subtype of tty driver */
 108         struct termios init_termios; /* Initial termios */
 109         int     flags;          /* tty driver flags */
 110         int     *refcount;      /* for loadable tty drivers */
 111         struct tty_driver *other; /* only used for the PTY driver */
 112 
 113         /*
 114          * Pointer to the tty data structures
 115          */
 116         struct tty_struct **table;
 117         struct termios **termios;
 118         struct termios **termios_locked;
 119         
 120         /*
 121          * Interface routines from the upper tty layer to the tty
 122          * driver.
 123          */
 124         int  (*open)(struct tty_struct * tty, struct file * filp);
 125         void (*close)(struct tty_struct * tty, struct file * filp);
 126         int  (*write)(struct tty_struct * tty, int from_user,
 127                       unsigned char *buf, int count);
 128         void (*put_char)(struct tty_struct *tty, unsigned char ch);
 129         void (*flush_chars)(struct tty_struct *tty);
 130         int  (*write_room)(struct tty_struct *tty);
 131         int  (*chars_in_buffer)(struct tty_struct *tty);
 132         int  (*ioctl)(struct tty_struct *tty, struct file * file,
 133                     unsigned int cmd, unsigned long arg);
 134         void (*set_termios)(struct tty_struct *tty, struct termios * old);
 135         void (*throttle)(struct tty_struct * tty);
 136         void (*unthrottle)(struct tty_struct * tty);
 137         void (*stop)(struct tty_struct *tty);
 138         void (*start)(struct tty_struct *tty);
 139         void (*hangup)(struct tty_struct *tty);
 140         void (*flush_buffer)(struct tty_struct *tty);
 141         void (*set_ldisc)(struct tty_struct *tty);
 142 
 143         /*
 144          * linked list pointers
 145          */
 146         struct tty_driver *next;
 147         struct tty_driver *prev;
 148 };
 149 
 150 /* tty driver magic number */
 151 #define TTY_DRIVER_MAGIC                0x5402
 152 
 153 /*
 154  * tty driver flags
 155  * 
 156  * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
 157  *      termios setting when the last process has closed the device.
 158  *      Used for PTY's, in particular.
 159  * 
 160  * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will
 161  *      guarantee never not to set any special character handling
 162  *      flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR ||
 163  *      !INPCK)).  That is, if there is no reason for the driver to
 164  *      send notifications of parity and break characters up to the
 165  *      line driver, it won't do so.  This allows the line driver to
 166  *      optimize for this case if this flag is set.  (Note that there
 167  *      is also a promise, if the above case is true, not to signal
 168  *      overruns, either.)
 169  */
 170 #define TTY_DRIVER_INSTALLED            0x0001
 171 #define TTY_DRIVER_RESET_TERMIOS        0x0002
 172 #define TTY_DRIVER_REAL_RAW             0x0004
 173 
 174 /* tty driver types */
 175 #define TTY_DRIVER_TYPE_SYSTEM          0x0001
 176 #define TTY_DRIVER_TYPE_CONSOLE         0x0002
 177 #define TTY_DRIVER_TYPE_SERIAL          0x0003
 178 #define TTY_DRIVER_TYPE_PTY             0x0004
 179 
 180 /* system subtypes (magic, used by tty_io.c) */
 181 #define SYSTEM_TYPE_TTY                 0x0001
 182 #define SYSTEM_TYPE_CONSOLE             0x0002
 183 
 184 /* pty subtypes (magic, used by tty_io.c) */
 185 #define PTY_TYPE_MASTER                 0x0001
 186 #define PTY_TYPE_SLAVE                  0x0002
 187 
 188 #endif /* #ifdef _LINUX_TTY_DRIVER_H */

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