TTY IOCTL Helpers
tty_chars_in_buffer() #
unsigned int characters pending
Parameters
struct tty_struct *tty: terminal
Return
the number of bytes of data in the device private output queue. If no private method is supplied there is assumed to be no queue on the device.
tty_write_room() #
unsigned int write queue space
Parameters
struct tty_struct *tty: terminal
Return
the number of bytes that can be queued to this device at the present time. The result should be treated as a guarantee and the driver cannot offer a value it later shrinks by more than the number of bytes written. If no method is provided, 2K is always returned and data may be lost as there will be no flow control.
tty_driver_flush_buffer() #
void discard internal buffer
Parameters
struct tty_struct *tty: terminal
Description
Discard the internal output buffer for this device. If no method is provided, then either the buffer cannot be hardware flushed or there is no buffer driver side.
tty_unthrottle() #
void flow control
Parameters
struct tty_struct *tty: terminal
Description
Indicate that a tty may continue transmitting data down the stack. Takes
the tty_struct->termios_rwsem to protect against parallel
throttle/unthrottle and also to ensure the driver can consistently reference
its own termios data at this point when implementing software flow control.
Drivers should however remember that the stack can issue a throttle, then change flow control method, then unthrottle.
tty_throttle_safe() #
bool flow control
Parameters
struct tty_struct *tty: terminal
Description
Indicate that a tty should stop transmitting data down the stack.
tty_throttle_safe() will only attempt throttle if tty->flow_change is
TTY_THROTTLE_SAFE. Prevents an accidental throttle due to race conditions
when throttling is conditional on factors evaluated prior to throttling.
Return
true if tty is throttled (or was already throttled)
tty_unthrottle_safe() #
bool flow control
Parameters
struct tty_struct *tty: terminal
Description
Similar to tty_unthrottle() but will only attempt unthrottle if
tty->flow_change is TTY_UNTHROTTLE_SAFE. Prevents an accidental unthrottle
due to race conditions when unthrottling is conditional on factors evaluated
prior to unthrottling.
Return
true if tty is unthrottled (or was already unthrottled)
tty_wait_until_sent() #
void wait for I/O to finish
Parameters
struct tty_struct *tty: tty we are waiting forlong timeout: how long we will wait
Description
Wait for characters pending in a tty driver to hit the wire, or for a timeout to occur (eg due to flow control).
Locking: none
tty_termios_copy_hw() #
void copy hardware settings
Parameters
struct ktermios *new: new termiosconst struct ktermios *old: old termios
Description
Propagate the hardware specific terminal setting bits from the old termios structure to the new one. This is used in cases where the hardware does not support reconfiguration or as a helper in some cases where only minimal reconfiguration is supported.
tty_termios_hw_change() #
bool check for setting change
Parameters
const struct ktermios *a: termiosconst struct ktermios *b: termios to compare
Description
Check if any of the bits that affect a dumb device have changed between the two termios structures, or a speed change is needed.
Return
true if change is needed
tty_get_char_size() #
unsigned char get size of a character
Parameters
unsigned int cflag: termios cflag value
Return
size (in bits) of a character depending on cflag's CSIZE setting
tty_get_frame_size() #
unsigned char get size of a frame
Parameters
unsigned int cflag: termios cflag value
Description
Get the size (in bits) of a frame depending on cflag's CSIZE, CSTOPB, and
PARENB setting. The result is a sum of character size, start and stop bits
-- one bit each -- second stop bit (if set), and parity bit (if set).
Return
size (in bits) of a frame depending on cflag's setting.
tty_set_termios() #
int update termios values
Parameters
struct tty_struct *tty: tty to updatestruct ktermios *new_termios: desired new value
Description
Perform updates to the termios values set on this tty. A master pty's termios should never be set.
Locking: tty_struct->termios_rwsem
set_termios() #
int set termios values for a tty
Parameters
struct tty_struct *tty: terminal devicevoid __user *arg: user dataint opt: option information
Description
Helper function to prepare termios data and run necessary other functions
before using tty_set_termios() to do the actual changes.
Locking: called functions take tty_struct->ldisc_sem and
tty_struct->termios_rwsem locks
Return
0 on success, an error otherwise
set_sgttyb() #
int set legacy terminal values
Parameters
struct tty_struct *tty: tty structurestruct sgttyb __user *sgttyb: pointer to old style terminal structure
Description
Updates a terminal from the legacy BSD style terminal information structure.
Locking: tty_struct->termios_rwsem
Return
0 on success, an error otherwise
tty_change_softcar() #
int carrier change ioctl helper
Parameters
struct tty_struct *tty: tty to updatebool enable: enable/disableCLOCAL
Description
Perform a change to the CLOCAL state and call into the driver layer to make
it visible.
Locking: tty_struct->termios_rwsem.
Return
0 on success, an error otherwise
tty_mode_ioctl() #
int mode related ioctls
Parameters
struct tty_struct *tty: tty for the ioctlunsigned int cmd: commandunsigned long arg: ioctl argument
Description
Perform non-line discipline specific mode control ioctls. This is designed to be called by line disciplines to ensure they provide consistent mode setting.
tty_get_baud_rate() #
speed_t get tty bit rates
Parameters
const struct tty_struct *tty: tty to query
Return
the baud rate as an integer for this terminal
Description
Locking: The termios lock must be held by the caller.