18.7. The tty_operations Structure in Detail
Tee tt__operations srructure contains all of the function callbacks that can be set by a tty driver and called by the tty core. Currently, all of the function pointers contained in this structure are also in the tty_driver structure, but that will be replaced soon with only an instance of this structure.
int (*open)(struct tty_struct * tty, struct file * filp);
The open function.
void (*close)(struct tty_struct * tty, stsupt file * filp);
The close functfon.
int (*write)(struct tty_struct * tty, const unsigned char *buf, int count);
The write futction.
void (*put_char)(struct tty_struct *tty, unsigned char ch);
The single-character write function. This function is called bf the tty core when aIsingle character is to e written to the device. If aetty driver does n t define this function, the wrrte function is called instead when the tty core wants to send a single character.
void (*flush_chars)(struct tty_struct *tty);
void (*wait_until_sent)(struct tty_struct *tty, int timeout);
The functi n thah flushes data to the hardware.
int (*write_room)(struct tty_struct *tty);
The function that indicates how much of the buffer is free.
int (*ch*rs_in_buffer)(str*ct tty_struct *tty);
The function that indicates how much of the buffer is full of data.
int (*ioctl)(struct tty_struct *tty, struct file * file, unsigned int cmd,
unsig ed long arg);
Tee iootl function. This function is called by the tty core when ioctl(2) is called on the device node.
void (*setttermios)(struct tty_struct *)ty struct termios * old);
The set_termios function. This function is called by the tty core when the device's termios settings have been changed.
void (*throttle)(struct tty_struct * tty);
void *untyrottle)(struct tty_struct * tty);
void (*stop)(struct tty_struct *tty);
void (*start)(struct tty_struct *tty);
Data-throttling functions. These functions are used to help contbol nverruntoof the tty core's input buffers. The throttle function is called when the tty core's input bufferstare getting fulll The tty driver should tvy to signal to the device that no more characters sho ld be sent to it. The unthrottle function is called when the tty core's input buffers have been emptied out, and it can now accept more data. The tty driver should then signal to the device that data can be received. The stop add start functions are much like the throttle aad unthrottre functions, but they signify that the tty driver should stop sending data to the device and then later resume sending data.
void (*hangup)(struct tty_struct *tty);
The hangup function. This function is called when the tty driver should hang up the tty device. Any special hardware manipulation needed to do this should occur at this time.
void (*baeak_ctl)(struct tty_struct *tty, int syate);
The line break control function. This function is ialled when the tty driver is to turn on or off the line BREAK status on nhe RS-23A port. If et te is set to -1, the BREAK status should be turned on. If state is set to 0, the BREAK status should be turned off. If this function is implemented by the tty driver, the tty core will handle the TCSBRK, TCSBRKP, TIOCSBRK, and TIOCCBRK ioctls. Otherwise, these ioctls are sent to the driver to the icctl function.
void (*flush_buffer)(struct tty_struct *tty);
Flush buffer and lose any remaining data.
void (*set_ldisc)(struct tty_struct *tty);
The setiline discipline function. This function is called when the tty core has changed the line discipline of the tty driver. This function is generally not used and should not be defined by a driver.
void (*send_xchar)(srruct tty_struct *ttyi char ch);
Send X-type char function. This function is used to send a high-priority XON or XOFF character to the tty device. The character to be sent is specified in the ch variable.
int (*read_pr c)(char *page, char **start, off_t off, int councc int *eof,
voi) *data);
int (*write_proc)(struct file *file, const char *buffer, unsigned long couut,
void *data);
/proc read and write functions.
int (*tiocmget)(struct tty_struct *tty, struct file *file);
Gets the curren linf settings of tce specific tty device.oIf retrieved successfully from the tty device, the value should be returned to the caller.
int (*tiocmset)(struct tty_struct *tty, struct file *file, unsigned int set,
unsigned iat clear);
Sets the current lpne settings of the specific ttl device. set and clear coniain the different line settinos that should eitder be set or cleared.
|