Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
tty.h File Reference
#include <linux/fs.h>
#include <linux/major.h>
#include <linux/termios.h>
#include <linux/workqueue.h>
#include <linux/tty_driver.h>
#include <linux/tty_ldisc.h>
#include <linux/mutex.h>
#include <linux/tty_flags.h>
#include <uapi/linux/tty.h>

Go to the source code of this file.

Data Structures

struct  tty_buffer
 
struct  tty_bufhead
 
struct  tty_port_operations
 
struct  tty_port
 
struct  tty_struct
 
struct  tty_file_private
 

Macros

#define NR_UNIX98_PTY_DEFAULT   4096 /* Default maximum for Unix98 ptys */
 
#define NR_UNIX98_PTY_RESERVE   1024 /* Default reserve for main devpts */
 
#define NR_UNIX98_PTY_MAX   (1 << MINORBITS) /* Absolute limit */
 
#define __DISABLED_CHAR   '\0'
 
#define TTY_BUFFER_PAGE   (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)
 
#define TTY_NORMAL   0
 
#define TTY_BREAK   1
 
#define TTY_FRAME   2
 
#define TTY_PARITY   3
 
#define TTY_OVERRUN   4
 
#define INTR_CHAR(tty)   ((tty)->termios.c_cc[VINTR])
 
#define QUIT_CHAR(tty)   ((tty)->termios.c_cc[VQUIT])
 
#define ERASE_CHAR(tty)   ((tty)->termios.c_cc[VERASE])
 
#define KILL_CHAR(tty)   ((tty)->termios.c_cc[VKILL])
 
#define EOF_CHAR(tty)   ((tty)->termios.c_cc[VEOF])
 
#define TIME_CHAR(tty)   ((tty)->termios.c_cc[VTIME])
 
#define MIN_CHAR(tty)   ((tty)->termios.c_cc[VMIN])
 
#define SWTC_CHAR(tty)   ((tty)->termios.c_cc[VSWTC])
 
#define START_CHAR(tty)   ((tty)->termios.c_cc[VSTART])
 
#define STOP_CHAR(tty)   ((tty)->termios.c_cc[VSTOP])
 
#define SUSP_CHAR(tty)   ((tty)->termios.c_cc[VSUSP])
 
#define EOL_CHAR(tty)   ((tty)->termios.c_cc[VEOL])
 
#define REPRINT_CHAR(tty)   ((tty)->termios.c_cc[VREPRINT])
 
#define DISCARD_CHAR(tty)   ((tty)->termios.c_cc[VDISCARD])
 
#define WERASE_CHAR(tty)   ((tty)->termios.c_cc[VWERASE])
 
#define LNEXT_CHAR(tty)   ((tty)->termios.c_cc[VLNEXT])
 
#define EOL2_CHAR(tty)   ((tty)->termios.c_cc[VEOL2])
 
#define _I_FLAG(tty, f)   ((tty)->termios.c_iflag & (f))
 
#define _O_FLAG(tty, f)   ((tty)->termios.c_oflag & (f))
 
#define _C_FLAG(tty, f)   ((tty)->termios.c_cflag & (f))
 
#define _L_FLAG(tty, f)   ((tty)->termios.c_lflag & (f))
 
#define I_IGNBRK(tty)   _I_FLAG((tty), IGNBRK)
 
#define I_BRKINT(tty)   _I_FLAG((tty), BRKINT)
 
#define I_IGNPAR(tty)   _I_FLAG((tty), IGNPAR)
 
#define I_PARMRK(tty)   _I_FLAG((tty), PARMRK)
 
#define I_INPCK(tty)   _I_FLAG((tty), INPCK)
 
#define I_ISTRIP(tty)   _I_FLAG((tty), ISTRIP)
 
#define I_INLCR(tty)   _I_FLAG((tty), INLCR)
 
#define I_IGNCR(tty)   _I_FLAG((tty), IGNCR)
 
#define I_ICRNL(tty)   _I_FLAG((tty), ICRNL)
 
#define I_IUCLC(tty)   _I_FLAG((tty), IUCLC)
 
#define I_IXON(tty)   _I_FLAG((tty), IXON)
 
#define I_IXANY(tty)   _I_FLAG((tty), IXANY)
 
#define I_IXOFF(tty)   _I_FLAG((tty), IXOFF)
 
#define I_IMAXBEL(tty)   _I_FLAG((tty), IMAXBEL)
 
#define I_IUTF8(tty)   _I_FLAG((tty), IUTF8)
 
#define O_OPOST(tty)   _O_FLAG((tty), OPOST)
 
#define O_OLCUC(tty)   _O_FLAG((tty), OLCUC)
 
#define O_ONLCR(tty)   _O_FLAG((tty), ONLCR)
 
#define O_OCRNL(tty)   _O_FLAG((tty), OCRNL)
 
#define O_ONOCR(tty)   _O_FLAG((tty), ONOCR)
 
#define O_ONLRET(tty)   _O_FLAG((tty), ONLRET)
 
#define O_OFILL(tty)   _O_FLAG((tty), OFILL)
 
#define O_OFDEL(tty)   _O_FLAG((tty), OFDEL)
 
#define O_NLDLY(tty)   _O_FLAG((tty), NLDLY)
 
#define O_CRDLY(tty)   _O_FLAG((tty), CRDLY)
 
#define O_TABDLY(tty)   _O_FLAG((tty), TABDLY)
 
#define O_BSDLY(tty)   _O_FLAG((tty), BSDLY)
 
#define O_VTDLY(tty)   _O_FLAG((tty), VTDLY)
 
#define O_FFDLY(tty)   _O_FLAG((tty), FFDLY)
 
#define C_BAUD(tty)   _C_FLAG((tty), CBAUD)
 
#define C_CSIZE(tty)   _C_FLAG((tty), CSIZE)
 
#define C_CSTOPB(tty)   _C_FLAG((tty), CSTOPB)
 
#define C_CREAD(tty)   _C_FLAG((tty), CREAD)
 
#define C_PARENB(tty)   _C_FLAG((tty), PARENB)
 
#define C_PARODD(tty)   _C_FLAG((tty), PARODD)
 
#define C_HUPCL(tty)   _C_FLAG((tty), HUPCL)
 
#define C_CLOCAL(tty)   _C_FLAG((tty), CLOCAL)
 
#define C_CIBAUD(tty)   _C_FLAG((tty), CIBAUD)
 
#define C_CRTSCTS(tty)   _C_FLAG((tty), CRTSCTS)
 
#define L_ISIG(tty)   _L_FLAG((tty), ISIG)
 
#define L_ICANON(tty)   _L_FLAG((tty), ICANON)
 
#define L_XCASE(tty)   _L_FLAG((tty), XCASE)
 
#define L_ECHO(tty)   _L_FLAG((tty), ECHO)
 
#define L_ECHOE(tty)   _L_FLAG((tty), ECHOE)
 
#define L_ECHOK(tty)   _L_FLAG((tty), ECHOK)
 
#define L_ECHONL(tty)   _L_FLAG((tty), ECHONL)
 
#define L_NOFLSH(tty)   _L_FLAG((tty), NOFLSH)
 
#define L_TOSTOP(tty)   _L_FLAG((tty), TOSTOP)
 
#define L_ECHOCTL(tty)   _L_FLAG((tty), ECHOCTL)
 
#define L_ECHOPRT(tty)   _L_FLAG((tty), ECHOPRT)
 
#define L_ECHOKE(tty)   _L_FLAG((tty), ECHOKE)
 
#define L_FLUSHO(tty)   _L_FLAG((tty), FLUSHO)
 
#define L_PENDIN(tty)   _L_FLAG((tty), PENDIN)
 
#define L_IEXTEN(tty)   _L_FLAG((tty), IEXTEN)
 
#define L_EXTPROC(tty)   _L_FLAG((tty), EXTPROC)
 
#define N_TTY_BUF_SIZE   4096
 
#define TTY_MAGIC   0x5401
 
#define TTY_THROTTLED   0 /* Call unthrottle() at threshold min */
 
#define TTY_IO_ERROR   1 /* Cause an I/O error (may be no ldisc too) */
 
#define TTY_OTHER_CLOSED   2 /* Other side (if any) has closed */
 
#define TTY_EXCLUSIVE   3 /* Exclusive open mode */
 
#define TTY_DEBUG   4 /* Debugging */
 
#define TTY_DO_WRITE_WAKEUP   5 /* Call write_wakeup after queuing new */
 
#define TTY_PUSH   6 /* n_tty private */
 
#define TTY_CLOSING   7 /* ->close() in progress */
 
#define TTY_LDISC   9 /* Line discipline attached */
 
#define TTY_LDISC_CHANGING   10 /* Line discipline changing */
 
#define TTY_LDISC_OPEN   11 /* Line discipline is open */
 
#define TTY_HW_COOK_OUT   14 /* Hardware can do output cooking */
 
#define TTY_HW_COOK_IN   15 /* Hardware can do input cooking */
 
#define TTY_PTY_LOCK   16 /* pty private */
 
#define TTY_NO_WRITE_SPLIT   17 /* Preserve write boundaries to driver */
 
#define TTY_HUPPED   18 /* Post driver->hangup() */
 
#define TTY_FLUSHING   19 /* Flushing to ldisc in progress */
 
#define TTY_FLUSHPENDING   20 /* Queued buffer flush pending */
 
#define TTY_HUPPING   21 /* ->hangup() in progress */
 
#define TTY_WRITE_FLUSH(tty)   tty_write_flush((tty))
 
#define tty_is_writelocked(tty)   (mutex_is_locked(&tty->atomic_write_lock))
 
#define wait_event_interruptible_tty(tty, wq, condition)
 
#define __wait_event_interruptible_tty(tty, wq, condition, ret)
 

Functions

void tty_write_flush (struct tty_struct *)
 
void console_init (void)
 
int vcs_init (void)
 
void tty_kref_put (struct tty_struct *tty)
 
int tty_paranoia_check (struct tty_struct *tty, struct inode *inode, const char *routine)
 
chartty_name (struct tty_struct *tty, char *buf)
 
void tty_wait_until_sent (struct tty_struct *tty, long timeout)
 
int tty_check_change (struct tty_struct *tty)
 
void stop_tty (struct tty_struct *tty)
 
void start_tty (struct tty_struct *tty)
 
int tty_register_driver (struct tty_driver *driver)
 
int tty_unregister_driver (struct tty_driver *driver)
 
struct devicetty_register_device (struct tty_driver *driver, unsigned index, struct device *dev)
 
struct devicetty_register_device_attr (struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, const struct attribute_group **attr_grp)
 
void tty_unregister_device (struct tty_driver *driver, unsigned index)
 
int tty_read_raw_data (struct tty_struct *tty, unsigned char *bufp, int buflen)
 
void tty_write_message (struct tty_struct *tty, char *msg)
 
int tty_put_char (struct tty_struct *tty, unsigned char c)
 
int tty_chars_in_buffer (struct tty_struct *tty)
 
int tty_write_room (struct tty_struct *tty)
 
void tty_driver_flush_buffer (struct tty_struct *tty)
 
void tty_throttle (struct tty_struct *tty)
 
void tty_unthrottle (struct tty_struct *tty)
 
int tty_do_resize (struct tty_struct *tty, struct winsize *ws)
 
void tty_driver_remove_tty (struct tty_driver *driver, struct tty_struct *tty)
 
void tty_free_termios (struct tty_struct *tty)
 
int is_current_pgrp_orphaned (void)
 
struct pidtty_get_pgrp (struct tty_struct *tty)
 
int is_ignored (int sig)
 
int tty_signal (int sig, struct tty_struct *tty)
 
void tty_hangup (struct tty_struct *tty)
 
void tty_vhangup (struct tty_struct *tty)
 
void tty_vhangup_locked (struct tty_struct *tty)
 
void tty_vhangup_self (void)
 
void tty_unhangup (struct file *filp)
 
int tty_hung_up_p (struct file *filp)
 
void do_SAK (struct tty_struct *tty)
 
void __do_SAK (struct tty_struct *tty)
 
void disassociate_ctty (int priv)
 
void no_tty (void)
 
void tty_flip_buffer_push (struct tty_struct *tty)
 
void tty_flush_to_ldisc (struct tty_struct *tty)
 
void tty_buffer_free_all (struct tty_struct *tty)
 
void tty_buffer_flush (struct tty_struct *tty)
 
void tty_buffer_init (struct tty_struct *tty)
 
speed_t tty_get_baud_rate (struct tty_struct *tty)
 
speed_t tty_termios_baud_rate (struct ktermios *termios)
 
speed_t tty_termios_input_baud_rate (struct ktermios *termios)
 
void tty_termios_encode_baud_rate (struct ktermios *termios, speed_t ibaud, speed_t obaud)
 
void tty_encode_baud_rate (struct tty_struct *tty, speed_t ibaud, speed_t obaud)
 
void tty_termios_copy_hw (struct ktermios *new, struct ktermios *old)
 
int tty_termios_hw_change (struct ktermios *a, struct ktermios *b)
 
int tty_set_termios (struct tty_struct *tty, struct ktermios *kt)
 
struct tty_ldisctty_ldisc_ref (struct tty_struct *)
 
void tty_ldisc_deref (struct tty_ldisc *)
 
struct tty_ldisctty_ldisc_ref_wait (struct tty_struct *)
 
void tty_ldisc_hangup (struct tty_struct *tty)
 
void tty_wakeup (struct tty_struct *tty)
 
void tty_ldisc_flush (struct tty_struct *tty)
 
long tty_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
 
int tty_mode_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 
int tty_perform_flush (struct tty_struct *tty, unsigned long arg)
 
dev_t tty_devnum (struct tty_struct *tty)
 
void proc_clear_tty (struct task_struct *p)
 
struct tty_structget_current_tty (void)
 
void tty_default_fops (struct file_operations *fops)
 
struct tty_structalloc_tty_struct (void)
 
int tty_alloc_file (struct file *file)
 
void tty_add_file (struct tty_struct *tty, struct file *file)
 
void tty_free_file (struct file *file)
 
void free_tty_struct (struct tty_struct *tty)
 
void initialize_tty_struct (struct tty_struct *tty, struct tty_driver *driver, int idx)
 
void deinitialize_tty_struct (struct tty_struct *tty)
 
struct tty_structtty_init_dev (struct tty_driver *driver, int idx)
 
int tty_release (struct inode *inode, struct file *filp)
 
int tty_init_termios (struct tty_struct *tty)
 
int tty_standard_install (struct tty_driver *driver, struct tty_struct *tty)
 
struct tty_structtty_pair_get_tty (struct tty_struct *tty)
 
struct tty_structtty_pair_get_pty (struct tty_struct *tty)
 
void tty_write_unlock (struct tty_struct *tty)
 
int tty_write_lock (struct tty_struct *tty, int ndelay)
 
void tty_port_init (struct tty_port *port)
 
void tty_port_link_device (struct tty_port *port, struct tty_driver *driver, unsigned index)
 
struct devicetty_port_register_device (struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device)
 
struct devicetty_port_register_device_attr (struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device, void *drvdata, const struct attribute_group **attr_grp)
 
int tty_port_alloc_xmit_buf (struct tty_port *port)
 
void tty_port_free_xmit_buf (struct tty_port *port)
 
void tty_port_put (struct tty_port *port)
 
struct tty_structtty_port_tty_get (struct tty_port *port)
 
void tty_port_tty_set (struct tty_port *port, struct tty_struct *tty)
 
int tty_port_carrier_raised (struct tty_port *port)
 
void tty_port_raise_dtr_rts (struct tty_port *port)
 
void tty_port_lower_dtr_rts (struct tty_port *port)
 
void tty_port_hangup (struct tty_port *port)
 
int tty_port_block_til_ready (struct tty_port *port, struct tty_struct *tty, struct file *filp)
 
int tty_port_close_start (struct tty_port *port, struct tty_struct *tty, struct file *filp)
 
void tty_port_close_end (struct tty_port *port, struct tty_struct *tty)
 
void tty_port_close (struct tty_port *port, struct tty_struct *tty, struct file *filp)
 
int tty_port_install (struct tty_port *port, struct tty_driver *driver, struct tty_struct *tty)
 
int tty_port_open (struct tty_port *port, struct tty_struct *tty, struct file *filp)
 
int tty_register_ldisc (int disc, struct tty_ldisc_ops *new_ldisc)
 
int tty_unregister_ldisc (int disc)
 
int tty_set_ldisc (struct tty_struct *tty, int ldisc)
 
int tty_ldisc_setup (struct tty_struct *tty, struct tty_struct *o_tty)
 
void tty_ldisc_release (struct tty_struct *tty, struct tty_struct *o_tty)
 
void tty_ldisc_init (struct tty_struct *tty)
 
void tty_ldisc_deinit (struct tty_struct *tty)
 
void tty_ldisc_begin (void)
 
void tty_ldisc_enable (struct tty_struct *tty)
 
void n_tty_inherit_ops (struct tty_ldisc_ops *ops)
 
int __init tty_init (void)
 
int n_tty_ioctl_helper (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 
long n_tty_compat_ioctl_helper (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 
void serial_console_init (void)
 
int pcxe_open (struct tty_struct *tty, struct file *filp)
 
int vt_ioctl (struct tty_struct *tty, unsigned int cmd, unsigned long arg)
 
long vt_compat_ioctl (struct tty_struct *tty, unsigned int cmd, unsigned long arg)
 
void __lockfunc tty_lock (struct tty_struct *tty)
 
void __lockfunc tty_unlock (struct tty_struct *tty)
 
void __lockfunc tty_lock_pair (struct tty_struct *tty, struct tty_struct *tty2)
 
void __lockfunc tty_unlock_pair (struct tty_struct *tty, struct tty_struct *tty2)
 

Variables

struct ktermios tty_std_termios
 
struct classtty_class
 
struct file_operations tty_ldiscs_proc_fops
 
struct mutex tty_mutex
 
spinlock_t tty_files_lock
 
struct tty_ldisc_ops tty_ldisc_N_TTY
 

Macro Definition Documentation

#define __DISABLED_CHAR   '\0'

Definition at line 29 of file tty.h.

#define __wait_event_interruptible_tty (   tty,
  wq,
  condition,
  ret 
)
Value:
do { \
DEFINE_WAIT(__wait); \
for (;;) { \
prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
if (condition) \
break; \
if (!signal_pending(current)) { \
tty_unlock(tty); \
schedule(); \
tty_lock(tty); \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
finish_wait(&wq, &__wait); \
} while (0)

Definition at line 642 of file tty.h.

#define _C_FLAG (   tty,
  f 
)    ((tty)->termios.c_cflag & (f))

Definition at line 93 of file tty.h.

#define _I_FLAG (   tty,
  f 
)    ((tty)->termios.c_iflag & (f))

Definition at line 91 of file tty.h.

#define _L_FLAG (   tty,
  f 
)    ((tty)->termios.c_lflag & (f))

Definition at line 94 of file tty.h.

#define _O_FLAG (   tty,
  f 
)    ((tty)->termios.c_oflag & (f))

Definition at line 92 of file tty.h.

#define C_BAUD (   tty)    _C_FLAG((tty), CBAUD)

Definition at line 127 of file tty.h.

#define C_CIBAUD (   tty)    _C_FLAG((tty), CIBAUD)

Definition at line 135 of file tty.h.

#define C_CLOCAL (   tty)    _C_FLAG((tty), CLOCAL)

Definition at line 134 of file tty.h.

#define C_CREAD (   tty)    _C_FLAG((tty), CREAD)

Definition at line 130 of file tty.h.

#define C_CRTSCTS (   tty)    _C_FLAG((tty), CRTSCTS)

Definition at line 136 of file tty.h.

#define C_CSIZE (   tty)    _C_FLAG((tty), CSIZE)

Definition at line 128 of file tty.h.

#define C_CSTOPB (   tty)    _C_FLAG((tty), CSTOPB)

Definition at line 129 of file tty.h.

#define C_HUPCL (   tty)    _C_FLAG((tty), HUPCL)

Definition at line 133 of file tty.h.

#define C_PARENB (   tty)    _C_FLAG((tty), PARENB)

Definition at line 131 of file tty.h.

#define C_PARODD (   tty)    _C_FLAG((tty), PARODD)

Definition at line 132 of file tty.h.

#define DISCARD_CHAR (   tty)    ((tty)->termios.c_cc[VDISCARD])

Definition at line 86 of file tty.h.

#define EOF_CHAR (   tty)    ((tty)->termios.c_cc[VEOF])

Definition at line 77 of file tty.h.

#define EOL2_CHAR (   tty)    ((tty)->termios.c_cc[VEOL2])

Definition at line 89 of file tty.h.

#define EOL_CHAR (   tty)    ((tty)->termios.c_cc[VEOL])

Definition at line 84 of file tty.h.

#define ERASE_CHAR (   tty)    ((tty)->termios.c_cc[VERASE])

Definition at line 75 of file tty.h.

#define I_BRKINT (   tty)    _I_FLAG((tty), BRKINT)

Definition at line 97 of file tty.h.

#define I_ICRNL (   tty)    _I_FLAG((tty), ICRNL)

Definition at line 104 of file tty.h.

#define I_IGNBRK (   tty)    _I_FLAG((tty), IGNBRK)

Definition at line 96 of file tty.h.

#define I_IGNCR (   tty)    _I_FLAG((tty), IGNCR)

Definition at line 103 of file tty.h.

#define I_IGNPAR (   tty)    _I_FLAG((tty), IGNPAR)

Definition at line 98 of file tty.h.

#define I_IMAXBEL (   tty)    _I_FLAG((tty), IMAXBEL)

Definition at line 109 of file tty.h.

#define I_INLCR (   tty)    _I_FLAG((tty), INLCR)

Definition at line 102 of file tty.h.

#define I_INPCK (   tty)    _I_FLAG((tty), INPCK)

Definition at line 100 of file tty.h.

#define I_ISTRIP (   tty)    _I_FLAG((tty), ISTRIP)

Definition at line 101 of file tty.h.

#define I_IUCLC (   tty)    _I_FLAG((tty), IUCLC)

Definition at line 105 of file tty.h.

#define I_IUTF8 (   tty)    _I_FLAG((tty), IUTF8)

Definition at line 110 of file tty.h.

#define I_IXANY (   tty)    _I_FLAG((tty), IXANY)

Definition at line 107 of file tty.h.

#define I_IXOFF (   tty)    _I_FLAG((tty), IXOFF)

Definition at line 108 of file tty.h.

#define I_IXON (   tty)    _I_FLAG((tty), IXON)

Definition at line 106 of file tty.h.

#define I_PARMRK (   tty)    _I_FLAG((tty), PARMRK)

Definition at line 99 of file tty.h.

#define INTR_CHAR (   tty)    ((tty)->termios.c_cc[VINTR])

Definition at line 73 of file tty.h.

#define KILL_CHAR (   tty)    ((tty)->termios.c_cc[VKILL])

Definition at line 76 of file tty.h.

#define L_ECHO (   tty)    _L_FLAG((tty), ECHO)

Definition at line 141 of file tty.h.

#define L_ECHOCTL (   tty)    _L_FLAG((tty), ECHOCTL)

Definition at line 147 of file tty.h.

#define L_ECHOE (   tty)    _L_FLAG((tty), ECHOE)

Definition at line 142 of file tty.h.

#define L_ECHOK (   tty)    _L_FLAG((tty), ECHOK)

Definition at line 143 of file tty.h.

#define L_ECHOKE (   tty)    _L_FLAG((tty), ECHOKE)

Definition at line 149 of file tty.h.

#define L_ECHONL (   tty)    _L_FLAG((tty), ECHONL)

Definition at line 144 of file tty.h.

#define L_ECHOPRT (   tty)    _L_FLAG((tty), ECHOPRT)

Definition at line 148 of file tty.h.

#define L_EXTPROC (   tty)    _L_FLAG((tty), EXTPROC)

Definition at line 153 of file tty.h.

#define L_FLUSHO (   tty)    _L_FLAG((tty), FLUSHO)

Definition at line 150 of file tty.h.

#define L_ICANON (   tty)    _L_FLAG((tty), ICANON)

Definition at line 139 of file tty.h.

#define L_IEXTEN (   tty)    _L_FLAG((tty), IEXTEN)

Definition at line 152 of file tty.h.

#define L_ISIG (   tty)    _L_FLAG((tty), ISIG)

Definition at line 138 of file tty.h.

#define L_NOFLSH (   tty)    _L_FLAG((tty), NOFLSH)

Definition at line 145 of file tty.h.

#define L_PENDIN (   tty)    _L_FLAG((tty), PENDIN)

Definition at line 151 of file tty.h.

#define L_TOSTOP (   tty)    _L_FLAG((tty), TOSTOP)

Definition at line 146 of file tty.h.

#define L_XCASE (   tty)    _L_FLAG((tty), XCASE)

Definition at line 140 of file tty.h.

#define LNEXT_CHAR (   tty)    ((tty)->termios.c_cc[VLNEXT])

Definition at line 88 of file tty.h.

#define MIN_CHAR (   tty)    ((tty)->termios.c_cc[VMIN])

Definition at line 79 of file tty.h.

#define N_TTY_BUF_SIZE   4096

Definition at line 266 of file tty.h.

#define NR_UNIX98_PTY_DEFAULT   4096 /* Default maximum for Unix98 ptys */

Definition at line 20 of file tty.h.

#define NR_UNIX98_PTY_MAX   (1 << MINORBITS) /* Absolute limit */

Definition at line 22 of file tty.h.

#define NR_UNIX98_PTY_RESERVE   1024 /* Default reserve for main devpts */

Definition at line 21 of file tty.h.

#define O_BSDLY (   tty)    _O_FLAG((tty), BSDLY)

Definition at line 123 of file tty.h.

#define O_CRDLY (   tty)    _O_FLAG((tty), CRDLY)

Definition at line 121 of file tty.h.

#define O_FFDLY (   tty)    _O_FLAG((tty), FFDLY)

Definition at line 125 of file tty.h.

#define O_NLDLY (   tty)    _O_FLAG((tty), NLDLY)

Definition at line 120 of file tty.h.

#define O_OCRNL (   tty)    _O_FLAG((tty), OCRNL)

Definition at line 115 of file tty.h.

#define O_OFDEL (   tty)    _O_FLAG((tty), OFDEL)

Definition at line 119 of file tty.h.

#define O_OFILL (   tty)    _O_FLAG((tty), OFILL)

Definition at line 118 of file tty.h.

#define O_OLCUC (   tty)    _O_FLAG((tty), OLCUC)

Definition at line 113 of file tty.h.

#define O_ONLCR (   tty)    _O_FLAG((tty), ONLCR)

Definition at line 114 of file tty.h.

#define O_ONLRET (   tty)    _O_FLAG((tty), ONLRET)

Definition at line 117 of file tty.h.

#define O_ONOCR (   tty)    _O_FLAG((tty), ONOCR)

Definition at line 116 of file tty.h.

#define O_OPOST (   tty)    _O_FLAG((tty), OPOST)

Definition at line 112 of file tty.h.

#define O_TABDLY (   tty)    _O_FLAG((tty), TABDLY)

Definition at line 122 of file tty.h.

#define O_VTDLY (   tty)    _O_FLAG((tty), VTDLY)

Definition at line 124 of file tty.h.

#define QUIT_CHAR (   tty)    ((tty)->termios.c_cc[VQUIT])

Definition at line 74 of file tty.h.

#define REPRINT_CHAR (   tty)    ((tty)->termios.c_cc[VREPRINT])

Definition at line 85 of file tty.h.

#define START_CHAR (   tty)    ((tty)->termios.c_cc[VSTART])

Definition at line 81 of file tty.h.

#define STOP_CHAR (   tty)    ((tty)->termios.c_cc[VSTOP])

Definition at line 82 of file tty.h.

#define SUSP_CHAR (   tty)    ((tty)->termios.c_cc[VSUSP])

Definition at line 83 of file tty.h.

#define SWTC_CHAR (   tty)    ((tty)->termios.c_cc[VSWTC])

Definition at line 80 of file tty.h.

#define TIME_CHAR (   tty)    ((tty)->termios.c_cc[VTIME])

Definition at line 78 of file tty.h.

#define TTY_BREAK   1

Definition at line 68 of file tty.h.

#define TTY_BUFFER_PAGE   (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)

Definition at line 51 of file tty.h.

#define TTY_CLOSING   7 /* ->close() in progress */

Definition at line 329 of file tty.h.

#define TTY_DEBUG   4 /* Debugging */

Definition at line 326 of file tty.h.

#define TTY_DO_WRITE_WAKEUP   5 /* Call write_wakeup after queuing new */

Definition at line 327 of file tty.h.

#define TTY_EXCLUSIVE   3 /* Exclusive open mode */

Definition at line 325 of file tty.h.

#define TTY_FLUSHING   19 /* Flushing to ldisc in progress */

Definition at line 338 of file tty.h.

#define TTY_FLUSHPENDING   20 /* Queued buffer flush pending */

Definition at line 339 of file tty.h.

#define TTY_FRAME   2

Definition at line 69 of file tty.h.

#define TTY_HUPPED   18 /* Post driver->hangup() */

Definition at line 337 of file tty.h.

#define TTY_HUPPING   21 /* ->hangup() in progress */

Definition at line 340 of file tty.h.

#define TTY_HW_COOK_IN   15 /* Hardware can do input cooking */

Definition at line 334 of file tty.h.

#define TTY_HW_COOK_OUT   14 /* Hardware can do output cooking */

Definition at line 333 of file tty.h.

#define TTY_IO_ERROR   1 /* Cause an I/O error (may be no ldisc too) */

Definition at line 323 of file tty.h.

#define tty_is_writelocked (   tty)    (mutex_is_locked(&tty->atomic_write_lock))

Definition at line 468 of file tty.h.

#define TTY_LDISC   9 /* Line discipline attached */

Definition at line 330 of file tty.h.

#define TTY_LDISC_CHANGING   10 /* Line discipline changing */

Definition at line 331 of file tty.h.

#define TTY_LDISC_OPEN   11 /* Line discipline is open */

Definition at line 332 of file tty.h.

#define TTY_MAGIC   0x5401

Definition at line 312 of file tty.h.

#define TTY_NO_WRITE_SPLIT   17 /* Preserve write boundaries to driver */

Definition at line 336 of file tty.h.

#define TTY_NORMAL   0

Definition at line 67 of file tty.h.

#define TTY_OTHER_CLOSED   2 /* Other side (if any) has closed */

Definition at line 324 of file tty.h.

#define TTY_OVERRUN   4

Definition at line 71 of file tty.h.

#define TTY_PARITY   3

Definition at line 70 of file tty.h.

#define TTY_PTY_LOCK   16 /* pty private */

Definition at line 335 of file tty.h.

#define TTY_PUSH   6 /* n_tty private */

Definition at line 328 of file tty.h.

#define TTY_THROTTLED   0 /* Call unthrottle() at threshold min */

Definition at line 322 of file tty.h.

#define TTY_WRITE_FLUSH (   tty)    tty_write_flush((tty))

Definition at line 342 of file tty.h.

#define wait_event_interruptible_tty (   tty,
  wq,
  condition 
)
Value:
({ \
int __ret = 0; \
if (!(condition)) { \
__wait_event_interruptible_tty(tty, wq, condition, __ret); \
} \
__ret; \
})

Definition at line 633 of file tty.h.

#define WERASE_CHAR (   tty)    ((tty)->termios.c_cc[VWERASE])

Definition at line 87 of file tty.h.

Function Documentation

void __do_SAK ( struct tty_struct tty)

Definition at line 2835 of file tty_io.c.

struct tty_struct* alloc_tty_struct ( void  )
read

alloc_tty_struct - allocate a tty object

Return a new empty tty structure. The data fields have not been initialized in any way but has been zeroed

Locking: none

Definition at line 168 of file tty_io.c.

void console_init ( void  )

Definition at line 145 of file early_serial_console.c.

void deinitialize_tty_struct ( struct tty_struct tty)

deinitialize_tty_struct : tty to deinitialize

This subroutine deinitializes a tty structure that has been newly allocated but tty_release cannot be called on that yet.

Locking: none - tty in question must not be exposed at this point

Definition at line 2973 of file tty_io.c.

void disassociate_ctty ( int  on_exit)

disassociate_ctty - disconnect controlling tty : true if exiting so need to "hang up" the session

This function is typically called only by the session leader, when it wants to disassociate itself from its controlling tty.

It performs the following functions: (1) Sends a SIGHUP and SIGCONT to the foreground process group (2) Clears the tty from being controlling the session (3) Clears the controlling tty for all processes in the session group.

The argument on_exit is set to 1 if called when a process is exiting; it is 0 if called by the ioctl TIOCNOTTY.

Locking: BTM is taken for hysterical raisins, and held when called from no_tty(). tty_mutex is taken to protect tty ->siglock is taken to protect ->signal/->sighand tasklist_lock is taken to walk process list for sessions ->siglock is taken to protect ->signal/->sighand

Definition at line 792 of file tty_io.c.

void do_SAK ( struct tty_struct tty)

Definition at line 2898 of file tty_io.c.

void free_tty_struct ( struct tty_struct tty)

free_tty_struct - free a disused tty : tty struct to free

Free the write buffers, tty queue and tty memory itself.

Locking: none. Must be called after tty is definitely unused

Definition at line 182 of file tty_io.c.

struct tty_struct* get_current_tty ( void  )
read

Definition at line 3384 of file tty_io.c.

void initialize_tty_struct ( struct tty_struct tty,
struct tty_driver driver,
int  idx 
)

initialize_tty_struct : tty to initialize

This subroutine initializes a tty structure that has been newly allocated.

Locking: none - tty in question must not be exposed at this point

Definition at line 2931 of file tty_io.c.

int is_current_pgrp_orphaned ( void  )

Definition at line 271 of file exit.c.

int is_ignored ( int  sig)

Definition at line 1451 of file n_tty.c.

long n_tty_compat_ioctl_helper ( struct tty_struct tty,
struct file file,
unsigned int  cmd,
unsigned long  arg 
)
void n_tty_inherit_ops ( struct tty_ldisc_ops ops)

n_tty_inherit_ops - inherit N_TTY methods : struct tty_ldisc_ops where to save N_TTY methods

Used by a generic struct tty_ldisc_ops to easily inherit N_TTY methods.

Definition at line 2141 of file n_tty.c.

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.

void no_tty ( void  )

no_tty - Ensure the current process does not have a controlling tty

Definition at line 859 of file tty_io.c.

int pcxe_open ( struct tty_struct tty,
struct file filp 
)
void proc_clear_tty ( struct task_struct p)

Definition at line 3343 of file tty_io.c.

void serial_console_init ( void  )

Definition at line 111 of file serial.c.

void start_tty ( struct tty_struct tty)

start_tty - propagate flow control : tty to start

Start a tty that has been stopped if at all possible. Perform any necessary wakeups and propagate the TIOCPKT status. If this is the tty was previous stopped and is being started then the driver start method is invoked and the line discipline woken.

Locking: ctrl_lock

Definition at line 922 of file tty_io.c.

void stop_tty ( struct tty_struct tty)

stop_tty - propagate flow control : tty to stop

Perform flow control to the driver. For PTY/TTY pairs we must also propagate the TIOCKPKT status. May be called on an already stopped device and will not re-call the driver method.

This functionality is used by both the line disciplines for halting incoming flow and by the driver. It may therefore be called from any context, may be under the tty atomic_write_lock but not always.

Locking: Uses the tty control lock internally

Definition at line 888 of file tty_io.c.

void tty_add_file ( struct tty_struct tty,
struct file file 
)

Definition at line 213 of file tty_io.c.

int tty_alloc_file ( struct file file)

Definition at line 199 of file tty_io.c.

void tty_buffer_flush ( struct tty_struct tty)

tty_buffer_flush - flush full tty buffers : tty to flush

flush all the buffers containing receive data. If the buffer is being processed by flush_to_ldisc then we defer the processing to that function

Locking: none

Definition at line 135 of file tty_buffer.c.

void tty_buffer_free_all ( struct tty_struct tty)

tty_buffer_free_all - free buffers used by a tty : tty to free from

Remove all the buffers pending on a tty whether queued with data or in the free ring. Must be called when the tty is no longer in use

Locking: none

Definition at line 30 of file tty_buffer.c.

void tty_buffer_init ( struct tty_struct tty)

tty_buffer_init - prepare a tty buffer structure : tty to initialise

Set up the initial state of the buffer management for a tty device. Must be called before the other tty buffer functions are used.

Locking: none

Definition at line 558 of file tty_buffer.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.

int tty_check_change ( struct tty_struct tty)

tty_check_change - check for POSIX terminal changes : tty to check

If we try to write to, or set the state of, a terminal and we're not in the foreground, send a SIGTTOU. If the signal is blocked or ignored, go ahead and perform the operation. (POSIX 7.2)

Locking: ctrl_lock

Definition at line 408 of file tty_io.c.

void tty_default_fops ( struct file_operations fops)

Definition at line 3396 of file tty_io.c.

dev_t tty_devnum ( struct tty_struct tty)

Definition at line 3337 of file tty_io.c.

int tty_do_resize ( struct tty_struct tty,
struct winsize ws 
)

tty_do_resize - resize event : tty being resized : rows (character) : cols (character)

Update the termios variables and send the necessary signals to peform a terminal resize correctly

Definition at line 2185 of file tty_io.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_driver_remove_tty ( struct tty_driver driver,
struct tty_struct tty 
)

tty_driver_remove_tty() - remove a tty from the driver tables : the driver for the tty : the minor number

Remvoe a tty object from the driver tables. The tty->index field will be set by the time this is called.

Locking: tty_mutex for now

Definition at line 1315 of file tty_io.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.

void tty_flip_buffer_push ( struct tty_struct tty)

tty_flip_buffer_push - terminal : tty to push

Queue a push of the terminal flip buffers to the line discipline. This function must not be called from IRQ context if tty->low_latency is set.

In the event of the queue being busy for flipping the work will be held off and retried later.

Locking: tty buffer lock. Driver locks in low latency mode.

Definition at line 533 of file tty_buffer.c.

void tty_flush_to_ldisc ( struct tty_struct tty)

tty_flush_to_ldisc : tty to push

Push the terminal flip buffers to the line discipline.

Must not be called from IRQ context.

Definition at line 515 of file tty_buffer.c.

void tty_free_file ( struct file file)

tty_free_file - free file->private_data

This shall be used only for fail path handling when tty_add_file was not called yet.

Definition at line 231 of file tty_io.c.

void tty_free_termios ( struct tty_struct tty)

Definition at line 1448 of file tty_io.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.

struct pid* tty_get_pgrp ( struct tty_struct tty)
read

tty_get_pgrp - return a ref counted pgrp pid : tty to read

Returns a refcounted instance of the pid struct for the process group controlling the tty.

Definition at line 2359 of file tty_io.c.

void tty_hangup ( struct tty_struct tty)

tty_hangup - trigger a hangup event : tty to hangup

A carrier loss (virtual or otherwise) has occurred on this like schedule a hangup sequence to run after this event.

Definition at line 694 of file tty_io.c.

int tty_hung_up_p ( struct file filp)

tty_hung_up_p - was tty hung up : file pointer of tty

Return true if the tty has been subject to a vhangup or a carrier loss

Definition at line 752 of file tty_io.c.

int __init tty_init ( void  )

Definition at line 3490 of file tty_io.c.

struct tty_struct* tty_init_dev ( struct tty_driver driver,
int  idx 
)
read

tty_init_dev - initialise a tty device : tty driver we are opening a device on : device index : returned tty structure

Prepare a tty device. This may not be a "new" clean device but could also be an active device. The pty drivers require special handling because of this.

Locking: The function is called under the tty_mutex, which protects us from the tty struct or driver itself going away.

On exit the tty device has the line discipline attached and a reference count of 1. If a pair was created for pty/tty use and the other was a pty master then it too has a reference count of 1.

WSH 06/09/97: Rewritten to remove races and properly clean up after a failed open. The new code protects the open with a mutex, so it's really quite straightforward. The mutex locking can probably be relaxed for the (most common) case of reopening a tty.

Definition at line 1385 of file tty_io.c.

int tty_init_termios ( struct tty_struct tty)

tty_init_termios - helper for termios setup : the tty to set up

Initialise the termios structures for this tty. Thus runs under the tty_mutex currently so we can be relaxed about ordering.

Definition at line 1251 of file tty_io.c.

long tty_ioctl ( struct file file,
unsigned int  cmd,
unsigned long  arg 
)

Definition at line 2639 of file tty_io.c.

void tty_kref_put ( struct tty_struct tty)

tty_kref_put - release a tty kref : tty device

Release a reference to a tty device and if need be let the kref layer destruct the object for us

Definition at line 1527 of file tty_io.c.

void tty_ldisc_begin ( void  )

Definition at line 980 of file tty_ldisc.c.

void tty_ldisc_deinit ( struct tty_struct tty)

tty_ldisc_init - ldisc cleanup for new tty : tty that was allocated recently

The tty structure must not becompletely set up (tty_ldisc_setup) when this call is made.

Definition at line 974 of file tty_ldisc.c.

void tty_ldisc_deref ( struct tty_ldisc ld)

tty_ldisc_deref - free a tty ldisc reference : reference to free up

Undoes the effect of tty_ldisc_ref or tty_ldisc_ref_wait. May be called in IRQ context.

Locking: takes tty_ldisc_lock

Definition at line 351 of file tty_ldisc.c.

void tty_ldisc_enable ( struct tty_struct tty)

tty_ldisc_enable - allow ldisc use : terminal to activate ldisc on

Set the TTY_LDISC flag when the line discipline can be called again. Do necessary wakeups for existing sleepers. Clear the LDISC changing flag to indicate any ldisc change is now over.

Note: nobody should set the TTY_LDISC bit except via this function. Clearing directly is allowed.

Definition at line 374 of file tty_ldisc.c.

void tty_ldisc_flush ( struct tty_struct tty)

tty_ldisc_flush - flush line discipline queue : tty

Flush the line discipline queue (if any) for this tty. If there is no line discipline active this is a no-op.

Definition at line 389 of file tty_ldisc.c.

void tty_ldisc_hangup ( struct tty_struct tty)

tty_ldisc_hangup - hangup ldisc reset : tty being hung up

Some tty devices reset their termios when they receive a hangup event. In that situation we must also switch back to N_TTY properly before we reset the termios data.

Locking: We can take the ldisc mutex as the rest of the code is careful to allow for this.

In the pty pair case this occurs in the close() path of the tty itself so we must be careful about locking rules.

Definition at line 775 of file tty_ldisc.c.

void tty_ldisc_init ( struct tty_struct tty)

tty_ldisc_init - ldisc setup for new tty : tty being allocated

Set up the line discipline objects for a newly allocated tty. Note that the tty structure is not completely set up when this call is made.

Definition at line 959 of file tty_ldisc.c.

struct tty_ldisc* tty_ldisc_ref ( struct tty_struct tty)
read

tty_ldisc_ref - get the tty ldisc : tty device

Dereference the line discipline for the terminal and take a reference to it. If the line discipline is in flux then return NULL. Can be called from IRQ and timer functions.

Locking: called functions take tty_ldisc_lock

Definition at line 335 of file tty_ldisc.c.

struct tty_ldisc* tty_ldisc_ref_wait ( struct tty_struct tty)
read

tty_ldisc_ref_wait - wait for the tty ldisc : tty device

Dereference the line discipline for the terminal and take a reference to it. If the line discipline is in flux then wait patiently until it changes.

Note: Must not be called from an IRQ/timer context. The caller must also be careful not to hold other locks that will deadlock against a discipline change, such as an existing ldisc reference (which we check for)

Locking: call functions take tty_ldisc_lock

Definition at line 314 of file tty_ldisc.c.

void tty_ldisc_release ( struct tty_struct tty,
struct tty_struct o_tty 
)

tty_ldisc_release - release line discipline : tty being shut down : pair tty for pty/tty pairs

Called during the final close of a tty/pty pair in order to shut down the line discpline layer. On exit the ldisc assigned is N_TTY and the ldisc has not been opened.

Definition at line 924 of file tty_ldisc.c.

int tty_ldisc_setup ( struct tty_struct tty,
struct tty_struct o_tty 
)

tty_ldisc_setup - open line discipline : tty being shut down : pair tty for pty/tty pairs

Called during the initial open of a tty/pty pair in order to set up the line disciplines and bind them to the tty. This has no locking issues as the device isn't yet active.

Definition at line 877 of file tty_ldisc.c.

void __lockfunc tty_lock ( struct tty_struct tty)

Definition at line 30 of file tty_mutex.c.

void __lockfunc tty_lock_pair ( struct tty_struct tty,
struct tty_struct tty2 
)

Definition at line 52 of file tty_mutex.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.

char* tty_name ( struct tty_struct tty,
char buf 
)

tty_name - return tty naming : tty structure : buffer for output

Convert a tty structure into a name. The name reflects the kernel naming policy and if udev is in use may not reflect user space

Locking: none

Definition at line 264 of file tty_io.c.

struct tty_struct* tty_pair_get_pty ( struct tty_struct tty)
read

Definition at line 2627 of file tty_io.c.

struct tty_struct* tty_pair_get_tty ( struct tty_struct tty)
read

Definition at line 2618 of file tty_io.c.

int tty_paranoia_check ( struct tty_struct tty,
struct inode inode,
const char routine 
)

Definition at line 275 of file tty_io.c.

int tty_perform_flush ( struct tty_struct tty,
unsigned long  arg 
)

Definition at line 1089 of file tty_ioctl.c.

int tty_port_alloc_xmit_buf ( struct tty_port port)

Definition at line 100 of file tty_port.c.

int tty_port_block_til_ready ( struct tty_port port,
struct tty_struct tty,
struct file filp 
)

tty_port_block_til_ready - Waiting logic for tty open : the tty port being opened : the tty device being bound : the file pointer of the opener

Implement the core POSIX/SuS tty behaviour when opening a tty device. Handles:

  • hangup (both before and during)
  • non blocking open
  • rts/dtr/dcd
  • signals
  • port flags and counts

The passed tty_port must implement the carrier_raised method if it can do carrier detect and the dtr_rts method if it supports software management of these lines. Note that the dtr/rts raise is done each iteration as a hangup may have previously dropped them while we wait.

Definition at line 288 of file tty_port.c.

int tty_port_carrier_raised ( struct tty_port port)

tty_port_carrier_raised - carrier raised check : tty port

Wrapper for the carrier detect logic. For the moment this is used to hide some internal details. This will eventually become entirely internal to the tty port.

Definition at line 228 of file tty_port.c.

void tty_port_close ( struct tty_port port,
struct tty_struct tty,
struct file filp 
)

Definition at line 468 of file tty_port.c.

void tty_port_close_end ( struct tty_port port,
struct tty_struct tty 
)

Definition at line 446 of file tty_port.c.

int tty_port_close_start ( struct tty_port port,
struct tty_struct tty,
struct file filp 
)

Definition at line 382 of file tty_port.c.

void tty_port_free_xmit_buf ( struct tty_port port)

Definition at line 113 of file tty_port.c.

void tty_port_hangup ( struct tty_port port)

tty_port_hangup - hangup helper : tty port

Perform port level tty hangup flag and count changes. Drop the tty reference.

Definition at line 200 of file tty_port.c.

void tty_port_init ( struct tty_port port)

Definition at line 21 of file tty_port.c.

int tty_port_install ( struct tty_port port,
struct tty_driver driver,
struct tty_struct tty 
)

tty_port_install - generic tty->ops->install handler : tty_port of the device : tty_driver for this device : tty to be installed

It is the same as tty_standard_install except the provided is linked to a concrete tty specified by . Use this or tty_port_register_device (or both). Call tty_port_link_device as a last resort.

Definition at line 490 of file tty_port.c.

void tty_port_link_device ( struct tty_port port,
struct tty_driver driver,
unsigned  index 
)

tty_port_link_device - link tty and tty_port : tty_port of the device : tty_driver for this device : index of the tty

Provide the tty layer wit ha link from a tty (specified by ) to a tty_port (). Use this only if neither tty_port_register_device nor tty_port_install is used in the driver. If used, this has to be called before tty_register_driver.

Definition at line 47 of file tty_port.c.

void tty_port_lower_dtr_rts ( struct tty_port port)

tty_port_lower_dtr_rts - Lower DTR/RTS : tty port

Wrapper for the DTR/RTS raise logic. For the moment this is used to hide some internal details. This will eventually become entirely internal to the tty port.

Definition at line 261 of file tty_port.c.

int tty_port_open ( struct tty_port port,
struct tty_struct tty,
struct file filp 
)

Definition at line 498 of file tty_port.c.

void tty_port_put ( struct tty_port port)

Definition at line 135 of file tty_port.c.

void tty_port_raise_dtr_rts ( struct tty_port port)

tty_port_raise_dtr_rts - Raise DTR/RTS : tty port

Wrapper for the DTR/RTS raise logic. For the moment this is used to hide some internal details. This will eventually become entirely internal to the tty port.

Definition at line 245 of file tty_port.c.

struct device* tty_port_register_device ( struct tty_port port,
struct tty_driver driver,
unsigned  index,
struct device device 
)
read

tty_port_register_device - register tty device : tty_port of the device : tty_driver for this device : index of the tty : parent if exists, otherwise NULL

It is the same as tty_register_device except the provided is linked to a concrete tty specified by . Use this or tty_port_install (or both). Call tty_port_link_device as a last resort.

Definition at line 67 of file tty_port.c.

struct device* tty_port_register_device_attr ( struct tty_port port,
struct tty_driver driver,
unsigned  index,
struct device device,
void drvdata,
const struct attribute_group **  attr_grp 
)
read

tty_port_register_device_attr - register tty device : tty_port of the device : tty_driver for this device : index of the tty : parent if exists, otherwise NULL : Driver data to be set to device. : Attribute group to be set on device.

It is the same as tty_register_device_attr except the provided is linked to a concrete tty specified by . Use this or tty_port_install (or both). Call tty_port_link_device as a last resort.

Definition at line 89 of file tty_port.c.

struct tty_struct* tty_port_tty_get ( struct tty_port port)
read

tty_port_tty_get - get a tty reference : tty port

Return a refcount protected tty instance or NULL if the port is not associated with a tty (eg due to close or hangup)

Definition at line 150 of file tty_port.c.

void tty_port_tty_set ( struct tty_port port,
struct tty_struct tty 
)

tty_port_tty_set - set the tty of a port : tty port : the tty

Associate the port and tty pair. Manages any internal refcounts. Pass NULL to deassociate a port

Definition at line 171 of file tty_port.c.

int tty_put_char ( struct tty_struct tty,
unsigned char  ch 
)

tty_put_char - write one character to a tty : tty : character

Write one byte to the tty using the provided put_char method if present. Returns the number of characters successfully output.

Note: the specific put_char operation in the driver layer may go away soon. Don't call it directly, use this method

Definition at line 2990 of file tty_io.c.

int tty_read_raw_data ( struct tty_struct tty,
unsigned char bufp,
int  buflen 
)
struct device* tty_register_device ( struct tty_driver driver,
unsigned  index,
struct device device 
)
read

tty_register_device - register a tty device : the tty driver that describes the tty device : the index in the tty driver for this tty device : a struct device that is associated with this tty device. This field is optional, if there is no known struct device for this tty device it can be set to NULL safely.

Returns a pointer to the struct device for this tty device (or ERR_PTR(-EFOO) on error).

This call is required to be made to register an individual tty device if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If that bit is not set, this function should not be called by a tty driver.

Locking: ??

Definition at line 3028 of file tty_io.c.

struct device* tty_register_device_attr ( struct tty_driver driver,
unsigned  index,
struct device device,
void drvdata,
const struct attribute_group **  attr_grp 
)
read

tty_register_device_attr - register a tty device : the tty driver that describes the tty device : the index in the tty driver for this tty device : a struct device that is associated with this tty device. This field is optional, if there is no known struct device for this tty device it can be set to NULL safely. : Driver data to be set to device. : Attribute group to be set on device.

Returns a pointer to the struct device for this tty device (or ERR_PTR(-EFOO) on error).

This call is required to be made to register an individual tty device if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If that bit is not set, this function should not be called by a tty driver.

Locking: ??

Definition at line 3061 of file tty_io.c.

int tty_register_driver ( struct tty_driver driver)

Definition at line 3258 of file tty_io.c.

int tty_register_ldisc ( int  disc,
struct tty_ldisc_ops new_ldisc 
)

tty_register_ldisc - install a line discipline : ldisc number : pointer to the ldisc object

Installs a new line discipline into the kernel. The discipline is set up as unreferenced and then made available to the kernel from this point onwards.

Locking: takes tty_ldisc_lock to guard against ldisc races

Definition at line 83 of file tty_ldisc.c.

int tty_release ( struct inode inode,
struct file filp 
)

tty_release - vfs callback for close : inode of tty : file pointer for handle to tty

Called the last time each file handle is closed that references this tty. There may however be several such references.

Locking: Takes bkl. See tty_release_dev

Even releasing the tty structures is a tricky business.. We have to be very careful that the structures are all released at the same time, as interrupts might otherwise get the wrong pointers.

WSH 09/09/97: rewritten to avoid some nasty race conditions that could lead to double frees or releasing memory still in use.

Definition at line 1623 of file tty_io.c.

int tty_set_ldisc ( struct tty_struct tty,
int  ldisc 
)

tty_set_ldisc - set line discipline : the terminal to set : the line discipline

Set the discipline of a tty line. Must be called from a process context. The ldisc change logic has to protect itself against any overlapping ldisc change (including on the other end of pty pairs), the close of one side of a tty/pty pair, and eventually hangup.

Locking: takes tty_ldisc_lock, termios_mutex

Definition at line 560 of file tty_ldisc.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.

int tty_signal ( int  sig,
struct tty_struct tty 
)
int tty_standard_install ( struct tty_driver driver,
struct tty_struct tty 
)

Definition at line 1273 of file tty_io.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_unhangup ( struct file filp)
void __lockfunc tty_unlock ( struct tty_struct tty)

Definition at line 36 of file tty_mutex.c.

void __lockfunc tty_unlock_pair ( struct tty_struct tty,
struct tty_struct tty2 
)

Definition at line 66 of file tty_mutex.c.

void tty_unregister_device ( struct tty_driver driver,
unsigned  index 
)

tty_unregister_device - unregister a tty device : the tty driver that describes the tty device : the index in the tty driver for this tty device

If a tty device is registered with a call to tty_register_device() then this function must be called when the tty device is gone.

Locking: ??

Definition at line 3129 of file tty_io.c.

int tty_unregister_driver ( struct tty_driver driver)

Definition at line 3320 of file tty_io.c.

int tty_unregister_ldisc ( int  disc)

tty_unregister_ldisc - unload a line discipline : ldisc number : pointer to the ldisc object

Remove a line discipline from the kernel providing it is not currently in use.

Locking: takes tty_ldisc_lock to guard against ldisc races

Definition at line 113 of file tty_ldisc.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_vhangup ( struct tty_struct tty)

tty_vhangup - process vhangup : tty to hangup

The user has asked via system call for the terminal to be hung up. We do this synchronously so that when the syscall returns the process is complete. That guarantee is necessary for security reasons.

Definition at line 714 of file tty_io.c.

void tty_vhangup_locked ( struct tty_struct tty)
void tty_vhangup_self ( void  )

tty_vhangup_self - process vhangup for own ctty

Perform a vhangup on the current controlling tty

Definition at line 733 of file tty_io.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.

void tty_wakeup ( struct tty_struct tty)

tty_wakeup - request more data : terminal

Internal and external helper for wakeups of tty. This function informs the line discipline if present that the driver is ready to receive more output data.

Definition at line 519 of file tty_io.c.

void tty_write_flush ( struct tty_struct )
int tty_write_lock ( struct tty_struct tty,
int  ndelay 
)

Definition at line 993 of file tty_io.c.

void tty_write_message ( struct tty_struct tty,
char msg 
)

tty_write_message - write a message to a certain tty, not just the console. : the destination tty_struct : the message to write

This is used for messages that need to be redirected to a specific tty. We don't put it into the syslog queue right now maybe in the future if really needed.

We must still hold the BTM and test the CLOSING flag for the moment.

Definition at line 1105 of file tty_io.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.

void tty_write_unlock ( struct tty_struct tty)

Definition at line 986 of file tty_io.c.

int vcs_init ( void  )

Definition at line 653 of file vc_screen.c.

long vt_compat_ioctl ( struct tty_struct tty,
unsigned int  cmd,
unsigned long  arg 
)
int vt_ioctl ( struct tty_struct tty,
unsigned int  cmd,
unsigned long  arg 
)

Definition at line 291 of file vt_ioctl.c.

Variable Documentation

struct class* tty_class

Definition at line 2998 of file tty_io.c.

spinlock_t tty_files_lock
struct tty_ldisc_ops tty_ldisc_N_TTY

Definition at line 2117 of file n_tty.c.

struct file_operations tty_ldiscs_proc_fops

Definition at line 247 of file tty_ldisc.c.

struct mutex tty_mutex
struct ktermios tty_std_termios

Definition at line 113 of file tty_io.c.