diff options
Diffstat (limited to 'include/linux/tty.h')
| -rw-r--r-- | include/linux/tty.h | 82 |
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 | |||
| 71 | struct tty_bufhead { | 84 | struct 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 | ||
| 171 | struct device; | 185 | struct device; |
| 172 | struct signal_struct; | 186 | struct 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 */ | ||
| 333 | struct 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); | |||
| 402 | extern int tty_signal(int sig, struct tty_struct *tty); | 424 | extern int tty_signal(int sig, struct tty_struct *tty); |
| 403 | extern void tty_hangup(struct tty_struct *tty); | 425 | extern void tty_hangup(struct tty_struct *tty); |
| 404 | extern void tty_vhangup(struct tty_struct *tty); | 426 | extern void tty_vhangup(struct tty_struct *tty); |
| 427 | extern void tty_vhangup_locked(struct tty_struct *tty); | ||
| 405 | extern void tty_vhangup_self(void); | 428 | extern void tty_vhangup_self(void); |
| 406 | extern void tty_unhangup(struct file *filp); | 429 | extern void tty_unhangup(struct file *filp); |
| 407 | extern int tty_hung_up_p(struct file *filp); | 430 | extern int tty_hung_up_p(struct file *filp); |
| @@ -442,6 +465,7 @@ extern void proc_clear_tty(struct task_struct *p); | |||
| 442 | extern struct tty_struct *get_current_tty(void); | 465 | extern struct tty_struct *get_current_tty(void); |
| 443 | extern void tty_default_fops(struct file_operations *fops); | 466 | extern void tty_default_fops(struct file_operations *fops); |
| 444 | extern struct tty_struct *alloc_tty_struct(void); | 467 | extern struct tty_struct *alloc_tty_struct(void); |
| 468 | extern void tty_add_file(struct tty_struct *tty, struct file *file); | ||
| 445 | extern void free_tty_struct(struct tty_struct *tty); | 469 | extern void free_tty_struct(struct tty_struct *tty); |
| 446 | extern void initialize_tty_struct(struct tty_struct *tty, | 470 | extern 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); | |||
| 454 | extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty); | 478 | extern struct tty_struct *tty_pair_get_pty(struct tty_struct *tty); |
| 455 | 479 | ||
| 456 | extern struct mutex tty_mutex; | 480 | extern struct mutex tty_mutex; |
| 481 | extern spinlock_t tty_files_lock; | ||
| 457 | 482 | ||
| 458 | extern void tty_write_unlock(struct tty_struct *tty); | 483 | extern void tty_write_unlock(struct tty_struct *tty); |
| 459 | extern int tty_write_lock(struct tty_struct *tty, int ndelay); | 484 | extern 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 */ |
| 506 | extern struct tty_ldisc_ops tty_ldisc_N_TTY; | 531 | extern struct tty_ldisc_ops tty_ldisc_N_TTY; |
| 532 | extern 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 */ | ||
| 568 | extern int __init tty_init(void); | ||
| 569 | |||
| 541 | /* tty_ioctl.c */ | 570 | /* tty_ioctl.c */ |
| 542 | extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, | 571 | extern 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, | |||
| 558 | extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file, | 587 | extern 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 */ | ||
| 592 | extern void __lockfunc tty_lock(void) __acquires(tty_lock); | ||
| 593 | extern void __lockfunc tty_unlock(void) __releases(tty_lock); | ||
| 594 | extern 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) \ | ||
| 619 | do { \ | ||
| 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 |
