diff options
Diffstat (limited to 'include/linux/tty_driver.h')
| -rw-r--r-- | include/linux/tty_driver.h | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 21f69aca4505..59f1c0bd8f9c 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h | |||
| @@ -12,11 +12,15 @@ | |||
| 12 | * This routine is called when a particular tty device is opened. | 12 | * This routine is called when a particular tty device is opened. |
| 13 | * This routine is mandatory; if this routine is not filled in, | 13 | * This routine is mandatory; if this routine is not filled in, |
| 14 | * the attempted open will fail with ENODEV. | 14 | * the attempted open will fail with ENODEV. |
| 15 | * | ||
| 16 | * Required method. | ||
| 15 | * | 17 | * |
| 16 | * void (*close)(struct tty_struct * tty, struct file * filp); | 18 | * void (*close)(struct tty_struct * tty, struct file * filp); |
| 17 | * | 19 | * |
| 18 | * This routine is called when a particular tty device is closed. | 20 | * This routine is called when a particular tty device is closed. |
| 19 | * | 21 | * |
| 22 | * Required method. | ||
| 23 | * | ||
| 20 | * int (*write)(struct tty_struct * tty, | 24 | * int (*write)(struct tty_struct * tty, |
| 21 | * const unsigned char *buf, int count); | 25 | * const unsigned char *buf, int count); |
| 22 | * | 26 | * |
| @@ -26,7 +30,9 @@ | |||
| 26 | * number of characters actually accepted for writing. This | 30 | * number of characters actually accepted for writing. This |
| 27 | * routine is mandatory. | 31 | * routine is mandatory. |
| 28 | * | 32 | * |
| 29 | * void (*put_char)(struct tty_struct *tty, unsigned char ch); | 33 | * Optional: Required for writable devices. |
| 34 | * | ||
| 35 | * int (*put_char)(struct tty_struct *tty, unsigned char ch); | ||
| 30 | * | 36 | * |
| 31 | * This routine is called by the kernel to write a single | 37 | * This routine is called by the kernel to write a single |
| 32 | * character to the tty device. If the kernel uses this routine, | 38 | * character to the tty device. If the kernel uses this routine, |
| @@ -34,10 +40,18 @@ | |||
| 34 | * done stuffing characters into the driver. If there is no room | 40 | * done stuffing characters into the driver. If there is no room |
| 35 | * in the queue, the character is ignored. | 41 | * in the queue, the character is ignored. |
| 36 | * | 42 | * |
| 43 | * Optional: Kernel will use the write method if not provided. | ||
| 44 | * | ||
| 45 | * Note: Do not call this function directly, call tty_put_char | ||
| 46 | * | ||
| 37 | * void (*flush_chars)(struct tty_struct *tty); | 47 | * void (*flush_chars)(struct tty_struct *tty); |
| 38 | * | 48 | * |
| 39 | * This routine is called by the kernel after it has written a | 49 | * This routine is called by the kernel after it has written a |
| 40 | * series of characters to the tty device using put_char(). | 50 | * series of characters to the tty device using put_char(). |
| 51 | * | ||
| 52 | * Optional: | ||
| 53 | * | ||
| 54 | * Note: Do not call this function directly, call tty_driver_flush_chars | ||
| 41 | * | 55 | * |
| 42 | * int (*write_room)(struct tty_struct *tty); | 56 | * int (*write_room)(struct tty_struct *tty); |
| 43 | * | 57 | * |
| @@ -45,6 +59,10 @@ | |||
| 45 | * will accept for queuing to be written. This number is subject | 59 | * will accept for queuing to be written. This number is subject |
| 46 | * to change as output buffers get emptied, or if the output flow | 60 | * to change as output buffers get emptied, or if the output flow |
| 47 | * control is acted. | 61 | * control is acted. |
| 62 | * | ||
| 63 | * Required if write method is provided else not needed. | ||
| 64 | * | ||
| 65 | * Note: Do not call this function directly, call tty_write_room | ||
| 48 | * | 66 | * |
| 49 | * int (*ioctl)(struct tty_struct *tty, struct file * file, | 67 | * int (*ioctl)(struct tty_struct *tty, struct file * file, |
| 50 | * unsigned int cmd, unsigned long arg); | 68 | * unsigned int cmd, unsigned long arg); |
| @@ -53,28 +71,37 @@ | |||
| 53 | * device-specific ioctl's. If the ioctl number passed in cmd | 71 | * device-specific ioctl's. If the ioctl number passed in cmd |
| 54 | * is not recognized by the driver, it should return ENOIOCTLCMD. | 72 | * is not recognized by the driver, it should return ENOIOCTLCMD. |
| 55 | * | 73 | * |
| 74 | * Optional | ||
| 75 | * | ||
| 56 | * long (*compat_ioctl)(struct tty_struct *tty, struct file * file, | 76 | * long (*compat_ioctl)(struct tty_struct *tty, struct file * file, |
| 57 | * unsigned int cmd, unsigned long arg); | 77 | * unsigned int cmd, unsigned long arg); |
| 58 | * | 78 | * |
| 59 | * implement ioctl processing for 32 bit process on 64 bit system | 79 | * implement ioctl processing for 32 bit process on 64 bit system |
| 80 | * | ||
| 81 | * Optional | ||
| 60 | * | 82 | * |
| 61 | * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); | 83 | * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); |
| 62 | * | 84 | * |
| 63 | * This routine allows the tty driver to be notified when | 85 | * This routine allows the tty driver to be notified when |
| 64 | * device's termios settings have changed. Note that a | 86 | * device's termios settings have changed. |
| 65 | * well-designed tty driver should be prepared to accept the case | 87 | * |
| 66 | * where old == NULL, and try to do something rational. | 88 | * Optional: Called under the termios lock |
| 89 | * | ||
| 67 | * | 90 | * |
| 68 | * void (*set_ldisc)(struct tty_struct *tty); | 91 | * void (*set_ldisc)(struct tty_struct *tty); |
| 69 | * | 92 | * |
| 70 | * This routine allows the tty driver to be notified when the | 93 | * This routine allows the tty driver to be notified when the |
| 71 | * device's termios settings have changed. | 94 | * device's termios settings have changed. |
| 95 | * | ||
| 96 | * Optional: Called under BKL (currently) | ||
| 72 | * | 97 | * |
| 73 | * void (*throttle)(struct tty_struct * tty); | 98 | * void (*throttle)(struct tty_struct * tty); |
| 74 | * | 99 | * |
| 75 | * This routine notifies the tty driver that input buffers for | 100 | * This routine notifies the tty driver that input buffers for |
| 76 | * the line discipline are close to full, and it should somehow | 101 | * the line discipline are close to full, and it should somehow |
| 77 | * signal that no more characters should be sent to the tty. | 102 | * signal that no more characters should be sent to the tty. |
| 103 | * | ||
| 104 | * Optional: Always invoke via tty_throttle(); | ||
| 78 | * | 105 | * |
| 79 | * void (*unthrottle)(struct tty_struct * tty); | 106 | * void (*unthrottle)(struct tty_struct * tty); |
| 80 | * | 107 | * |
| @@ -82,21 +109,33 @@ | |||
| 82 | * that characters can now be sent to the tty without fear of | 109 | * that characters can now be sent to the tty without fear of |
| 83 | * overrunning the input buffers of the line disciplines. | 110 | * overrunning the input buffers of the line disciplines. |
| 84 | * | 111 | * |
| 112 | * Optional: Always invoke via tty_unthrottle(); | ||
| 113 | * | ||
| 85 | * void (*stop)(struct tty_struct *tty); | 114 | * void (*stop)(struct tty_struct *tty); |
| 86 | * | 115 | * |
| 87 | * This routine notifies the tty driver that it should stop | 116 | * This routine notifies the tty driver that it should stop |
| 88 | * outputting characters to the tty device. | 117 | * outputting characters to the tty device. |
| 118 | * | ||
| 119 | * Optional: | ||
| 120 | * | ||
| 121 | * Note: Call stop_tty not this method. | ||
| 89 | * | 122 | * |
| 90 | * void (*start)(struct tty_struct *tty); | 123 | * void (*start)(struct tty_struct *tty); |
| 91 | * | 124 | * |
| 92 | * This routine notifies the tty driver that it resume sending | 125 | * This routine notifies the tty driver that it resume sending |
| 93 | * characters to the tty device. | 126 | * characters to the tty device. |
| 127 | * | ||
| 128 | * Optional: | ||
| 129 | * | ||
| 130 | * Note: Call start_tty not this method. | ||
| 94 | * | 131 | * |
| 95 | * void (*hangup)(struct tty_struct *tty); | 132 | * void (*hangup)(struct tty_struct *tty); |
| 96 | * | 133 | * |
| 97 | * This routine notifies the tty driver that it should hangup the | 134 | * This routine notifies the tty driver that it should hangup the |
| 98 | * tty device. | 135 | * tty device. |
| 99 | * | 136 | * |
| 137 | * Required: | ||
| 138 | * | ||
| 100 | * void (*break_ctl)(struct tty_stuct *tty, int state); | 139 | * void (*break_ctl)(struct tty_stuct *tty, int state); |
| 101 | * | 140 | * |
| 102 | * This optional routine requests the tty driver to turn on or | 141 | * This optional routine requests the tty driver to turn on or |
| @@ -106,18 +145,26 @@ | |||
| 106 | * | 145 | * |
| 107 | * If this routine is implemented, the high-level tty driver will | 146 | * If this routine is implemented, the high-level tty driver will |
| 108 | * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, | 147 | * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, |
| 109 | * TIOCCBRK. Otherwise, these ioctls will be passed down to the | 148 | * TIOCCBRK. |
| 110 | * driver to handle. | 149 | * |
| 150 | * Optional: Required for TCSBRK/BRKP/etc handling. | ||
| 111 | * | 151 | * |
| 112 | * void (*wait_until_sent)(struct tty_struct *tty, int timeout); | 152 | * void (*wait_until_sent)(struct tty_struct *tty, int timeout); |
| 113 | * | 153 | * |
| 114 | * This routine waits until the device has written out all of the | 154 | * This routine waits until the device has written out all of the |
| 115 | * characters in its transmitter FIFO. | 155 | * characters in its transmitter FIFO. |
| 116 | * | 156 | * |
| 157 | * Optional: If not provided the device is assumed to have no FIFO | ||
| 158 | * | ||
| 159 | * Note: Usually correct to call tty_wait_until_sent | ||
| 160 | * | ||
| 117 | * void (*send_xchar)(struct tty_struct *tty, char ch); | 161 | * void (*send_xchar)(struct tty_struct *tty, char ch); |
| 118 | * | 162 | * |
| 119 | * This routine is used to send a high-priority XON/XOFF | 163 | * This routine is used to send a high-priority XON/XOFF |
| 120 | * character to the device. | 164 | * character to the device. |
| 165 | * | ||
| 166 | * Optional: If not provided then the write method is called under | ||
| 167 | * the atomic write lock to keep it serialized with the ldisc. | ||
| 121 | */ | 168 | */ |
| 122 | 169 | ||
| 123 | #include <linux/fs.h> | 170 | #include <linux/fs.h> |
| @@ -132,7 +179,7 @@ struct tty_operations { | |||
| 132 | void (*close)(struct tty_struct * tty, struct file * filp); | 179 | void (*close)(struct tty_struct * tty, struct file * filp); |
| 133 | int (*write)(struct tty_struct * tty, | 180 | int (*write)(struct tty_struct * tty, |
| 134 | const unsigned char *buf, int count); | 181 | const unsigned char *buf, int count); |
| 135 | void (*put_char)(struct tty_struct *tty, unsigned char ch); | 182 | int (*put_char)(struct tty_struct *tty, unsigned char ch); |
| 136 | void (*flush_chars)(struct tty_struct *tty); | 183 | void (*flush_chars)(struct tty_struct *tty); |
| 137 | int (*write_room)(struct tty_struct *tty); | 184 | int (*write_room)(struct tty_struct *tty); |
| 138 | int (*chars_in_buffer)(struct tty_struct *tty); | 185 | int (*chars_in_buffer)(struct tty_struct *tty); |
| @@ -153,8 +200,6 @@ struct tty_operations { | |||
| 153 | void (*send_xchar)(struct tty_struct *tty, char ch); | 200 | void (*send_xchar)(struct tty_struct *tty, char ch); |
| 154 | int (*read_proc)(char *page, char **start, off_t off, | 201 | int (*read_proc)(char *page, char **start, off_t off, |
| 155 | int count, int *eof, void *data); | 202 | int count, int *eof, void *data); |
| 156 | int (*write_proc)(struct file *file, const char __user *buffer, | ||
| 157 | unsigned long count, void *data); | ||
| 158 | int (*tiocmget)(struct tty_struct *tty, struct file *file); | 203 | int (*tiocmget)(struct tty_struct *tty, struct file *file); |
| 159 | int (*tiocmset)(struct tty_struct *tty, struct file *file, | 204 | int (*tiocmset)(struct tty_struct *tty, struct file *file, |
| 160 | unsigned int set, unsigned int clear); | 205 | unsigned int set, unsigned int clear); |
| @@ -190,48 +235,13 @@ struct tty_driver { | |||
| 190 | struct tty_struct **ttys; | 235 | struct tty_struct **ttys; |
| 191 | struct ktermios **termios; | 236 | struct ktermios **termios; |
| 192 | struct ktermios **termios_locked; | 237 | struct ktermios **termios_locked; |
| 193 | void *driver_state; /* only used for the PTY driver */ | 238 | void *driver_state; |
| 194 | 239 | ||
| 195 | /* | 240 | /* |
| 196 | * Interface routines from the upper tty layer to the tty | 241 | * Driver methods |
| 197 | * driver. Will be replaced with struct tty_operations. | ||
| 198 | */ | 242 | */ |
| 199 | int (*open)(struct tty_struct * tty, struct file * filp); | ||
| 200 | void (*close)(struct tty_struct * tty, struct file * filp); | ||
| 201 | int (*write)(struct tty_struct * tty, | ||
| 202 | const unsigned char *buf, int count); | ||
| 203 | void (*put_char)(struct tty_struct *tty, unsigned char ch); | ||
| 204 | void (*flush_chars)(struct tty_struct *tty); | ||
| 205 | int (*write_room)(struct tty_struct *tty); | ||
| 206 | int (*chars_in_buffer)(struct tty_struct *tty); | ||
| 207 | int (*ioctl)(struct tty_struct *tty, struct file * file, | ||
| 208 | unsigned int cmd, unsigned long arg); | ||
| 209 | long (*compat_ioctl)(struct tty_struct *tty, struct file * file, | ||
| 210 | unsigned int cmd, unsigned long arg); | ||
| 211 | void (*set_termios)(struct tty_struct *tty, struct ktermios * old); | ||
| 212 | void (*throttle)(struct tty_struct * tty); | ||
| 213 | void (*unthrottle)(struct tty_struct * tty); | ||
| 214 | void (*stop)(struct tty_struct *tty); | ||
| 215 | void (*start)(struct tty_struct *tty); | ||
| 216 | void (*hangup)(struct tty_struct *tty); | ||
| 217 | void (*break_ctl)(struct tty_struct *tty, int state); | ||
| 218 | void (*flush_buffer)(struct tty_struct *tty); | ||
| 219 | void (*set_ldisc)(struct tty_struct *tty); | ||
| 220 | void (*wait_until_sent)(struct tty_struct *tty, int timeout); | ||
| 221 | void (*send_xchar)(struct tty_struct *tty, char ch); | ||
| 222 | int (*read_proc)(char *page, char **start, off_t off, | ||
| 223 | int count, int *eof, void *data); | ||
| 224 | int (*write_proc)(struct file *file, const char __user *buffer, | ||
| 225 | unsigned long count, void *data); | ||
| 226 | int (*tiocmget)(struct tty_struct *tty, struct file *file); | ||
| 227 | int (*tiocmset)(struct tty_struct *tty, struct file *file, | ||
| 228 | unsigned int set, unsigned int clear); | ||
| 229 | #ifdef CONFIG_CONSOLE_POLL | ||
| 230 | int (*poll_init)(struct tty_driver *driver, int line, char *options); | ||
| 231 | int (*poll_get_char)(struct tty_driver *driver, int line); | ||
| 232 | void (*poll_put_char)(struct tty_driver *driver, int line, char ch); | ||
| 233 | #endif | ||
| 234 | 243 | ||
| 244 | const struct tty_operations *ops; | ||
| 235 | struct list_head tty_drivers; | 245 | struct list_head tty_drivers; |
| 236 | }; | 246 | }; |
| 237 | 247 | ||
