aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tty.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/tty.h')
-rw-r--r--include/linux/tty.h133
1 files changed, 62 insertions, 71 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 9f47ab540f65..f0b4eb47297c 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -1,41 +1,6 @@
1#ifndef _LINUX_TTY_H 1#ifndef _LINUX_TTY_H
2#define _LINUX_TTY_H 2#define _LINUX_TTY_H
3 3
4/*
5 * 'tty.h' defines some structures used by tty_io.c and some defines.
6 */
7
8#define NR_LDISCS 30
9
10/* line disciplines */
11#define N_TTY 0
12#define N_SLIP 1
13#define N_MOUSE 2
14#define N_PPP 3
15#define N_STRIP 4
16#define N_AX25 5
17#define N_X25 6 /* X.25 async */
18#define N_6PACK 7
19#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
20#define N_R3964 9 /* Reserved for Simatic R3964 module */
21#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */
22#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
23#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data */
24 /* cards about SMS messages */
25#define N_HDLC 13 /* synchronous HDLC */
26#define N_SYNC_PPP 14 /* synchronous PPP */
27#define N_HCI 15 /* Bluetooth HCI UART */
28#define N_GIGASET_M101 16 /* Siemens Gigaset M101 serial DECT adapter */
29#define N_SLCAN 17 /* Serial / USB serial CAN Adaptors */
30#define N_PPS 18 /* Pulse per Second */
31#define N_V253 19 /* Codec control over voice modem */
32#define N_CAIF 20 /* CAIF protocol for talking to modems */
33#define N_GSM0710 21 /* GSM 0710 Mux */
34#define N_TI_WL 22 /* for TI's WL BT, FM, GPS combo chips */
35#define N_TRACESINK 23 /* Trace data routing for MIPI P1149.7 */
36#define N_TRACEROUTER 24 /* Trace data routing for MIPI P1149.7 */
37
38#ifdef __KERNEL__
39#include <linux/fs.h> 4#include <linux/fs.h>
40#include <linux/major.h> 5#include <linux/major.h>
41#include <linux/termios.h> 6#include <linux/termios.h>
@@ -43,6 +8,8 @@
43#include <linux/tty_driver.h> 8#include <linux/tty_driver.h>
44#include <linux/tty_ldisc.h> 9#include <linux/tty_ldisc.h>
45#include <linux/mutex.h> 10#include <linux/mutex.h>
11#include <linux/tty_flags.h>
12#include <uapi/linux/tty.h>
46 13
47 14
48 15
@@ -103,28 +70,28 @@ struct tty_bufhead {
103#define TTY_PARITY 3 70#define TTY_PARITY 3
104#define TTY_OVERRUN 4 71#define TTY_OVERRUN 4
105 72
106#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR]) 73#define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
107#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT]) 74#define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
108#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE]) 75#define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
109#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL]) 76#define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
110#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF]) 77#define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
111#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME]) 78#define TIME_CHAR(tty) ((tty)->termios.c_cc[VTIME])
112#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN]) 79#define MIN_CHAR(tty) ((tty)->termios.c_cc[VMIN])
113#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC]) 80#define SWTC_CHAR(tty) ((tty)->termios.c_cc[VSWTC])
114#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART]) 81#define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
115#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP]) 82#define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
116#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP]) 83#define SUSP_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
117#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL]) 84#define EOL_CHAR(tty) ((tty)->termios.c_cc[VEOL])
118#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT]) 85#define REPRINT_CHAR(tty) ((tty)->termios.c_cc[VREPRINT])
119#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD]) 86#define DISCARD_CHAR(tty) ((tty)->termios.c_cc[VDISCARD])
120#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE]) 87#define WERASE_CHAR(tty) ((tty)->termios.c_cc[VWERASE])
121#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) 88#define LNEXT_CHAR(tty) ((tty)->termios.c_cc[VLNEXT])
122#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) 89#define EOL2_CHAR(tty) ((tty)->termios.c_cc[VEOL2])
123 90
124#define _I_FLAG(tty, f) ((tty)->termios->c_iflag & (f)) 91#define _I_FLAG(tty, f) ((tty)->termios.c_iflag & (f))
125#define _O_FLAG(tty, f) ((tty)->termios->c_oflag & (f)) 92#define _O_FLAG(tty, f) ((tty)->termios.c_oflag & (f))
126#define _C_FLAG(tty, f) ((tty)->termios->c_cflag & (f)) 93#define _C_FLAG(tty, f) ((tty)->termios.c_cflag & (f))
127#define _L_FLAG(tty, f) ((tty)->termios->c_lflag & (f)) 94#define _L_FLAG(tty, f) ((tty)->termios.c_lflag & (f))
128 95
129#define I_IGNBRK(tty) _I_FLAG((tty), IGNBRK) 96#define I_IGNBRK(tty) _I_FLAG((tty), IGNBRK)
130#define I_BRKINT(tty) _I_FLAG((tty), BRKINT) 97#define I_BRKINT(tty) _I_FLAG((tty), BRKINT)
@@ -268,10 +235,11 @@ struct tty_struct {
268 struct mutex ldisc_mutex; 235 struct mutex ldisc_mutex;
269 struct tty_ldisc *ldisc; 236 struct tty_ldisc *ldisc;
270 237
238 struct mutex legacy_mutex;
271 struct mutex termios_mutex; 239 struct mutex termios_mutex;
272 spinlock_t ctrl_lock; 240 spinlock_t ctrl_lock;
273 /* Termios values are protected by the termios mutex */ 241 /* Termios values are protected by the termios mutex */
274 struct ktermios *termios, *termios_locked; 242 struct ktermios termios, termios_locked;
275 struct termiox *termiox; /* May be NULL for unsupported */ 243 struct termiox *termiox; /* May be NULL for unsupported */
276 char name[64]; 244 char name[64];
277 struct pid *pgrp; /* Protected by ctrl lock */ 245 struct pid *pgrp; /* Protected by ctrl lock */
@@ -410,6 +378,10 @@ extern int tty_register_driver(struct tty_driver *driver);
410extern int tty_unregister_driver(struct tty_driver *driver); 378extern int tty_unregister_driver(struct tty_driver *driver);
411extern struct device *tty_register_device(struct tty_driver *driver, 379extern struct device *tty_register_device(struct tty_driver *driver,
412 unsigned index, struct device *dev); 380 unsigned index, struct device *dev);
381extern struct device *tty_register_device_attr(struct tty_driver *driver,
382 unsigned index, struct device *device,
383 void *drvdata,
384 const struct attribute_group **attr_grp);
413extern void tty_unregister_device(struct tty_driver *driver, unsigned index); 385extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
414extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, 386extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
415 int buflen); 387 int buflen);
@@ -423,7 +395,6 @@ extern void tty_unthrottle(struct tty_struct *tty);
423extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws); 395extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws);
424extern void tty_driver_remove_tty(struct tty_driver *driver, 396extern void tty_driver_remove_tty(struct tty_driver *driver,
425 struct tty_struct *tty); 397 struct tty_struct *tty);
426extern void tty_shutdown(struct tty_struct *tty);
427extern void tty_free_termios(struct tty_struct *tty); 398extern void tty_free_termios(struct tty_struct *tty);
428extern int is_current_pgrp_orphaned(void); 399extern int is_current_pgrp_orphaned(void);
429extern struct pid *tty_get_pgrp(struct tty_struct *tty); 400extern struct pid *tty_get_pgrp(struct tty_struct *tty);
@@ -497,6 +468,15 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay);
497#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock)) 468#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock))
498 469
499extern void tty_port_init(struct tty_port *port); 470extern void tty_port_init(struct tty_port *port);
471extern void tty_port_link_device(struct tty_port *port,
472 struct tty_driver *driver, unsigned index);
473extern struct device *tty_port_register_device(struct tty_port *port,
474 struct tty_driver *driver, unsigned index,
475 struct device *device);
476extern struct device *tty_port_register_device_attr(struct tty_port *port,
477 struct tty_driver *driver, unsigned index,
478 struct device *device, void *drvdata,
479 const struct attribute_group **attr_grp);
500extern int tty_port_alloc_xmit_buf(struct tty_port *port); 480extern int tty_port_alloc_xmit_buf(struct tty_port *port);
501extern void tty_port_free_xmit_buf(struct tty_port *port); 481extern void tty_port_free_xmit_buf(struct tty_port *port);
502extern void tty_port_put(struct tty_port *port); 482extern void tty_port_put(struct tty_port *port);
@@ -508,6 +488,12 @@ static inline struct tty_port *tty_port_get(struct tty_port *port)
508 return port; 488 return port;
509} 489}
510 490
491/* If the cts flow control is enabled, return true. */
492static inline bool tty_port_cts_enabled(struct tty_port *port)
493{
494 return port->flags & ASYNC_CTS_FLOW;
495}
496
511extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 497extern struct tty_struct *tty_port_tty_get(struct tty_port *port);
512extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 498extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
513extern int tty_port_carrier_raised(struct tty_port *port); 499extern int tty_port_carrier_raised(struct tty_port *port);
@@ -521,6 +507,8 @@ extern int tty_port_close_start(struct tty_port *port,
521extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); 507extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty);
522extern void tty_port_close(struct tty_port *port, 508extern void tty_port_close(struct tty_port *port,
523 struct tty_struct *tty, struct file *filp); 509 struct tty_struct *tty, struct file *filp);
510extern int tty_port_install(struct tty_port *port, struct tty_driver *driver,
511 struct tty_struct *tty);
524extern int tty_port_open(struct tty_port *port, 512extern int tty_port_open(struct tty_port *port,
525 struct tty_struct *tty, struct file *filp); 513 struct tty_struct *tty, struct file *filp);
526static inline int tty_port_users(struct tty_port *port) 514static inline int tty_port_users(struct tty_port *port)
@@ -553,7 +541,7 @@ extern void tty_audit_fork(struct signal_struct *sig);
553extern void tty_audit_tiocsti(struct tty_struct *tty, char ch); 541extern void tty_audit_tiocsti(struct tty_struct *tty, char ch);
554extern void tty_audit_push(struct tty_struct *tty); 542extern void tty_audit_push(struct tty_struct *tty);
555extern int tty_audit_push_task(struct task_struct *tsk, 543extern int tty_audit_push_task(struct task_struct *tsk,
556 uid_t loginuid, u32 sessionid); 544 kuid_t loginuid, u32 sessionid);
557#else 545#else
558static inline void tty_audit_add_data(struct tty_struct *tty, 546static inline void tty_audit_add_data(struct tty_struct *tty,
559 unsigned char *data, size_t size) 547 unsigned char *data, size_t size)
@@ -572,7 +560,7 @@ static inline void tty_audit_push(struct tty_struct *tty)
572{ 560{
573} 561}
574static inline int tty_audit_push_task(struct task_struct *tsk, 562static inline int tty_audit_push_task(struct task_struct *tsk,
575 uid_t loginuid, u32 sessionid) 563 kuid_t loginuid, u32 sessionid)
576{ 564{
577 return 0; 565 return 0;
578} 566}
@@ -605,8 +593,12 @@ extern long vt_compat_ioctl(struct tty_struct *tty,
605 593
606/* tty_mutex.c */ 594/* tty_mutex.c */
607/* functions for preparation of BKL removal */ 595/* functions for preparation of BKL removal */
608extern void __lockfunc tty_lock(void) __acquires(tty_lock); 596extern void __lockfunc tty_lock(struct tty_struct *tty);
609extern void __lockfunc tty_unlock(void) __releases(tty_lock); 597extern void __lockfunc tty_unlock(struct tty_struct *tty);
598extern void __lockfunc tty_lock_pair(struct tty_struct *tty,
599 struct tty_struct *tty2);
600extern void __lockfunc tty_unlock_pair(struct tty_struct *tty,
601 struct tty_struct *tty2);
610 602
611/* 603/*
612 * this shall be called only from where BTM is held (like close) 604 * this shall be called only from where BTM is held (like close)
@@ -621,9 +613,9 @@ extern void __lockfunc tty_unlock(void) __releases(tty_lock);
621static inline void tty_wait_until_sent_from_close(struct tty_struct *tty, 613static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,
622 long timeout) 614 long timeout)
623{ 615{
624 tty_unlock(); /* tty->ops->close holds the BTM, drop it while waiting */ 616 tty_unlock(tty); /* tty->ops->close holds the BTM, drop it while waiting */
625 tty_wait_until_sent(tty, timeout); 617 tty_wait_until_sent(tty, timeout);
626 tty_lock(); 618 tty_lock(tty);
627} 619}
628 620
629/* 621/*
@@ -638,16 +630,16 @@ static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,
638 * 630 *
639 * Do not use in new code. 631 * Do not use in new code.
640 */ 632 */
641#define wait_event_interruptible_tty(wq, condition) \ 633#define wait_event_interruptible_tty(tty, wq, condition) \
642({ \ 634({ \
643 int __ret = 0; \ 635 int __ret = 0; \
644 if (!(condition)) { \ 636 if (!(condition)) { \
645 __wait_event_interruptible_tty(wq, condition, __ret); \ 637 __wait_event_interruptible_tty(tty, wq, condition, __ret); \
646 } \ 638 } \
647 __ret; \ 639 __ret; \
648}) 640})
649 641
650#define __wait_event_interruptible_tty(wq, condition, ret) \ 642#define __wait_event_interruptible_tty(tty, wq, condition, ret) \
651do { \ 643do { \
652 DEFINE_WAIT(__wait); \ 644 DEFINE_WAIT(__wait); \
653 \ 645 \
@@ -656,9 +648,9 @@ do { \
656 if (condition) \ 648 if (condition) \
657 break; \ 649 break; \
658 if (!signal_pending(current)) { \ 650 if (!signal_pending(current)) { \
659 tty_unlock(); \ 651 tty_unlock(tty); \
660 schedule(); \ 652 schedule(); \
661 tty_lock(); \ 653 tty_lock(tty); \
662 continue; \ 654 continue; \
663 } \ 655 } \
664 ret = -ERESTARTSYS; \ 656 ret = -ERESTARTSYS; \
@@ -668,5 +660,4 @@ do { \
668} while (0) 660} while (0)
669 661
670 662
671#endif /* __KERNEL__ */
672#endif 663#endif