linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / include / linux / tty.h
index 3585883..f45cd74 100644 (file)
@@ -5,14 +5,25 @@
  * 'tty.h' defines some structures used by tty_io.c and some defines.
  */
 
+/*
+ * These constants are also useful for user-level apps (e.g., VC
+ * resizing).
+ */
+#define MIN_NR_CONSOLES 1       /* must be at least 1 */
+#define MAX_NR_CONSOLES        63      /* serial lines start at 64 */
+#define MAX_NR_USER_CONSOLES 63        /* must be root to allocate above this */
+               /* Note: the ioctl VT_GETSTATE does not work for
+                  consoles 16 and higher (since it returns a short) */
+
 #ifdef __KERNEL__
+#include <linux/config.h>
 #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/screen_info.h>
 
 #include <asm/system.h>
 
@@ -46,6 +57,7 @@ struct tty_buffer {
        unsigned char *flag_buf_ptr;
        int used;
        int size;
+       int active;
        int commit;
        int read;
        /* Data points here */
@@ -59,7 +71,6 @@ struct tty_bufhead {
        struct tty_buffer *head;        /* Queue head */
        struct tty_buffer *tail;        /* Active buffer */
        struct tty_buffer *free;        /* Free queue head */
-       int memory_used;                /* Buffer space used excluding free queue */
 };
 /*
  * The pty uses char_buf and flag_buf as a contiguous buffer
@@ -174,7 +185,7 @@ struct tty_struct {
        struct tty_driver *driver;
        int index;
        struct tty_ldisc ldisc;
-       struct mutex termios_mutex;
+       struct semaphore termios_sem;
        struct termios *termios, *termios_locked;
        char name[64];
        int pgrp;
@@ -190,6 +201,7 @@ struct tty_struct {
        struct tty_struct *link;
        struct fasync_struct *fasync;
        struct tty_bufhead buf;
+       int max_flip_cnt;
        int alt_speed;          /* For magic substitution of 38400 bps */
        wait_queue_head_t write_wait;
        wait_queue_head_t read_wait;
@@ -219,8 +231,8 @@ struct tty_struct {
        int canon_data;
        unsigned long canon_head;
        unsigned int canon_column;
-       struct mutex atomic_read_lock;
-       struct mutex atomic_write_lock;
+       struct semaphore atomic_read;
+       struct semaphore atomic_write;
        unsigned char *write_buf;
        int write_cnt;
        spinlock_t read_lock;
@@ -247,6 +259,7 @@ struct tty_struct {
 #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_DONT_FLIP          8       /* Defer buffer flip */
 #define TTY_LDISC              9       /* Line discipline attached */
 #define TTY_HW_COOK_OUT        14      /* Hardware can do output cooking */
 #define TTY_HW_COOK_IN                 15      /* Hardware can do input cooking */
@@ -259,6 +272,7 @@ struct tty_struct {
 extern void tty_write_flush(struct tty_struct *);
 
 extern struct termios tty_std_termios;
+extern int fg_console, last_console, want_console;
 
 extern int kmsg_redirect;
 
@@ -276,9 +290,7 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
 extern int tty_unregister_ldisc(int disc);
 extern int tty_register_driver(struct tty_driver *driver);
 extern int tty_unregister_driver(struct tty_driver *driver);
-extern struct class_device *tty_register_device(struct tty_driver *driver,
-                                               unsigned index,
-                                               struct device *dev);
+extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev);
 extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
 extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
                             int buflen);
@@ -307,7 +319,8 @@ extern void tty_ldisc_put(int);
 extern void tty_wakeup(struct tty_struct *tty);
 extern void tty_ldisc_flush(struct tty_struct *tty);
 
-extern struct mutex tty_mutex;
+struct semaphore;
+extern struct semaphore tty_sem;
 
 /* n_tty.c */
 extern struct tty_ldisc tty_ldisc_N_TTY;
@@ -338,45 +351,5 @@ static inline dev_t tty_devnum(struct tty_struct *tty)
        return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
 }
 
-static inline void proc_clear_tty(struct task_struct *p)
-{
-       spin_lock_irq(&p->sighand->siglock);
-       p->signal->tty = NULL;
-       spin_unlock_irq(&p->sighand->siglock);
-}
-
-static inline
-void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
-{
-       if (tty) {
-               tty->session = tsk->signal->session;
-               tty->pgrp = process_group(tsk);
-       }
-       tsk->signal->tty = tty;
-       tsk->signal->tty_old_pgrp = 0;
-}
-
-static inline
-void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
-{
-       spin_lock_irq(&tsk->sighand->siglock);
-       __proc_set_tty(tsk, tty);
-       spin_unlock_irq(&tsk->sighand->siglock);
-}
-
-static inline struct tty_struct *get_current_tty(void)
-{
-       struct tty_struct *tty;
-       WARN_ON_ONCE(!mutex_is_locked(&tty_mutex));
-       tty = current->signal->tty;
-       /*
-        * session->tty can be changed/cleared from under us, make sure we
-        * issue the load. The obtained pointer, when not NULL, is valid as
-        * long as we hold tty_mutex.
-        */
-       barrier();
-       return tty;
-}
-
 #endif /* __KERNEL__ */
 #endif