Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
tty_ioctl.c File Reference
#include <linux/types.h>
#include <linux/termios.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/tty.h>
#include <linux/fcntl.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/compat.h>
#include <asm/io.h>
#include <asm/uaccess.h>

Go to the source code of this file.

Macros

#define TERMIOS_FLUSH   1
 
#define TERMIOS_WAIT   2
 
#define TERMIOS_TERMIO   4
 
#define TERMIOS_OLD   8
 
#define NOSET_MASK(x, y, z)   (x = ((x) & ~(z)) | ((y) & (z)))
 

Functions

int tty_chars_in_buffer (struct tty_struct *tty)
 
 EXPORT_SYMBOL (tty_chars_in_buffer)
 
int tty_write_room (struct tty_struct *tty)
 
 EXPORT_SYMBOL (tty_write_room)
 
void tty_driver_flush_buffer (struct tty_struct *tty)
 
 EXPORT_SYMBOL (tty_driver_flush_buffer)
 
void tty_throttle (struct tty_struct *tty)
 
 EXPORT_SYMBOL (tty_throttle)
 
void tty_unthrottle (struct tty_struct *tty)
 
 EXPORT_SYMBOL (tty_unthrottle)
 
void tty_wait_until_sent (struct tty_struct *tty, long timeout)
 
 EXPORT_SYMBOL (tty_wait_until_sent)
 
speed_t tty_termios_baud_rate (struct ktermios *termios)
 
 EXPORT_SYMBOL (tty_termios_baud_rate)
 
speed_t tty_termios_input_baud_rate (struct ktermios *termios)
 
 EXPORT_SYMBOL (tty_termios_input_baud_rate)
 
void tty_termios_encode_baud_rate (struct ktermios *termios, speed_t ibaud, speed_t obaud)
 
 EXPORT_SYMBOL_GPL (tty_termios_encode_baud_rate)
 
void tty_encode_baud_rate (struct tty_struct *tty, speed_t ibaud, speed_t obaud)
 
 EXPORT_SYMBOL_GPL (tty_encode_baud_rate)
 
speed_t tty_get_baud_rate (struct tty_struct *tty)
 
 EXPORT_SYMBOL (tty_get_baud_rate)
 
void tty_termios_copy_hw (struct ktermios *new, struct ktermios *old)
 
 EXPORT_SYMBOL (tty_termios_copy_hw)
 
int tty_termios_hw_change (struct ktermios *a, struct ktermios *b)
 
 EXPORT_SYMBOL (tty_termios_hw_change)
 
int tty_set_termios (struct tty_struct *tty, struct ktermios *new_termios)
 
 EXPORT_SYMBOL_GPL (tty_set_termios)
 
int tty_mode_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 
 EXPORT_SYMBOL_GPL (tty_mode_ioctl)
 
int tty_perform_flush (struct tty_struct *tty, unsigned long arg)
 
 EXPORT_SYMBOL_GPL (tty_perform_flush)
 
int n_tty_ioctl_helper (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 
 EXPORT_SYMBOL (n_tty_ioctl_helper)
 

Macro Definition Documentation

#define NOSET_MASK (   x,
  y,
 
)    (x = ((x) & ~(z)) | ((y) & (z)))
#define TERMIOS_FLUSH   1

Definition at line 34 of file tty_ioctl.c.

#define TERMIOS_OLD   8

Definition at line 37 of file tty_ioctl.c.

#define TERMIOS_TERMIO   4

Definition at line 36 of file tty_ioctl.c.

#define TERMIOS_WAIT   2

Definition at line 35 of file tty_ioctl.c.

Function Documentation

EXPORT_SYMBOL ( tty_chars_in_buffer  )
EXPORT_SYMBOL ( tty_write_room  )
EXPORT_SYMBOL ( tty_driver_flush_buffer  )
EXPORT_SYMBOL ( tty_throttle  )
EXPORT_SYMBOL ( tty_unthrottle  )
EXPORT_SYMBOL ( tty_wait_until_sent  )
EXPORT_SYMBOL ( tty_termios_baud_rate  )
EXPORT_SYMBOL ( tty_termios_input_baud_rate  )
EXPORT_SYMBOL ( tty_get_baud_rate  )
EXPORT_SYMBOL ( tty_termios_copy_hw  )
EXPORT_SYMBOL ( tty_termios_hw_change  )
EXPORT_SYMBOL ( n_tty_ioctl_helper  )
EXPORT_SYMBOL_GPL ( tty_termios_encode_baud_rate  )
EXPORT_SYMBOL_GPL ( tty_encode_baud_rate  )
EXPORT_SYMBOL_GPL ( tty_set_termios  )
EXPORT_SYMBOL_GPL ( tty_mode_ioctl  )
EXPORT_SYMBOL_GPL ( tty_perform_flush  )
int n_tty_ioctl_helper ( struct tty_struct tty,
struct file file,
unsigned int  cmd,
unsigned long  arg 
)

Definition at line 1118 of file tty_ioctl.c.

int tty_chars_in_buffer ( struct tty_struct tty)

tty_chars_in_buffer - characters pending : 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.

Definition at line 49 of file tty_ioctl.c.

void tty_driver_flush_buffer ( struct tty_struct tty)

tty_driver_flush_buffer - discard internal buffer : terminal

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.

Definition at line 85 of file tty_ioctl.c.

void tty_encode_baud_rate ( struct tty_struct tty,
speed_t  ibaud,
speed_t  obaud 
)

tty_encode_baud_rate - set baud rate of the tty : input baud rate : output baud rate

Update the current termios data for the tty with the new speed settings. The caller must hold the termios_mutex for the tty in question.

Definition at line 411 of file tty_ioctl.c.

speed_t tty_get_baud_rate ( struct tty_struct tty)

tty_get_baud_rate - get tty bit rates : tty to query

Returns the baud rate as an integer for this terminal. The termios lock must be held by the caller and the terminal bit flags may be updated.

Locking: none

Definition at line 428 of file tty_ioctl.c.

int tty_mode_ioctl ( struct tty_struct tty,
struct file file,
unsigned int  cmd,
unsigned long  arg 
)

Definition at line 946 of file tty_ioctl.c.

int tty_perform_flush ( struct tty_struct tty,
unsigned long  arg 
)

Definition at line 1089 of file tty_ioctl.c.

int tty_set_termios ( struct tty_struct tty,
struct ktermios new_termios 
)

tty_set_termios - update termios values : tty to update : desired new value

Perform updates to the termios values set on this terminal. There is a bit of layering violation here with n_tty in terms of the internal knowledge of this function.

Locking: termios_mutex

Definition at line 498 of file tty_ioctl.c.

speed_t tty_termios_baud_rate ( struct ktermios termios)

tty_termios_baud_rate : termios structure

Convert termios baud rate data into a speed. This should be called with the termios lock held if this termios is a terminal termios structure. May change the termios data. Device drivers can call this function but should use ->c_[io]speed directly as they are updated.

Locking: none

Definition at line 241 of file tty_ioctl.c.

void tty_termios_copy_hw ( struct ktermios new,
struct ktermios old 
)

tty_termios_copy_hw - copy hardware settings : New termios : Old termios

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

Definition at line 456 of file tty_ioctl.c.

void tty_termios_encode_baud_rate ( struct ktermios termios,
speed_t  ibaud,
speed_t  obaud 
)

tty_termios_encode_baud_rate : ktermios structure holding user requested state : input speed : output speed

Encode the speeds set into the passed termios structure. This is used as a library helper for drivers so that they can report back the actual speed selected when it differs from the speed requested

For maximal back compatibility with legacy SYS5/POSIX *nix behaviour we need to carefully set the bits when the user does not get the desired speed. We allow small margins and preserve as much of possible of the input intent to keep compatibility.

Locking: Caller should hold termios lock. This is already held when calling this function from the driver termios handler.

The ifdefs deal with platforms whose owners have yet to update them and will all go away once this is done.

Definition at line 325 of file tty_ioctl.c.

int tty_termios_hw_change ( struct ktermios a,
struct ktermios b 
)

tty_termios_hw_change - check for setting change : termios : termios to compare

Check if any of the bits that affect a dumb device have changed between the two termios structures, or a speed change is needed.

Definition at line 476 of file tty_ioctl.c.

speed_t tty_termios_input_baud_rate ( struct ktermios termios)

tty_termios_input_baud_rate : termios structure

Convert termios baud rate data into a speed. This should be called with the termios lock held if this termios is a terminal termios structure. May change the termios data. Device drivers can call this function but should use ->c_[io]speed directly as they are updated.

Locking: none

Definition at line 276 of file tty_ioctl.c.

void tty_throttle ( struct tty_struct tty)

tty_throttle - flow control : terminal

Indicate that a tty should stop transmitting data down the stack. Takes the termios mutex 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.

Definition at line 102 of file tty_ioctl.c.

void tty_unthrottle ( struct tty_struct tty)

tty_unthrottle - flow control : terminal

Indicate that a tty may continue transmitting data down the stack. Takes the termios mutex 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.

Definition at line 126 of file tty_ioctl.c.

void tty_wait_until_sent ( struct tty_struct tty,
long  timeout 
)

tty_wait_until_sent - wait for I/O to finish : tty we are waiting for : how long we will wait

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

Definition at line 147 of file tty_ioctl.c.

int tty_write_room ( struct tty_struct tty)

tty_write_room - write queue space : 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.

Definition at line 69 of file tty_ioctl.c.