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 struct tty_driver {
  91         int     magic;          /* magic number for this structure */
  92         char    *name;
  93         int     name_base;      /* offset of printed name */
  94         short   major;          /* major device number */
  95         short   minor_start;    /* start of minor device number*/
  96         short   num;            /* number of devices */
  97         short   type;           /* type of tty driver */
  98         short   subtype;        /* subtype of tty driver */
  99         struct termios init_termios; /* Initial termios */
 100         int     flags;          /* tty driver flags */
 101         int     *refcount;      /* for loadable tty drivers */
 102         struct tty_driver *other; /* only used for the PTY driver */
 103 
 104         /*
 105          * Pointer to the tty data structures
 106          */
 107         struct tty_struct **table;
 108         struct termios **termios;
 109         struct termios **termios_locked;
 110         
 111         /*
 112          * Interface routines from the upper tty layer to the tty
 113          * driver.
 114          */
 115         int  (*open)(struct tty_struct * tty, struct file * filp);
 116         void (*close)(struct tty_struct * tty, struct file * filp);
 117         int  (*write)(struct tty_struct * tty, int from_user,
 118                       unsigned char *buf, int count);
 119         void (*put_char)(struct tty_struct *tty, unsigned char ch);
 120         void (*flush_chars)(struct tty_struct *tty);
 121         int  (*write_room)(struct tty_struct *tty);
 122         int  (*chars_in_buffer)(struct tty_struct *tty);
 123         int  (*ioctl)(struct tty_struct *tty, struct file * file,
 124                     unsigned int cmd, unsigned long arg);
 125         void (*set_termios)(struct tty_struct *tty, struct termios * old);
 126         void (*throttle)(struct tty_struct * tty);
 127         void (*unthrottle)(struct tty_struct * tty);
 128         void (*stop)(struct tty_struct *tty);
 129         void (*start)(struct tty_struct *tty);
 130         void (*hangup)(struct tty_struct *tty);
 131         void (*flush_buffer)(struct tty_struct *tty);
 132 
 133         /*
 134          * linked list pointers
 135          */
 136         struct tty_driver *next;
 137         struct tty_driver *prev;
 138 };
 139 
 140 /* tty driver magic number */
 141 #define TTY_DRIVER_MAGIC                0x5402
 142 
 143 /*
 144  * tty driver flags
 145  * 
 146  * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
 147  *      termios setting when the last process has closed the device.
 148  *      Used for PTY's, in particular.
 149  * 
 150  * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will
 151  *      guarantee never not to set any special character handling
 152  *      flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR ||
 153  *      !INPCK)).  That is, if there is no reason for the driver to
 154  *      send notifications of parity and break characters up to the
 155  *      line driver, it won't do so.  This allows the line driver to
 156  *      optimize for this case if this flag is set.  (Note that there
 157  *      is also a promise, if the above case is true, not to signal
 158  *      overruns, either.)
 159  */
 160 #define TTY_DRIVER_INSTALLED            0x0001
 161 #define TTY_DRIVER_RESET_TERMIOS        0x0002
 162 #define TTY_DRIVER_REAL_RAW             0x0004
 163 
 164 /* tty driver types */
 165 #define TTY_DRIVER_TYPE_SYSTEM          0x0001
 166 #define TTY_DRIVER_TYPE_CONSOLE         0x0002
 167 #define TTY_DRIVER_TYPE_SERIAL          0x0003
 168 #define TTY_DRIVER_TYPE_PTY             0x0004
 169 
 170 /* system subtypes (magic, used by tty_io.c) */
 171 #define SYSTEM_TYPE_TTY                 0x0001
 172 #define SYSTEM_TYPE_CONSOLE             0x0002
 173 
 174 /* pty subtypes (magic, used by tty_io.c) */
 175 #define PTY_TYPE_MASTER                 0x0001
 176 #define PTY_TYPE_SLAVE                  0x0002
 177 
 178 #endif /* #ifdef _LINUX_TTY_DRIVER_H */

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