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.h82
1 files changed, 80 insertions, 2 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 6abfcf5b5887..67d64e6efe7a 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -13,6 +13,7 @@
13#include <linux/tty_driver.h> 13#include <linux/tty_driver.h>
14#include <linux/tty_ldisc.h> 14#include <linux/tty_ldisc.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/smp_lock.h>
16 17
17#include <asm/system.h> 18#include <asm/system.h>
18 19
@@ -23,7 +24,7 @@
23 */ 24 */
24#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */ 25#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
25#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */ 26#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
26#define NR_LDISCS 20 27#define NR_LDISCS 30
27 28
28/* line disciplines */ 29/* line disciplines */
29#define N_TTY 0 30#define N_TTY 0
@@ -46,8 +47,9 @@
46#define N_GIGASET_M101 16 /* Siemens Gigaset M101 serial DECT adapter */ 47#define N_GIGASET_M101 16 /* Siemens Gigaset M101 serial DECT adapter */
47#define N_SLCAN 17 /* Serial / USB serial CAN Adaptors */ 48#define N_SLCAN 17 /* Serial / USB serial CAN Adaptors */
48#define N_PPS 18 /* Pulse per Second */ 49#define N_PPS 18 /* Pulse per Second */
49
50#define N_V253 19 /* Codec control over voice modem */ 50#define N_V253 19 /* Codec control over voice modem */
51#define N_CAIF 20 /* CAIF protocol for talking to modems */
52#define N_GSM0710 21 /* GSM 0710 Mux */
51 53
52/* 54/*
53 * This character is the same as _POSIX_VDISABLE: it cannot be used as 55 * This character is the same as _POSIX_VDISABLE: it cannot be used as
@@ -68,6 +70,17 @@ struct tty_buffer {
68 unsigned long data[0]; 70 unsigned long data[0];
69}; 71};
70 72
73/*
74 * We default to dicing tty buffer allocations to this many characters
75 * in order to avoid multiple page allocations. We know the size of
76 * tty_buffer itself but it must also be taken into account that the
77 * the buffer is 256 byte aligned. See tty_buffer_find for the allocation
78 * logic this must match
79 */
80
81#define TTY_BUFFER_PAGE (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)
82
83
71struct tty_bufhead { 84struct tty_bufhead {
72 struct delayed_work work; 85 struct delayed_work work;
73 spinlock_t lock; 86 spinlock_t lock;
@@ -167,6 +180,7 @@ struct tty_bufhead {
167#define L_FLUSHO(tty) _L_FLAG((tty), FLUSHO) 180#define L_FLUSHO(tty) _L_FLAG((tty), FLUSHO)
168#define L_PENDIN(tty) _L_FLAG((tty), PENDIN) 181#define L_PENDIN(tty) _L_FLAG((tty), PENDIN)
169#define L_IEXTEN(tty) _L_FLAG((tty), IEXTEN) 182#define L_IEXTEN(tty) _L_FLAG((tty), IEXTEN)
183#define L_EXTPROC(tty) _L_FLAG((tty), EXTPROC)
170 184
171struct device; 185struct device;
172struct signal_struct; 186struct signal_struct;
@@ -213,6 +227,7 @@ struct tty_port {
213 wait_queue_head_t close_wait; /* Close waiters */ 227 wait_queue_head_t close_wait; /* Close waiters */
214 wait_queue_head_t delta_msr_wait; /* Modem status change */ 228 wait_queue_head_t delta_msr_wait; /* Modem status change */
215 unsigned long flags; /* TTY flags ASY_*/ 229 unsigned long flags; /* TTY flags ASY_*/
230 unsigned char console:1; /* port is a console */
216 struct mutex mutex; /* Locking */ 231 struct mutex mutex; /* Locking */
217 struct mutex buf_mutex; /* Buffer alloc lock */ 232 struct mutex buf_mutex; /* Buffer alloc lock */
218 unsigned char *xmit_buf; /* Optional buffer */ 233 unsigned char *xmit_buf; /* Optional buffer */
@@ -314,6 +329,13 @@ struct tty_struct {
314 struct tty_port *port; 329 struct tty_port *port;
315}; 330};
316 331
332/* Each of a tty's open files has private_data pointing to tty_file_private */
333struct tty_file_private {
334 struct tty_struct *tty;
335 struct file *file;
336 struct list_head list;
337};
338
317/* tty magic number */ 339/* tty magic number */
318#define TTY_MAGIC 0x5401 340#define TTY_MAGIC 0x5401
319 341
@@ -402,6 +424,7 @@ extern int is_ignored(int sig);
402extern int tty_signal(int sig, struct tty_struct *tty); 424extern int tty_signal(int sig, struct tty_struct *tty);
403extern void tty_hangup(struct tty_struct *tty); 425extern void tty_hangup(struct tty_struct *tty);
404extern void tty_vhangup(struct tty_struct *tty); 426extern void tty_vhangup(struct tty_struct *tty);
427extern void tty_vhangup_locked(struct tty_struct *tty);
405extern void tty_vhangup_self(void); 428extern void tty_vhangup_self(void);
406extern void tty_unhangup(struct file *filp); 429extern void tty_unhangup(struct file *filp);
407extern int tty_hung_up_p(struct file *filp); 430extern int tty_hung_up_p(struct file *filp);
@@ -442,6 +465,7 @@ extern void proc_clear_tty(struct task_struct *p);
442extern struct tty_struct *get_current_tty(void); 465extern struct tty_struct *get_current_tty(void);
443extern void tty_default_fops(struct file_operations *fops); 466extern void tty_default_fops(struct file_operations *fops);
444extern struct tty_struct *alloc_tty_struct(void); 467extern struct tty_struct *alloc_tty_struct(void);
468extern void tty_add_file(struct tty_struct *tty, struct file *file);
445extern void free_tty_struct(struct tty_struct *tty); 469extern void free_tty_struct(struct tty_struct *tty);
446extern void initialize_tty_struct(struct tty_struct *tty, 470extern void initialize_tty_struct(struct tty_struct *tty,
447 struct tty_driver *driver, int idx); 471 struct tty_driver *driver, int idx);
@@ -454,6 +478,7 @@ extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty);
454extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty); 478extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty);
455 479
456extern struct mutex tty_mutex; 480extern struct mutex tty_mutex;
481extern spinlock_t tty_files_lock;
457 482
458extern void tty_write_unlock(struct tty_struct *tty); 483extern void tty_write_unlock(struct tty_struct *tty);
459extern int tty_write_lock(struct tty_struct *tty, int ndelay); 484extern int tty_write_lock(struct tty_struct *tty, int ndelay);
@@ -504,6 +529,7 @@ extern void tty_ldisc_enable(struct tty_struct *tty);
504 529
505/* n_tty.c */ 530/* n_tty.c */
506extern struct tty_ldisc_ops tty_ldisc_N_TTY; 531extern struct tty_ldisc_ops tty_ldisc_N_TTY;
532extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops);
507 533
508/* tty_audit.c */ 534/* tty_audit.c */
509#ifdef CONFIG_AUDIT 535#ifdef CONFIG_AUDIT
@@ -538,6 +564,9 @@ static inline void tty_audit_push_task(struct task_struct *tsk,
538} 564}
539#endif 565#endif
540 566
567/* tty_io.c */
568extern int __init tty_init(void);
569
541/* tty_ioctl.c */ 570/* tty_ioctl.c */
542extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, 571extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
543 unsigned int cmd, unsigned long arg); 572 unsigned int cmd, unsigned long arg);
@@ -558,5 +587,54 @@ extern int vt_ioctl(struct tty_struct *tty, struct file *file,
558extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file, 587extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file,
559 unsigned int cmd, unsigned long arg); 588 unsigned int cmd, unsigned long arg);
560 589
590/* tty_mutex.c */
591/* functions for preparation of BKL removal */
592extern void __lockfunc tty_lock(void) __acquires(tty_lock);
593extern void __lockfunc tty_unlock(void) __releases(tty_lock);
594extern struct task_struct *__big_tty_mutex_owner;
595#define tty_locked() (current == __big_tty_mutex_owner)
596
597/*
598 * wait_event_interruptible_tty -- wait for a condition with the tty lock held
599 *
600 * The condition we are waiting for might take a long time to
601 * become true, or might depend on another thread taking the
602 * BTM. In either case, we need to drop the BTM to guarantee
603 * forward progress. This is a leftover from the conversion
604 * from the BKL and should eventually get removed as the BTM
605 * falls out of use.
606 *
607 * Do not use in new code.
608 */
609#define wait_event_interruptible_tty(wq, condition) \
610({ \
611 int __ret = 0; \
612 if (!(condition)) { \
613 __wait_event_interruptible_tty(wq, condition, __ret); \
614 } \
615 __ret; \
616})
617
618#define __wait_event_interruptible_tty(wq, condition, ret) \
619do { \
620 DEFINE_WAIT(__wait); \
621 \
622 for (;;) { \
623 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
624 if (condition) \
625 break; \
626 if (!signal_pending(current)) { \
627 tty_unlock(); \
628 schedule(); \
629 tty_lock(); \
630 continue; \
631 } \
632 ret = -ERESTARTSYS; \
633 break; \
634 } \
635 finish_wait(&wq, &__wait); \
636} while (0)
637
638
561#endif /* __KERNEL__ */ 639#endif /* __KERNEL__ */
562#endif 640#endif