Commit 0142e3ff authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] merge vt_struct into vc_data

The vt_struct and vc_data are always allocated together, so there is no need
for a separate vt_struct structure.
Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 64ff3b16
...@@ -275,7 +275,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -275,7 +275,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
*/ */
int paste_selection(struct tty_struct *tty) int paste_selection(struct tty_struct *tty)
{ {
struct vt_struct *vt = (struct vt_struct *) tty->driver_data; struct vc_data *vc = (struct vc_data *)tty->driver_data;
int pasted = 0, count; int pasted = 0, count;
struct tty_ldisc *ld; struct tty_ldisc *ld;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
...@@ -286,7 +286,7 @@ int paste_selection(struct tty_struct *tty) ...@@ -286,7 +286,7 @@ int paste_selection(struct tty_struct *tty)
ld = tty_ldisc_ref_wait(tty); ld = tty_ldisc_ref_wait(tty);
add_wait_queue(&vt->paste_wait, &wait); add_wait_queue(&vc->paste_wait, &wait);
while (sel_buffer && sel_buffer_lth > pasted) { while (sel_buffer && sel_buffer_lth > pasted) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (test_bit(TTY_THROTTLED, &tty->flags)) { if (test_bit(TTY_THROTTLED, &tty->flags)) {
...@@ -298,7 +298,7 @@ int paste_selection(struct tty_struct *tty) ...@@ -298,7 +298,7 @@ int paste_selection(struct tty_struct *tty)
tty->ldisc.receive_buf(tty, sel_buffer + pasted, NULL, count); tty->ldisc.receive_buf(tty, sel_buffer + pasted, NULL, count);
pasted += count; pasted += count;
} }
remove_wait_queue(&vt->paste_wait, &wait); remove_wait_queue(&vc->paste_wait, &wait);
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
......
...@@ -547,7 +547,7 @@ static void hide_cursor(struct vc_data *vc) ...@@ -547,7 +547,7 @@ static void hide_cursor(struct vc_data *vc)
static void set_cursor(struct vc_data *vc) static void set_cursor(struct vc_data *vc)
{ {
if (!IS_FG(vc) || console_blanked || if (!IS_FG(vc) || console_blanked ||
vc->vc_vt->vc_mode == KD_GRAPHICS) vc->vc_mode == KD_GRAPHICS)
return; return;
if (vc->vc_deccm) { if (vc->vc_deccm) {
if (vc == sel_cons) if (vc == sel_cons)
...@@ -642,7 +642,7 @@ void redraw_screen(struct vc_data *vc, int is_switch) ...@@ -642,7 +642,7 @@ void redraw_screen(struct vc_data *vc, int is_switch)
update_attr(vc); update_attr(vc);
clear_buffer_attributes(vc); clear_buffer_attributes(vc);
} }
if (update && vt_cons[vc->vc_num]->vc_mode != KD_GRAPHICS) if (update && vc->vc_mode != KD_GRAPHICS)
do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
} }
set_cursor(vc); set_cursor(vc);
...@@ -695,7 +695,6 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ ...@@ -695,7 +695,6 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
return -ENXIO; return -ENXIO;
if (!vc_cons[currcons].d) { if (!vc_cons[currcons].d) {
struct vc_data *vc; struct vc_data *vc;
long p, q;
/* prevent users from taking too much memory */ /* prevent users from taking too much memory */
if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE)) if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE))
...@@ -707,24 +706,20 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ ...@@ -707,24 +706,20 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
/* although the numbers above are not valid since long ago, the /* although the numbers above are not valid since long ago, the
point is still up-to-date and the comment still has its value point is still up-to-date and the comment still has its value
even if only as a historical artifact. --mj, July 1998 */ even if only as a historical artifact. --mj, July 1998 */
p = (long) kmalloc(sizeof(struct vc_data) + sizeof(struct vt_struct), GFP_KERNEL); vc = kmalloc(sizeof(struct vc_data), GFP_KERNEL);
if (!p) if (!vc)
return -ENOMEM; return -ENOMEM;
memset((void *)p, 0, sizeof(struct vc_data) + sizeof(struct vt_struct)); memset(vc, 0, sizeof(*vc));
vc_cons[currcons].d = vc = (struct vc_data *)p; vc_cons[currcons].d = vc;
vt_cons[currcons] = (struct vt_struct *)(p+sizeof(struct vc_data));
vc_cons[currcons].d->vc_vt = vt_cons[currcons];
visual_init(vc, currcons, 1); visual_init(vc, currcons, 1);
if (!*vc->vc_uni_pagedir_loc) if (!*vc->vc_uni_pagedir_loc)
con_set_default_unimap(vc); con_set_default_unimap(vc);
q = (long)kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL);
if (!q) { if (!vc->vc_screenbuf) {
kfree((char *) p); kfree(vc);
vc_cons[currcons].d = NULL; vc_cons[currcons].d = NULL;
vt_cons[currcons] = NULL;
return -ENOMEM; return -ENOMEM;
} }
vc->vc_screenbuf = (unsigned short *)q;
vc->vc_kmalloced = 1; vc->vc_kmalloced = 1;
vc_init(vc, vc->vc_rows, vc->vc_cols, 1); vc_init(vc, vc->vc_rows, vc->vc_cols, 1);
...@@ -742,7 +737,7 @@ inline int resize_screen(struct vc_data *vc, int width, int height) ...@@ -742,7 +737,7 @@ inline int resize_screen(struct vc_data *vc, int width, int height)
/* Resizes the resolution of the display adapater */ /* Resizes the resolution of the display adapater */
int err = 0; int err = 0;
if (vt_cons[vc->vc_num]->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize) if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize)
err = vc->vc_sw->con_resize(vc, width, height); err = vc->vc_sw->con_resize(vc, width, height);
return err; return err;
} }
...@@ -1906,7 +1901,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co ...@@ -1906,7 +1901,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
int c, tc, ok, n = 0, draw_x = -1; int c, tc, ok, n = 0, draw_x = -1;
unsigned int currcons; unsigned int currcons;
unsigned long draw_from = 0, draw_to = 0; unsigned long draw_from = 0, draw_to = 0;
struct vt_struct *vt;
struct vc_data *vc; struct vc_data *vc;
u16 himask, charmask; u16 himask, charmask;
const unsigned char *orig_buf = NULL; const unsigned char *orig_buf = NULL;
...@@ -1918,14 +1912,14 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co ...@@ -1918,14 +1912,14 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
might_sleep(); might_sleep();
acquire_console_sem(); acquire_console_sem();
vt = tty->driver_data; vc = tty->driver_data;
if (vt == NULL) { if (vc == NULL) {
printk(KERN_ERR "vt: argh, driver_data is NULL !\n"); printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
release_console_sem(); release_console_sem();
return 0; return 0;
} }
currcons = vt->vc_num; currcons = vc->vc_num;
if (!vc_cons_allocated(currcons)) { if (!vc_cons_allocated(currcons)) {
/* could this happen? */ /* could this happen? */
static int error = 0; static int error = 0;
...@@ -1936,7 +1930,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co ...@@ -1936,7 +1930,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
release_console_sem(); release_console_sem();
return 0; return 0;
} }
vc = vc_cons[currcons].d;
release_console_sem(); release_console_sem();
orig_buf = buf; orig_buf = buf;
...@@ -1951,8 +1944,8 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co ...@@ -1951,8 +1944,8 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
acquire_console_sem(); acquire_console_sem();
vt = tty->driver_data; vc = tty->driver_data;
if (vt == NULL) { if (vc == NULL) {
printk(KERN_ERR "vt: argh, driver_data _became_ NULL !\n"); printk(KERN_ERR "vt: argh, driver_data _became_ NULL !\n");
release_console_sem(); release_console_sem();
goto out; goto out;
...@@ -2117,7 +2110,7 @@ static void console_callback(void *ignored) ...@@ -2117,7 +2110,7 @@ static void console_callback(void *ignored)
if (scrollback_delta) { if (scrollback_delta) {
struct vc_data *vc = vc_cons[fg_console].d; struct vc_data *vc = vc_cons[fg_console].d;
clear_selection(); clear_selection();
if (vt_cons[vc->vc_num]->vc_mode == KD_TEXT) if (vc->vc_mode == KD_TEXT)
vc->vc_sw->con_scrolldelta(vc, scrollback_delta); vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
scrollback_delta = 0; scrollback_delta = 0;
} }
...@@ -2171,7 +2164,7 @@ void vt_console_print(struct console *co, const char *b, unsigned count) ...@@ -2171,7 +2164,7 @@ void vt_console_print(struct console *co, const char *b, unsigned count)
goto quit; goto quit;
} }
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT) if (vc->vc_mode != KD_TEXT)
goto quit; goto quit;
/* undraw cursor first */ /* undraw cursor first */
...@@ -2392,9 +2385,9 @@ static void con_throttle(struct tty_struct *tty) ...@@ -2392,9 +2385,9 @@ static void con_throttle(struct tty_struct *tty)
static void con_unthrottle(struct tty_struct *tty) static void con_unthrottle(struct tty_struct *tty)
{ {
struct vt_struct *vt = tty->driver_data; struct vc_data *vc = tty->driver_data;
wake_up_interruptible(&vt->paste_wait); wake_up_interruptible(&vc->paste_wait);
} }
/* /*
...@@ -2429,16 +2422,16 @@ static void con_start(struct tty_struct *tty) ...@@ -2429,16 +2422,16 @@ static void con_start(struct tty_struct *tty)
static void con_flush_chars(struct tty_struct *tty) static void con_flush_chars(struct tty_struct *tty)
{ {
struct vt_struct *vt; struct vc_data *vc;
if (in_interrupt()) /* from flush_to_ldisc */ if (in_interrupt()) /* from flush_to_ldisc */
return; return;
/* if we race with con_close(), vt may be null */ /* if we race with con_close(), vt may be null */
acquire_console_sem(); acquire_console_sem();
vt = tty->driver_data; vc = tty->driver_data;
if (vt) if (vc)
set_cursor(vc_cons[vt->vc_num].d); set_cursor(vc);
release_console_sem(); release_console_sem();
} }
...@@ -2455,8 +2448,7 @@ static int con_open(struct tty_struct *tty, struct file *filp) ...@@ -2455,8 +2448,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
ret = vc_allocate(currcons); ret = vc_allocate(currcons);
if (ret == 0) { if (ret == 0) {
struct vc_data *vc = vc_cons[currcons].d; struct vc_data *vc = vc_cons[currcons].d;
vt_cons[currcons]->vc_num = currcons; tty->driver_data = vc;
tty->driver_data = vt_cons[currcons];
vc->vc_tty = tty; vc->vc_tty = tty;
if (!tty->winsize.ws_row && !tty->winsize.ws_col) { if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
...@@ -2484,11 +2476,10 @@ static void con_close(struct tty_struct *tty, struct file *filp) ...@@ -2484,11 +2476,10 @@ static void con_close(struct tty_struct *tty, struct file *filp)
down(&tty_sem); down(&tty_sem);
acquire_console_sem(); acquire_console_sem();
if (tty && tty->count == 1) { if (tty && tty->count == 1) {
struct vt_struct *vt; struct vc_data *vc = tty->driver_data;
vt = tty->driver_data; if (vc)
if (vt) vc->vc_tty = NULL;
vc_cons[vt->vc_num].d->vc_tty = NULL;
tty->driver_data = NULL; tty->driver_data = NULL;
release_console_sem(); release_console_sem();
vcs_remove_devfs(tty); vcs_remove_devfs(tty);
...@@ -2524,7 +2515,7 @@ static void vc_init(struct vc_data *vc, unsigned int rows, ...@@ -2524,7 +2515,7 @@ static void vc_init(struct vc_data *vc, unsigned int rows,
vc->vc_def_color = 0x07; /* white */ vc->vc_def_color = 0x07; /* white */
vc->vc_ulcolor = 0x0f; /* bold white */ vc->vc_ulcolor = 0x0f; /* bold white */
vc->vc_halfcolor = 0x08; /* grey */ vc->vc_halfcolor = 0x08; /* grey */
init_waitqueue_head(&vt_cons[vc->vc_num]->paste_wait); init_waitqueue_head(&vc->paste_wait);
reset_terminal(vc, do_clear); reset_terminal(vc, do_clear);
} }
...@@ -2561,11 +2552,7 @@ static int __init con_init(void) ...@@ -2561,11 +2552,7 @@ static int __init con_init(void)
* kmalloc is not running yet - we use the bootmem allocator. * kmalloc is not running yet - we use the bootmem allocator.
*/ */
for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) { for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
vc_cons[currcons].d = vc = (struct vc_data *) vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data));
alloc_bootmem(sizeof(struct vc_data));
vt_cons[currcons] = (struct vt_struct *)
alloc_bootmem(sizeof(struct vt_struct));
vc_cons[currcons].d->vc_vt = vt_cons[currcons];
visual_init(vc, currcons, 1); visual_init(vc, currcons, 1);
vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size); vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size);
vc->vc_kmalloced = 0; vc->vc_kmalloced = 0;
...@@ -2800,7 +2787,7 @@ void do_blank_screen(int entering_gfx) ...@@ -2800,7 +2787,7 @@ void do_blank_screen(int entering_gfx)
} }
/* don't blank graphics */ /* don't blank graphics */
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT) { if (vc->vc_mode != KD_TEXT) {
console_blanked = fg_console + 1; console_blanked = fg_console + 1;
return; return;
} }
...@@ -2847,7 +2834,7 @@ void do_unblank_screen(int leaving_gfx) ...@@ -2847,7 +2834,7 @@ void do_unblank_screen(int leaving_gfx)
return; return;
} }
vc = vc_cons[fg_console].d; vc = vc_cons[fg_console].d;
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT) if (vc->vc_mode != KD_TEXT)
return; /* but leave console_blanked != 0 */ return; /* but leave console_blanked != 0 */
if (blankinterval) { if (blankinterval) {
...@@ -2898,7 +2885,7 @@ void poke_blanked_console(void) ...@@ -2898,7 +2885,7 @@ void poke_blanked_console(void)
del_timer(&console_timer); del_timer(&console_timer);
blank_timer_expired = 0; blank_timer_expired = 0;
if (ignore_poke || !vt_cons[fg_console] || vt_cons[fg_console]->vc_mode == KD_GRAPHICS) if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode == KD_GRAPHICS)
return; return;
if (console_blanked) if (console_blanked)
unblank_screen(); unblank_screen();
...@@ -2916,7 +2903,7 @@ void set_palette(struct vc_data *vc) ...@@ -2916,7 +2903,7 @@ void set_palette(struct vc_data *vc)
{ {
WARN_CONSOLE_UNLOCKED(); WARN_CONSOLE_UNLOCKED();
if (vt_cons[vc->vc_num]->vc_mode != KD_GRAPHICS) if (vc->vc_mode != KD_GRAPHICS)
vc->vc_sw->con_set_palette(vc, color_table); vc->vc_sw->con_set_palette(vc, color_table);
} }
...@@ -3009,7 +2996,7 @@ int con_font_get(struct vc_data *vc, struct console_font_op *op) ...@@ -3009,7 +2996,7 @@ int con_font_get(struct vc_data *vc, struct console_font_op *op)
int rc = -EINVAL; int rc = -EINVAL;
int c; int c;
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT) if (vc->vc_mode != KD_TEXT)
return -EINVAL; return -EINVAL;
if (op->data) { if (op->data) {
...@@ -3064,7 +3051,7 @@ int con_font_set(struct vc_data *vc, struct console_font_op *op) ...@@ -3064,7 +3051,7 @@ int con_font_set(struct vc_data *vc, struct console_font_op *op)
int rc = -EINVAL; int rc = -EINVAL;
int size; int size;
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT) if (vc->vc_mode != KD_TEXT)
return -EINVAL; return -EINVAL;
if (!op->data) if (!op->data)
return -EINVAL; return -EINVAL;
...@@ -3122,7 +3109,7 @@ int con_font_default(struct vc_data *vc, struct console_font_op *op) ...@@ -3122,7 +3109,7 @@ int con_font_default(struct vc_data *vc, struct console_font_op *op)
char *s = name; char *s = name;
int rc; int rc;
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT) if (vc->vc_mode != KD_TEXT)
return -EINVAL; return -EINVAL;
if (!op->data) if (!op->data)
...@@ -3150,7 +3137,7 @@ int con_font_copy(struct vc_data *vc, struct console_font_op *op) ...@@ -3150,7 +3137,7 @@ int con_font_copy(struct vc_data *vc, struct console_font_op *op)
int con = op->height; int con = op->height;
int rc; int rc;
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT) if (vc->vc_mode != KD_TEXT)
return -EINVAL; return -EINVAL;
acquire_console_sem(); acquire_console_sem();
...@@ -3262,7 +3249,6 @@ EXPORT_SYMBOL(vc_resize); ...@@ -3262,7 +3249,6 @@ EXPORT_SYMBOL(vc_resize);
EXPORT_SYMBOL(fg_console); EXPORT_SYMBOL(fg_console);
EXPORT_SYMBOL(console_blank_hook); EXPORT_SYMBOL(console_blank_hook);
EXPORT_SYMBOL(console_blanked); EXPORT_SYMBOL(console_blanked);
EXPORT_SYMBOL(vt_cons);
EXPORT_SYMBOL(vc_cons); EXPORT_SYMBOL(vc_cons);
#ifndef VT_SINGLE_DRIVER #ifndef VT_SINGLE_DRIVER
EXPORT_SYMBOL(take_over_console); EXPORT_SYMBOL(take_over_console);
......
...@@ -52,8 +52,6 @@ extern struct tty_driver *console_driver; ...@@ -52,8 +52,6 @@ extern struct tty_driver *console_driver;
* to the current console is done by the main ioctl code. * to the current console is done by the main ioctl code.
*/ */
struct vt_struct *vt_cons[MAX_NR_CONSOLES];
/* Keyboard type: Default is KB_101, but can be set by machine /* Keyboard type: Default is KB_101, but can be set by machine
* specific code. * specific code.
*/ */
...@@ -365,8 +363,7 @@ do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, struct vc_ ...@@ -365,8 +363,7 @@ do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, struct vc_
int vt_ioctl(struct tty_struct *tty, struct file * file, int vt_ioctl(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct vt_struct *vt = (struct vt_struct *)tty->driver_data; struct vc_data *vc = (struct vc_data *)tty->driver_data;
struct vc_data *vc = vc_cons[vt->vc_num].d;
struct console_font_op op; /* used in multiple places here */ struct console_font_op op; /* used in multiple places here */
struct kbd_struct * kbd; struct kbd_struct * kbd;
unsigned int console; unsigned int console;
...@@ -374,7 +371,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -374,7 +371,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
void __user *up = (void __user *)arg; void __user *up = (void __user *)arg;
int i, perm; int i, perm;
console = vt->vc_num; console = vc->vc_num;
if (!vc_cons_allocated(console)) /* impossible? */ if (!vc_cons_allocated(console)) /* impossible? */
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
...@@ -487,9 +484,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -487,9 +484,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
default: default:
return -EINVAL; return -EINVAL;
} }
if (vt_cons[console]->vc_mode == (unsigned char) arg) if (vc->vc_mode == (unsigned char) arg)
return 0; return 0;
vt_cons[console]->vc_mode = (unsigned char) arg; vc->vc_mode = (unsigned char) arg;
if (console != fg_console) if (console != fg_console)
return 0; return 0;
/* /*
...@@ -504,7 +501,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -504,7 +501,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
return 0; return 0;
case KDGETMODE: case KDGETMODE:
ucval = vt_cons[console]->vc_mode; ucval = vc->vc_mode;
goto setint; goto setint;
case KDMAPDISP: case KDMAPDISP:
...@@ -667,12 +664,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -667,12 +664,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS)
return -EINVAL; return -EINVAL;
acquire_console_sem(); acquire_console_sem();
vt_cons[console]->vt_mode = tmp; vc->vt_mode = tmp;
/* the frsig is ignored, so we set it to 0 */ /* the frsig is ignored, so we set it to 0 */
vt_cons[console]->vt_mode.frsig = 0; vc->vt_mode.frsig = 0;
vt_cons[console]->vt_pid = current->pid; vc->vt_pid = current->pid;
/* no switch is required -- saw@shade.msu.ru */ /* no switch is required -- saw@shade.msu.ru */
vt_cons[console]->vt_newvt = -1; vc->vt_newvt = -1;
release_console_sem(); release_console_sem();
return 0; return 0;
} }
...@@ -683,7 +680,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -683,7 +680,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
int rc; int rc;
acquire_console_sem(); acquire_console_sem();
memcpy(&tmp, &vt_cons[console]->vt_mode, sizeof(struct vt_mode)); memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode));
release_console_sem(); release_console_sem();
rc = copy_to_user(up, &tmp, sizeof(struct vt_mode)); rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
...@@ -761,31 +758,29 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -761,31 +758,29 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case VT_RELDISP: case VT_RELDISP:
if (!perm) if (!perm)
return -EPERM; return -EPERM;
if (vt_cons[console]->vt_mode.mode != VT_PROCESS) if (vc->vt_mode.mode != VT_PROCESS)
return -EINVAL; return -EINVAL;
/* /*
* Switching-from response * Switching-from response
*/ */
if (vt_cons[console]->vt_newvt >= 0) if (vc->vt_newvt >= 0) {
{
if (arg == 0) if (arg == 0)
/* /*
* Switch disallowed, so forget we were trying * Switch disallowed, so forget we were trying
* to do it. * to do it.
*/ */
vt_cons[console]->vt_newvt = -1; vc->vt_newvt = -1;
else else {
{
/* /*
* The current vt has been released, so * The current vt has been released, so
* complete the switch. * complete the switch.
*/ */
int newvt; int newvt;
acquire_console_sem(); acquire_console_sem();
newvt = vt_cons[console]->vt_newvt; newvt = vc->vt_newvt;
vt_cons[console]->vt_newvt = -1; vc->vt_newvt = -1;
i = vc_allocate(newvt); i = vc_allocate(newvt);
if (i) { if (i) {
release_console_sem(); release_console_sem();
...@@ -1057,17 +1052,15 @@ int vt_waitactive(int vt) ...@@ -1057,17 +1052,15 @@ int vt_waitactive(int vt)
void reset_vc(struct vc_data *vc) void reset_vc(struct vc_data *vc)
{ {
struct vt_struct *vt = vt_cons[vc->vc_num]; vc->vc_mode = KD_TEXT;
vt->vc_mode = KD_TEXT;
kbd_table[vc->vc_num].kbdmode = VC_XLATE; kbd_table[vc->vc_num].kbdmode = VC_XLATE;
vt->vt_mode.mode = VT_AUTO; vc->vt_mode.mode = VT_AUTO;
vt->vt_mode.waitv = 0; vc->vt_mode.waitv = 0;
vt->vt_mode.relsig = 0; vc->vt_mode.relsig = 0;
vt->vt_mode.acqsig = 0; vc->vt_mode.acqsig = 0;
vt->vt_mode.frsig = 0; vc->vt_mode.frsig = 0;
vt->vt_pid = -1; vc->vt_pid = -1;
vt->vt_newvt = -1; vc->vt_newvt = -1;
if (!in_interrupt()) /* Via keyboard.c:SAK() - akpm */ if (!in_interrupt()) /* Via keyboard.c:SAK() - akpm */
reset_palette(vc); reset_palette(vc);
} }
...@@ -1077,7 +1070,6 @@ void reset_vc(struct vc_data *vc) ...@@ -1077,7 +1070,6 @@ void reset_vc(struct vc_data *vc)
*/ */
void complete_change_console(struct vc_data *vc) void complete_change_console(struct vc_data *vc)
{ {
unsigned int new_console = vc->vc_num;
unsigned char old_vc_mode; unsigned char old_vc_mode;
last_console = fg_console; last_console = fg_console;
...@@ -1087,7 +1079,7 @@ void complete_change_console(struct vc_data *vc) ...@@ -1087,7 +1079,7 @@ void complete_change_console(struct vc_data *vc)
* KD_TEXT mode or vice versa, which means we need to blank or * KD_TEXT mode or vice versa, which means we need to blank or
* unblank the screen later. * unblank the screen later.
*/ */
old_vc_mode = vt_cons[fg_console]->vc_mode; old_vc_mode = vc_cons[fg_console].d->vc_mode;
switch_screen(vc); switch_screen(vc);
/* /*
...@@ -1100,9 +1092,8 @@ void complete_change_console(struct vc_data *vc) ...@@ -1100,9 +1092,8 @@ void complete_change_console(struct vc_data *vc)
* To account for this we duplicate this code below only if the * To account for this we duplicate this code below only if the
* controlling process is gone and we've called reset_vc. * controlling process is gone and we've called reset_vc.
*/ */
if (old_vc_mode != vt_cons[new_console]->vc_mode) if (old_vc_mode != vc->vc_mode) {
{ if (vc->vc_mode == KD_TEXT)
if (vt_cons[new_console]->vc_mode == KD_TEXT)
do_unblank_screen(1); do_unblank_screen(1);
else else
do_blank_screen(1); do_blank_screen(1);
...@@ -1113,17 +1104,13 @@ void complete_change_console(struct vc_data *vc) ...@@ -1113,17 +1104,13 @@ void complete_change_console(struct vc_data *vc)
* telling it that it has acquired. Also check if it has died and * telling it that it has acquired. Also check if it has died and
* clean up (similar to logic employed in change_console()) * clean up (similar to logic employed in change_console())
*/ */
if (vt_cons[new_console]->vt_mode.mode == VT_PROCESS) if (vc->vt_mode.mode == VT_PROCESS) {
{
/* /*
* Send the signal as privileged - kill_proc() will * Send the signal as privileged - kill_proc() will
* tell us if the process has gone or something else * tell us if the process has gone or something else
* is awry * is awry
*/ */
if (kill_proc(vt_cons[new_console]->vt_pid, if (kill_proc(vc->vt_pid, vc->vt_mode.acqsig, 1) != 0) {
vt_cons[new_console]->vt_mode.acqsig,
1) != 0)
{
/* /*
* The controlling process has died, so we revert back to * The controlling process has died, so we revert back to
* normal operation. In this case, we'll also change back * normal operation. In this case, we'll also change back
...@@ -1135,9 +1122,8 @@ void complete_change_console(struct vc_data *vc) ...@@ -1135,9 +1122,8 @@ void complete_change_console(struct vc_data *vc)
*/ */
reset_vc(vc); reset_vc(vc);
if (old_vc_mode != vt_cons[new_console]->vc_mode) if (old_vc_mode != vc->vc_mode) {
{ if (vc->vc_mode == KD_TEXT)
if (vt_cons[new_console]->vc_mode == KD_TEXT)
do_unblank_screen(1); do_unblank_screen(1);
else else
do_blank_screen(1); do_blank_screen(1);
...@@ -1157,6 +1143,8 @@ void complete_change_console(struct vc_data *vc) ...@@ -1157,6 +1143,8 @@ void complete_change_console(struct vc_data *vc)
*/ */
void change_console(struct vc_data *new_vc) void change_console(struct vc_data *new_vc)
{ {
struct vc_data *vc;
if (!new_vc || new_vc->vc_num == fg_console || vt_dont_switch) if (!new_vc || new_vc->vc_num == fg_console || vt_dont_switch)
return; return;
...@@ -1175,23 +1163,20 @@ void change_console(struct vc_data *new_vc) ...@@ -1175,23 +1163,20 @@ void change_console(struct vc_data *new_vc)
* the user waits just the right amount of time :-) and revert the * the user waits just the right amount of time :-) and revert the
* vt to auto control. * vt to auto control.
*/ */
if (vt_cons[fg_console]->vt_mode.mode == VT_PROCESS) vc = vc_cons[fg_console].d;
{ if (vc->vt_mode.mode == VT_PROCESS) {
/* /*
* Send the signal as privileged - kill_proc() will * Send the signal as privileged - kill_proc() will
* tell us if the process has gone or something else * tell us if the process has gone or something else
* is awry * is awry
*/ */
if (kill_proc(vt_cons[fg_console]->vt_pid, if (kill_proc(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) {
vt_cons[fg_console]->vt_mode.relsig,
1) == 0)
{
/* /*
* It worked. Mark the vt to switch to and * It worked. Mark the vt to switch to and
* return. The process needs to send us a * return. The process needs to send us a
* VT_RELDISP ioctl to complete the switch. * VT_RELDISP ioctl to complete the switch.
*/ */
vt_cons[fg_console]->vt_newvt = new_vc->vc_num; vc->vt_newvt = new_vc->vc_num;
return; return;
} }
...@@ -1204,7 +1189,7 @@ void change_console(struct vc_data *new_vc) ...@@ -1204,7 +1189,7 @@ void change_console(struct vc_data *new_vc)
* this outside of VT_PROCESS but there is no single process * this outside of VT_PROCESS but there is no single process
* to account for and tracking tty count may be undesirable. * to account for and tracking tty count may be undesirable.
*/ */
reset_vc(vc_cons[fg_console].d); reset_vc(vc);
/* /*
* Fall through to normal (VT_AUTO) handling of the switch... * Fall through to normal (VT_AUTO) handling of the switch...
...@@ -1214,7 +1199,7 @@ void change_console(struct vc_data *new_vc) ...@@ -1214,7 +1199,7 @@ void change_console(struct vc_data *new_vc)
/* /*
* Ignore all switches in KD_GRAPHICS+VT_AUTO mode * Ignore all switches in KD_GRAPHICS+VT_AUTO mode
*/ */
if (vt_cons[fg_console]->vc_mode == KD_GRAPHICS) if (vc->vc_mode == KD_GRAPHICS)
return; return;
complete_change_console(new_vc); complete_change_console(new_vc);
......
...@@ -203,7 +203,7 @@ static irqreturn_t fb_vbl_detect(int irq, void *dummy, struct pt_regs *fp) ...@@ -203,7 +203,7 @@ static irqreturn_t fb_vbl_detect(int irq, void *dummy, struct pt_regs *fp)
static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info) static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
{ {
return (info->state != FBINFO_STATE_RUNNING || return (info->state != FBINFO_STATE_RUNNING ||
vt_cons[vc->vc_num]->vc_mode != KD_TEXT); vc->vc_mode != KD_TEXT);
} }
static inline int get_color(struct vc_data *vc, struct fb_info *info, static inline int get_color(struct vc_data *vc, struct fb_info *info,
...@@ -456,7 +456,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, ...@@ -456,7 +456,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
erase, erase,
vc->vc_size_row * logo_lines); vc->vc_size_row * logo_lines);
if (CON_IS_VISIBLE(vc) && vt_cons[vc->vc_num]->vc_mode == KD_TEXT) { if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
fbcon_clear_margins(vc, 0); fbcon_clear_margins(vc, 0);
update_screen(vc); update_screen(vc);
} }
...@@ -2209,7 +2209,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, ...@@ -2209,7 +2209,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
} }
} }
} else if (CON_IS_VISIBLE(vc) } else if (CON_IS_VISIBLE(vc)
&& vt_cons[vc->vc_num]->vc_mode == KD_TEXT) { && vc->vc_mode == KD_TEXT) {
fbcon_clear_margins(vc, 0); fbcon_clear_margins(vc, 0);
update_screen(vc); update_screen(vc);
} }
...@@ -2436,7 +2436,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines) ...@@ -2436,7 +2436,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
if (softback_top) { if (softback_top) {
if (vc->vc_num != fg_console) if (vc->vc_num != fg_console)
return 0; return 0;
if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT || !lines) if (vc->vc_mode != KD_TEXT || !lines)
return 0; return 0;
if (logo_shown >= 0) { if (logo_shown >= 0) {
struct vc_data *conp2 = vc_cons[logo_shown].d; struct vc_data *conp2 = vc_cons[logo_shown].d;
...@@ -2553,11 +2553,11 @@ static void fbcon_modechanged(struct fb_info *info) ...@@ -2553,11 +2553,11 @@ static void fbcon_modechanged(struct fb_info *info)
struct display *p; struct display *p;
int rows, cols; int rows, cols;
if (!ops || ops->currcon < 0 || vt_cons[ops->currcon]->vc_mode != if (!ops || ops->currcon < 0)
KD_TEXT || registered_fb[con2fb_map[ops->currcon]] != info)
return; return;
vc = vc_cons[ops->currcon].d; vc = vc_cons[ops->currcon].d;
if (vc->vc_mode != KD_TEXT || registered_fb[con2fb_map[ops->currcon]] != info)
return;
p = &fb_display[vc->vc_num]; p = &fb_display[vc->vc_num];
...@@ -2639,17 +2639,15 @@ static int fbcon_fb_registered(int idx) ...@@ -2639,17 +2639,15 @@ static int fbcon_fb_registered(int idx)
static void fbcon_fb_blanked(struct fb_info *info, int blank) static void fbcon_fb_blanked(struct fb_info *info, int blank)
{ {
struct fbcon_ops *ops = info->fbcon_par; struct fbcon_ops *ops = info->fbcon_par;
int valid = 1;
if (!ops || ops->currcon < 0 ||
vt_cons[ops->currcon]->vc_mode != KD_TEXT ||
registered_fb[con2fb_map[ops->currcon]] != info)
valid = 0;
if (valid) {
struct vc_data *vc; struct vc_data *vc;
if (!ops || ops->currcon < 0)
return;
vc = vc_cons[ops->currcon].d; vc = vc_cons[ops->currcon].d;
if (vc->vc_mode != KD_TEXT ||
registered_fb[con2fb_map[ops->currcon]] != info)
return;
if (CON_IS_VISIBLE(vc)) { if (CON_IS_VISIBLE(vc)) {
if (blank) if (blank)
...@@ -2658,7 +2656,6 @@ static void fbcon_fb_blanked(struct fb_info *info, int blank) ...@@ -2658,7 +2656,6 @@ static void fbcon_fb_blanked(struct fb_info *info, int blank)
do_unblank_screen(0); do_unblank_screen(0);
} }
ops->blank_state = blank; ops->blank_state = blank;
}
} }
static int fbcon_event_notify(struct notifier_block *self, static int fbcon_event_notify(struct notifier_block *self,
......
...@@ -87,13 +87,12 @@ static int sticon_set_palette(struct vc_data *c, unsigned char *table) ...@@ -87,13 +87,12 @@ static int sticon_set_palette(struct vc_data *c, unsigned char *table)
static void sticon_putc(struct vc_data *conp, int c, int ypos, int xpos) static void sticon_putc(struct vc_data *conp, int c, int ypos, int xpos)
{ {
int unit = conp->vc_num;
int redraw_cursor = 0; int redraw_cursor = 0;
if (vga_is_gfx || console_blanked) if (vga_is_gfx || console_blanked)
return; return;
if (vt_cons[unit]->vc_mode != KD_TEXT) if (conp->vc_mode != KD_TEXT)
return; return;
#if 0 #if 0
if ((p->cursor_x == xpos) && (p->cursor_y == ypos)) { if ((p->cursor_x == xpos) && (p->cursor_y == ypos)) {
...@@ -111,13 +110,12 @@ static void sticon_putc(struct vc_data *conp, int c, int ypos, int xpos) ...@@ -111,13 +110,12 @@ static void sticon_putc(struct vc_data *conp, int c, int ypos, int xpos)
static void sticon_putcs(struct vc_data *conp, const unsigned short *s, static void sticon_putcs(struct vc_data *conp, const unsigned short *s,
int count, int ypos, int xpos) int count, int ypos, int xpos)
{ {
int unit = conp->vc_num;
int redraw_cursor = 0; int redraw_cursor = 0;
if (vga_is_gfx || console_blanked) if (vga_is_gfx || console_blanked)
return; return;
if (vt_cons[unit]->vc_mode != KD_TEXT) if (conp->vc_mode != KD_TEXT)
return; return;
#if 0 #if 0
......
...@@ -505,7 +505,7 @@ void sun3fb_palette(int enter) ...@@ -505,7 +505,7 @@ void sun3fb_palette(int enter)
if (fb->restore_palette) { if (fb->restore_palette) {
if (enter) if (enter)
fb->restore_palette(fb); fb->restore_palette(fb);
else if (vt_cons[i]->vc_mode != KD_GRAPHICS) else if (vc_cons[i].d->vc_mode != KD_GRAPHICS)
vc_cons[i].d->vc_sw->con_set_palette(vc_cons[i].d, color_table); vc_cons[i].d->vc_sw->con_set_palette(vc_cons[i].d, color_table);
} }
} }
......
...@@ -1597,7 +1597,7 @@ static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar ...@@ -1597,7 +1597,7 @@ static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar
struct console_font_op op; struct console_font_op op;
struct console_font_op32 __user *fontop = compat_ptr(arg); struct console_font_op32 __user *fontop = compat_ptr(arg);
int perm = vt_check(file), i; int perm = vt_check(file), i;
struct vt_struct *vt; struct vc_data *vc;
if (perm < 0) return perm; if (perm < 0) return perm;
...@@ -1607,9 +1607,10 @@ static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar ...@@ -1607,9 +1607,10 @@ static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar
return -EPERM; return -EPERM;
op.data = compat_ptr(((struct console_font_op32 *)&op)->data); op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
op.flags |= KD_FONT_FLAG_OLD; op.flags |= KD_FONT_FLAG_OLD;
vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data; vc = ((struct tty_struct *)file->private_data)->driver_data;
i = con_font_op(vc_cons[vt->vc_num].d, &op); i = con_font_op(vc, &op);
if (i) return i; if (i)
return i;
((struct console_font_op32 *)&op)->data = (unsigned long)op.data; ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
if (copy_to_user(fontop, &op, sizeof(struct console_font_op32))) if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
return -EFAULT; return -EFAULT;
......
...@@ -26,6 +26,7 @@ struct vc_data { ...@@ -26,6 +26,7 @@ struct vc_data {
const struct consw *vc_sw; const struct consw *vc_sw;
unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */ unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */
unsigned int vc_screenbuf_size; unsigned int vc_screenbuf_size;
unsigned char vc_mode; /* KD_TEXT, ... */
/* attributes for all characters on screen */ /* attributes for all characters on screen */
unsigned char vc_attr; /* Current attributes */ unsigned char vc_attr; /* Current attributes */
unsigned char vc_def_color; /* Default colors */ unsigned char vc_def_color; /* Default colors */
...@@ -48,6 +49,11 @@ struct vc_data { ...@@ -48,6 +49,11 @@ struct vc_data {
unsigned int vc_state; /* Escape sequence parser state */ unsigned int vc_state; /* Escape sequence parser state */
unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
struct tty_struct *vc_tty; /* TTY we are attached to */ struct tty_struct *vc_tty; /* TTY we are attached to */
/* data for manual vt switching */
struct vt_mode vt_mode;
int vt_pid;
int vt_newvt;
wait_queue_head_t paste_wait;
/* mode flags */ /* mode flags */
unsigned int vc_charset : 1; /* Character set G0 / G1 */ unsigned int vc_charset : 1; /* Character set G0 / G1 */
unsigned int vc_s_charset : 1; /* Saved character set */ unsigned int vc_s_charset : 1; /* Saved character set */
...@@ -89,7 +95,6 @@ struct vc_data { ...@@ -89,7 +95,6 @@ struct vc_data {
struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */ struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
unsigned long vc_uni_pagedir; unsigned long vc_uni_pagedir;
unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */ unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
struct vt_struct *vc_vt;
/* additional information is in vt_kern.h */ /* additional information is in vt_kern.h */
}; };
......
...@@ -25,15 +25,6 @@ ...@@ -25,15 +25,6 @@
#define BROKEN_GRAPHICS_PROGRAMS 1 #define BROKEN_GRAPHICS_PROGRAMS 1
#endif #endif
extern struct vt_struct {
int vc_num; /* The console number */
unsigned char vc_mode; /* KD_TEXT, ... */
struct vt_mode vt_mode;
int vt_pid;
int vt_newvt;
wait_queue_head_t paste_wait;
} *vt_cons[MAX_NR_CONSOLES];
extern void kd_mksound(unsigned int hz, unsigned int ticks); extern void kd_mksound(unsigned int hz, unsigned int ticks);
extern int kbd_rate(struct kbd_repeat *rep); extern int kbd_rate(struct kbd_repeat *rep);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment