Commit 716a6639 authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] cleanup vc array access

This removes as far as possible unneccessary vc_cons lookups by using a
pointer to the vc_data structure instead of the index.  The hidden currcons
argument in console_macros.h is temporarily replaced with a hidden vc pointer.
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 c035fc12
#define cons_num (vc_cons[currcons].d->vc_num)
#define video_scan_lines (vc_cons[currcons].d->vc_scan_lines)
#define sw (vc_cons[currcons].d->vc_sw)
#define screenbuf (vc_cons[currcons].d->vc_screenbuf)
#define screenbuf_size (vc_cons[currcons].d->vc_screenbuf_size)
#define origin (vc_cons[currcons].d->vc_origin)
#define scr_top (vc_cons[currcons].d->vc_scr_top)
#define visible_origin (vc_cons[currcons].d->vc_visible_origin)
#define scr_end (vc_cons[currcons].d->vc_scr_end)
#define pos (vc_cons[currcons].d->vc_pos)
#define top (vc_cons[currcons].d->vc_top)
#define bottom (vc_cons[currcons].d->vc_bottom)
#define x (vc_cons[currcons].d->vc_x)
#define y (vc_cons[currcons].d->vc_y)
#define vc_state (vc_cons[currcons].d->vc_state)
#define npar (vc_cons[currcons].d->vc_npar)
#define par (vc_cons[currcons].d->vc_par)
#define ques (vc_cons[currcons].d->vc_ques)
#define attr (vc_cons[currcons].d->vc_attr)
#define saved_x (vc_cons[currcons].d->vc_saved_x)
#define saved_y (vc_cons[currcons].d->vc_saved_y)
#define translate (vc_cons[currcons].d->vc_translate)
#define G0_charset (vc_cons[currcons].d->vc_G0_charset)
#define G1_charset (vc_cons[currcons].d->vc_G1_charset)
#define saved_G0 (vc_cons[currcons].d->vc_saved_G0)
#define saved_G1 (vc_cons[currcons].d->vc_saved_G1)
#define utf (vc_cons[currcons].d->vc_utf)
#define utf_count (vc_cons[currcons].d->vc_utf_count)
#define utf_char (vc_cons[currcons].d->vc_utf_char)
#define video_erase_char (vc_cons[currcons].d->vc_video_erase_char)
#define disp_ctrl (vc_cons[currcons].d->vc_disp_ctrl)
#define toggle_meta (vc_cons[currcons].d->vc_toggle_meta)
#define decscnm (vc_cons[currcons].d->vc_decscnm)
#define decom (vc_cons[currcons].d->vc_decom)
#define decawm (vc_cons[currcons].d->vc_decawm)
#define deccm (vc_cons[currcons].d->vc_deccm)
#define decim (vc_cons[currcons].d->vc_decim)
#define deccolm (vc_cons[currcons].d->vc_deccolm)
#define need_wrap (vc_cons[currcons].d->vc_need_wrap)
#define kmalloced (vc_cons[currcons].d->vc_kmalloced)
#define report_mouse (vc_cons[currcons].d->vc_report_mouse)
#define color (vc_cons[currcons].d->vc_color)
#define s_color (vc_cons[currcons].d->vc_s_color)
#define def_color (vc_cons[currcons].d->vc_def_color)
#define cons_num (vc->vc_num)
#define video_scan_lines (vc->vc_scan_lines)
#define sw (vc->vc_sw)
#define screenbuf (vc->vc_screenbuf)
#define screenbuf_size (vc->vc_screenbuf_size)
#define origin (vc->vc_origin)
#define scr_top (vc->vc_scr_top)
#define visible_origin (vc->vc_visible_origin)
#define scr_end (vc->vc_scr_end)
#define pos (vc->vc_pos)
#define top (vc->vc_top)
#define bottom (vc->vc_bottom)
#define x (vc->vc_x)
#define y (vc->vc_y)
#define vc_state (vc->vc_state)
#define npar (vc->vc_npar)
#define par (vc->vc_par)
#define ques (vc->vc_ques)
#define attr (vc->vc_attr)
#define saved_x (vc->vc_saved_x)
#define saved_y (vc->vc_saved_y)
#define translate (vc->vc_translate)
#define G0_charset (vc->vc_G0_charset)
#define G1_charset (vc->vc_G1_charset)
#define saved_G0 (vc->vc_saved_G0)
#define saved_G1 (vc->vc_saved_G1)
#define utf (vc->vc_utf)
#define utf_count (vc->vc_utf_count)
#define utf_char (vc->vc_utf_char)
#define video_erase_char (vc->vc_video_erase_char)
#define disp_ctrl (vc->vc_disp_ctrl)
#define toggle_meta (vc->vc_toggle_meta)
#define decscnm (vc->vc_decscnm)
#define decom (vc->vc_decom)
#define decawm (vc->vc_decawm)
#define deccm (vc->vc_deccm)
#define decim (vc->vc_decim)
#define deccolm (vc->vc_deccolm)
#define need_wrap (vc->vc_need_wrap)
#define kmalloced (vc->vc_kmalloced)
#define report_mouse (vc->vc_report_mouse)
#define color (vc->vc_color)
#define s_color (vc->vc_s_color)
#define def_color (vc->vc_def_color)
#define foreground (color & 0x0f)
#define background (color & 0xf0)
#define charset (vc_cons[currcons].d->vc_charset)
#define s_charset (vc_cons[currcons].d->vc_s_charset)
#define intensity (vc_cons[currcons].d->vc_intensity)
#define underline (vc_cons[currcons].d->vc_underline)
#define blink (vc_cons[currcons].d->vc_blink)
#define reverse (vc_cons[currcons].d->vc_reverse)
#define s_intensity (vc_cons[currcons].d->vc_s_intensity)
#define s_underline (vc_cons[currcons].d->vc_s_underline)
#define s_blink (vc_cons[currcons].d->vc_s_blink)
#define s_reverse (vc_cons[currcons].d->vc_s_reverse)
#define ulcolor (vc_cons[currcons].d->vc_ulcolor)
#define halfcolor (vc_cons[currcons].d->vc_halfcolor)
#define tab_stop (vc_cons[currcons].d->vc_tab_stop)
#define palette (vc_cons[currcons].d->vc_palette)
#define bell_pitch (vc_cons[currcons].d->vc_bell_pitch)
#define bell_duration (vc_cons[currcons].d->vc_bell_duration)
#define cursor_type (vc_cons[currcons].d->vc_cursor_type)
#define display_fg (vc_cons[currcons].d->vc_display_fg)
#define complement_mask (vc_cons[currcons].d->vc_complement_mask)
#define s_complement_mask (vc_cons[currcons].d->vc_s_complement_mask)
#define hi_font_mask (vc_cons[currcons].d->vc_hi_font_mask)
#define charset (vc->vc_charset)
#define s_charset (vc->vc_s_charset)
#define intensity (vc->vc_intensity)
#define underline (vc->vc_underline)
#define blink (vc->vc_blink)
#define reverse (vc->vc_reverse)
#define s_intensity (vc->vc_s_intensity)
#define s_underline (vc->vc_s_underline)
#define s_blink (vc->vc_s_blink)
#define s_reverse (vc->vc_s_reverse)
#define ulcolor (vc->vc_ulcolor)
#define halfcolor (vc->vc_halfcolor)
#define tab_stop (vc->vc_tab_stop)
#define palette (vc->vc_palette)
#define bell_pitch (vc->vc_bell_pitch)
#define bell_duration (vc->vc_bell_duration)
#define cursor_type (vc->vc_cursor_type)
#define display_fg (vc->vc_display_fg)
#define complement_mask (vc->vc_complement_mask)
#define s_complement_mask (vc->vc_s_complement_mask)
#define hi_font_mask (vc->vc_hi_font_mask)
#define vcmode (vt_cons[currcons]->vc_mode)
#define vcmode (vt_cons[vc->vc_num]->vc_mode)
#define structsize (sizeof(struct vc_data) + sizeof(struct vt_struct))
......@@ -208,9 +208,9 @@ static void set_inverse_transl(struct vc_data *conp, struct uni_pagedir *p, int
}
}
unsigned short *set_translate(int m,int currcons)
unsigned short *set_translate(int m, struct vc_data *vc)
{
inv_translate[currcons] = m;
inv_translate[vc->vc_num] = m;
return translations[m];
}
......@@ -362,15 +362,16 @@ static void con_release_unimap(struct uni_pagedir *p)
}
}
void con_free_unimap(int con)
void con_free_unimap(struct vc_data *vc)
{
struct uni_pagedir *p;
struct vc_data *conp = vc_cons[con].d;
p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
if (!p) return;
*conp->vc_uni_pagedir_loc = 0;
if (--p->refcount) return;
p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
if (!p)
return;
*vc->vc_uni_pagedir_loc = 0;
if (--p->refcount)
return;
con_release_unimap(p);
kfree(p);
}
......@@ -442,12 +443,11 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)
}
/* ui is a leftover from using a hashtable, but might be used again */
int con_clear_unimap(int con, struct unimapinit *ui)
int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui)
{
struct uni_pagedir *p, *q;
struct vc_data *conp = vc_cons[con].d;
p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
if (p && p->readonly) return -EIO;
if (!p || --p->refcount) {
q = (struct uni_pagedir *)kmalloc(sizeof(*p), GFP_KERNEL);
......@@ -457,7 +457,7 @@ int con_clear_unimap(int con, struct unimapinit *ui)
}
memset(q, 0, sizeof(*q));
q->refcount=1;
*conp->vc_uni_pagedir_loc = (unsigned long)q;
*vc->vc_uni_pagedir_loc = (unsigned long)q;
} else {
if (p == dflt) dflt = NULL;
p->refcount++;
......@@ -467,14 +467,12 @@ int con_clear_unimap(int con, struct unimapinit *ui)
return 0;
}
int
con_set_unimap(int con, ushort ct, struct unipair __user *list)
int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
{
int err = 0, err1, i;
struct uni_pagedir *p, *q;
struct vc_data *conp = vc_cons[con].d;
p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
if (p->readonly) return -EIO;
if (!ct) return 0;
......@@ -483,10 +481,10 @@ con_set_unimap(int con, ushort ct, struct unipair __user *list)
int j, k;
u16 **p1, *p2, l;
err1 = con_clear_unimap(con, NULL);
err1 = con_clear_unimap(vc, NULL);
if (err1) return err1;
q = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
q = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
for (i = 0, l = 0; i < 32; i++)
if ((p1 = p->uni_pgdir[i]))
for (j = 0; j < 32; j++)
......@@ -496,7 +494,7 @@ con_set_unimap(int con, ushort ct, struct unipair __user *list)
err1 = con_insert_unipair(q, l, p2[k]);
if (err1) {
p->refcount++;
*conp->vc_uni_pagedir_loc = (unsigned long)p;
*vc->vc_uni_pagedir_loc = (unsigned long)p;
con_release_unimap(q);
kfree(q);
return err1;
......@@ -515,11 +513,11 @@ con_set_unimap(int con, ushort ct, struct unipair __user *list)
list++;
}
if (con_unify_unimap(conp, p))
if (con_unify_unimap(vc, p))
return err;
for (i = 0; i <= 3; i++)
set_inverse_transl(conp, p, i); /* Update all inverse translations */
set_inverse_transl(vc, p, i); /* Update all inverse translations */
return err;
}
......@@ -529,20 +527,18 @@ con_set_unimap(int con, ushort ct, struct unipair __user *list)
with. This routine is executed at sys_setup time, and when the
PIO_FONTRESET ioctl is called. */
int
con_set_default_unimap(int con)
int con_set_default_unimap(struct vc_data *vc)
{
int i, j, err = 0, err1;
u16 *q;
struct uni_pagedir *p;
struct vc_data *conp = vc_cons[con].d;
if (dflt) {
p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
if (p == dflt)
return 0;
dflt->refcount++;
*conp->vc_uni_pagedir_loc = (unsigned long)dflt;
*vc->vc_uni_pagedir_loc = (unsigned long)dflt;
if (p && --p->refcount) {
con_release_unimap(p);
kfree(p);
......@@ -552,10 +548,10 @@ con_set_default_unimap(int con)
/* The default font is always 256 characters */
err = con_clear_unimap(con,NULL);
err = con_clear_unimap(vc, NULL);
if (err) return err;
p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
q = dfont_unitable;
for (i = 0; i < 256; i++)
......@@ -565,47 +561,42 @@ con_set_default_unimap(int con)
err = err1;
}
if (con_unify_unimap(conp, p)) {
dflt = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
if (con_unify_unimap(vc, p)) {
dflt = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
return err;
}
for (i = 0; i <= 3; i++)
set_inverse_transl(conp, p, i); /* Update all inverse translations */
set_inverse_transl(vc, p, i); /* Update all inverse translations */
dflt = p;
return err;
}
EXPORT_SYMBOL(con_set_default_unimap);
int
con_copy_unimap(int dstcon, int srccon)
int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc)
{
struct vc_data *sconp = vc_cons[srccon].d;
struct vc_data *dconp = vc_cons[dstcon].d;
struct uni_pagedir *q;
if (!vc_cons_allocated(srccon) || !*sconp->vc_uni_pagedir_loc)
if (!*src_vc->vc_uni_pagedir_loc)
return -EINVAL;
if (*dconp->vc_uni_pagedir_loc == *sconp->vc_uni_pagedir_loc)
if (*dst_vc->vc_uni_pagedir_loc == *src_vc->vc_uni_pagedir_loc)
return 0;
con_free_unimap(dstcon);
q = (struct uni_pagedir *)*sconp->vc_uni_pagedir_loc;
con_free_unimap(dst_vc);
q = (struct uni_pagedir *)*src_vc->vc_uni_pagedir_loc;
q->refcount++;
*dconp->vc_uni_pagedir_loc = (long)q;
*dst_vc->vc_uni_pagedir_loc = (long)q;
return 0;
}
int
con_get_unimap(int con, ushort ct, ushort __user *uct, struct unipair __user *list)
int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list)
{
int i, j, k, ect;
u16 **p1, *p2;
struct uni_pagedir *p;
struct vc_data *conp = vc_cons[con].d;
ect = 0;
if (*conp->vc_uni_pagedir_loc) {
p = (struct uni_pagedir *)*conp->vc_uni_pagedir_loc;
if (*vc->vc_uni_pagedir_loc) {
p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
for (i = 0; i < 32; i++)
if ((p1 = p->uni_pgdir[i]))
for (j = 0; j < 32; j++)
......@@ -625,12 +616,12 @@ con_get_unimap(int con, ushort ct, ushort __user *uct, struct unipair __user *li
return ((ect <= ct) ? 0 : -ENOMEM);
}
void con_protect_unimap(int con, int rdonly)
void con_protect_unimap(struct vc_data *vc, int rdonly)
{
struct uni_pagedir *p = (struct uni_pagedir *)
*vc_cons[con].d->vc_uni_pagedir_loc;
struct uni_pagedir *p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
if (p) p->readonly = rdonly;
if (p)
p->readonly = rdonly;
}
int
......@@ -679,7 +670,7 @@ console_map_init(void)
for (i = 0; i < MAX_NR_CONSOLES; i++)
if (vc_cons_allocated(i) && !*vc_cons[i].d->vc_uni_pagedir_loc)
con_set_default_unimap(i);
con_set_default_unimap(vc_cons[i].d);
}
EXPORT_SYMBOL(con_copy_unimap);
......@@ -536,12 +536,12 @@ static void fn_send_intr(struct vc_data *vc, struct pt_regs *regs)
static void fn_scroll_forw(struct vc_data *vc, struct pt_regs *regs)
{
scrollfront(0);
scrollfront(vc, 0);
}
static void fn_scroll_back(struct vc_data *vc, struct pt_regs *regs)
{
scrollback(0);
scrollback(vc, 0);
}
static void fn_show_mem(struct vc_data *vc, struct pt_regs *regs)
......@@ -581,7 +581,7 @@ static void fn_SAK(struct vc_data *vc, struct pt_regs *regs)
*/
if (tty)
do_SAK(tty);
reset_vc(fg_console);
reset_vc(vc);
}
static void fn_null(struct vc_data *vc, struct pt_regs *regs)
......
......@@ -43,15 +43,13 @@ static char *sel_buffer;
from interrupt (via scrollback/front) */
/* set reverse video on characters s-e of console with selection. */
inline static void
highlight(const int s, const int e)
static inline void highlight(const int s, const int e)
{
invert_screen(sel_cons, s, e-s+2, 1);
}
/* use complementary color to show the pointer */
inline static void
highlight_pointer(const int where)
static inline void highlight_pointer(const int where)
{
complement_pos(sel_cons, where);
}
......
......@@ -33,11 +33,10 @@
#include <linux/buffer_head.h> /* for fsync_bdev() */
#include <linux/spinlock.h>
#include <linux/vt_kern.h>
#include <asm/ptrace.h>
extern void reset_vc(unsigned int);
/* Whether we react on sysrq keys or just ignore them */
int sysrq_enabled = 1;
......@@ -68,7 +67,7 @@ static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs,
{
if (tty)
do_SAK(tty);
reset_vc(fg_console);
reset_vc(vc_cons[fg_console].d);
}
static struct sysrq_key_op sysrq_SAK_op = {
.handler = sysrq_handle_SAK,
......
......@@ -1789,7 +1789,6 @@ static int tty_open(struct inode * inode, struct file * filp)
}
#ifdef CONFIG_VT
if (device == MKDEV(TTY_MAJOR,0)) {
extern int fg_console;
extern struct tty_driver *console_driver;
driver = console_driver;
index = fg_console;
......@@ -2016,11 +2015,10 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty,
return 0;
#ifdef CONFIG_VT
if (tty->driver->type == TTY_DRIVER_TYPE_CONSOLE) {
unsigned int currcons = tty->index;
int rc;
acquire_console_sem();
rc = vc_resize(currcons, tmp_ws.ws_col, tmp_ws.ws_row);
rc = vc_resize(tty->driver_data, tmp_ws.ws_col, tmp_ws.ws_row);
release_console_sem();
if (rc)
return -ENXIO;
......
......@@ -52,14 +52,17 @@ vcs_size(struct inode *inode)
int size;
int minor = iminor(inode);
int currcons = minor & 127;
struct vc_data *vc;
if (currcons == 0)
currcons = fg_console;
else
currcons--;
if (!vc_cons_allocated(currcons))
return -ENXIO;
vc = vc_cons[currcons].d;
size = vc_cons[currcons].d->vc_rows * vc_cons[currcons].d->vc_cols;
size = vc->vc_rows * vc->vc_cols;
if (minor & 128)
size = 2*size + HEADER_SIZE;
......@@ -442,7 +445,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
buf += orig_count;
pos += orig_count;
if (org0)
update_region(currcons, (unsigned long)(org0), org-org0);
update_region(vc, (unsigned long)(org0), org - org0);
}
*ppos += written;
ret = written;
......
This diff is collapsed.
......@@ -311,7 +311,7 @@ do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struc
op->height = cfdarg.charheight;
op->charcount = cfdarg.charcount;
op->data = cfdarg.chardata;
return con_font_op(fg_console, op);
return con_font_op(vc_cons[fg_console].d, op);
case GIO_FONTX: {
op->op = KD_FONT_OP_GET;
op->flags = KD_FONT_FLAG_OLD;
......@@ -319,7 +319,7 @@ do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struc
op->height = cfdarg.charheight;
op->charcount = cfdarg.charcount;
op->data = cfdarg.chardata;
i = con_font_op(fg_console, op);
i = con_font_op(vc_cons[fg_console].d, op);
if (i)
return i;
cfdarg.charheight = op->height;
......@@ -333,7 +333,7 @@ do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struc
}
static inline int
do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, unsigned int console)
do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, struct vc_data *vc)
{
struct unimapdesc tmp;
int i = 0;
......@@ -349,11 +349,11 @@ do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, unsigned i
case PIO_UNIMAP:
if (!perm)
return -EPERM;
return con_set_unimap(console, tmp.entry_ct, tmp.entries);
return con_set_unimap(vc, tmp.entry_ct, tmp.entries);
case GIO_UNIMAP:
if (!perm && fg_console != console)
if (!perm && fg_console != vc->vc_num)
return -EPERM;
return con_get_unimap(console, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries);
return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries);
}
return 0;
}
......@@ -796,7 +796,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
* make sure we are atomic with respect to
* other console switches..
*/
complete_change_console(newvt);
complete_change_console(vc_cons[newvt].d);
release_console_sem();
}
}
......@@ -852,7 +852,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
return -EFAULT;
for (i = 0; i < MAX_NR_CONSOLES; i++) {
acquire_console_sem();
vc_resize(i, cc, ll);
vc_resize(vc_cons[i].d, cc, ll);
release_console_sem();
}
return 0;
......@@ -900,7 +900,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
vc_cons[i].d->vc_scan_lines = vlin;
if (clin)
vc_cons[i].d->vc_font.height = clin;
vc_resize(i, cc, ll);
vc_resize(vc_cons[i].d, cc, ll);
release_console_sem();
}
return 0;
......@@ -915,7 +915,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
op.height = 0;
op.charcount = 256;
op.data = up;
return con_font_op(fg_console, &op);
return con_font_op(vc_cons[fg_console].d, &op);
}
case GIO_FONT: {
......@@ -925,7 +925,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
op.height = 32;
op.charcount = 256;
op.data = up;
return con_font_op(fg_console, &op);
return con_font_op(vc_cons[fg_console].d, &op);
}
case PIO_CMAP:
......@@ -953,9 +953,10 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
{
op.op = KD_FONT_OP_SET_DEFAULT;
op.data = NULL;
i = con_font_op(fg_console, &op);
if (i) return i;
con_set_default_unimap(fg_console);
i = con_font_op(vc_cons[fg_console].d, &op);
if (i)
return i;
con_set_default_unimap(vc_cons[fg_console].d);
return 0;
}
#endif
......@@ -966,7 +967,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
return -EFAULT;
if (!perm && op.op != KD_FONT_OP_GET)
return -EPERM;
i = con_font_op(console, &op);
i = con_font_op(vc, &op);
if (i) return i;
if (copy_to_user(up, &op, sizeof(op)))
return -EFAULT;
......@@ -995,13 +996,13 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
return -EPERM;
i = copy_from_user(&ui, up, sizeof(struct unimapinit));
if (i) return -EFAULT;
con_clear_unimap(console, &ui);
con_clear_unimap(vc, &ui);
return 0;
}
case PIO_UNIMAP:
case GIO_UNIMAP:
return do_unimap_ioctl(cmd, up, perm, console);
return do_unimap_ioctl(cmd, up, perm, vc);
case VT_LOCKSWITCH:
if (!capable(CAP_SYS_TTY_CONFIG))
......@@ -1054,26 +1055,29 @@ int vt_waitactive(int vt)
#define vt_wake_waitactive() wake_up(&vt_activate_queue)
void reset_vc(unsigned int new_console)
void reset_vc(struct vc_data *vc)
{
vt_cons[new_console]->vc_mode = KD_TEXT;
kbd_table[new_console].kbdmode = VC_XLATE;
vt_cons[new_console]->vt_mode.mode = VT_AUTO;
vt_cons[new_console]->vt_mode.waitv = 0;
vt_cons[new_console]->vt_mode.relsig = 0;
vt_cons[new_console]->vt_mode.acqsig = 0;
vt_cons[new_console]->vt_mode.frsig = 0;
vt_cons[new_console]->vt_pid = -1;
vt_cons[new_console]->vt_newvt = -1;
struct vt_struct *vt = vt_cons[vc->vc_num];
vt->vc_mode = KD_TEXT;
kbd_table[vc->vc_num].kbdmode = VC_XLATE;
vt->vt_mode.mode = VT_AUTO;
vt->vt_mode.waitv = 0;
vt->vt_mode.relsig = 0;
vt->vt_mode.acqsig = 0;
vt->vt_mode.frsig = 0;
vt->vt_pid = -1;
vt->vt_newvt = -1;
if (!in_interrupt()) /* Via keyboard.c:SAK() - akpm */
reset_palette(new_console) ;
reset_palette(vc);
}
/*
* Performs the back end of a vt switch
*/
void complete_change_console(unsigned int new_console)
void complete_change_console(struct vc_data *vc)
{
unsigned int new_console = vc->vc_num;
unsigned char old_vc_mode;
last_console = fg_console;
......@@ -1084,7 +1088,7 @@ void complete_change_console(unsigned int new_console)
* unblank the screen later.
*/
old_vc_mode = vt_cons[fg_console]->vc_mode;
switch_screen(new_console);
switch_screen(vc);
/*
* This can't appear below a successful kill_proc(). If it did,
......@@ -1129,7 +1133,7 @@ void complete_change_console(unsigned int new_console)
* this outside of VT_PROCESS but there is no single process
* to account for and tracking tty count may be undesirable.
*/
reset_vc(new_console);
reset_vc(vc);
if (old_vc_mode != vt_cons[new_console]->vc_mode)
{
......@@ -1151,11 +1155,9 @@ void complete_change_console(unsigned int new_console)
/*
* Performs the front-end of a vt switch
*/
void change_console(unsigned int new_console)
void change_console(struct vc_data *new_vc)
{
if ((new_console == fg_console) || (vt_dont_switch))
return;
if (!vc_cons_allocated(new_console))
if (!new_vc || new_vc->vc_num == fg_console || vt_dont_switch)
return;
/*
......@@ -1189,7 +1191,7 @@ void change_console(unsigned int new_console)
* return. The process needs to send us a
* VT_RELDISP ioctl to complete the switch.
*/
vt_cons[fg_console]->vt_newvt = new_console;
vt_cons[fg_console]->vt_newvt = new_vc->vc_num;
return;
}
......@@ -1202,7 +1204,7 @@ void change_console(unsigned int new_console)
* this outside of VT_PROCESS but there is no single process
* to account for and tracking tty count may be undesirable.
*/
reset_vc(fg_console);
reset_vc(vc_cons[fg_console].d);
/*
* Fall through to normal (VT_AUTO) handling of the switch...
......@@ -1215,5 +1217,5 @@ void change_console(unsigned int new_console)
if (vt_cons[fg_console]->vc_mode == KD_GRAPHICS)
return;
complete_change_console(new_console);
complete_change_console(new_vc);
}
......@@ -42,7 +42,7 @@ static void dummycon_init(struct vc_data *vc, int init)
vc->vc_cols = DUMMY_COLUMNS;
vc->vc_rows = DUMMY_ROWS;
} else
vc_resize(vc->vc_num, DUMMY_COLUMNS, DUMMY_ROWS);
vc_resize(vc, DUMMY_COLUMNS, DUMMY_ROWS);
}
static int dummycon_dummy(void)
......
......@@ -458,7 +458,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
if (CON_IS_VISIBLE(vc) && vt_cons[vc->vc_num]->vc_mode == KD_TEXT) {
fbcon_clear_margins(vc, 0);
update_screen(vc->vc_num);
update_screen(vc);
}
if (save) {
......@@ -609,7 +609,7 @@ static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
fg_vc->vc_rows);
}
switch_screen(fg_console);
update_screen(vc_cons[fg_console].d);
}
/**
......@@ -802,7 +802,7 @@ static const char *fbcon_startup(void)
cols = info->var.xres / vc->vc_font.width;
rows = info->var.yres / vc->vc_font.height;
vc_resize(vc->vc_num, cols, rows);
vc_resize(vc, cols, rows);
DPRINTK("mode: %s\n", info->fix.id);
DPRINTK("visual: %d\n", info->fix.visual);
......@@ -890,13 +890,12 @@ static void fbcon_init(struct vc_data *vc, int init)
struct vc_data **default_mode = vc->vc_display_fg;
struct vc_data *svc = *default_mode;
struct display *t, *p = &fb_display[vc->vc_num];
int display_fg = (*default_mode)->vc_num;
int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
int cap = info->flags;
if (info_idx == -1 || info == NULL)
return;
if (vc->vc_num != display_fg || logo_shown == FBCON_LOGO_DONTSHOW ||
if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
(info->fix.type == FB_TYPE_TEXT))
logo = 0;
......@@ -907,7 +906,7 @@ static void fbcon_init(struct vc_data *vc, int init)
/* If we are not the first console on this
fb, copy the font from that console */
t = &fb_display[display_fg];
t = &fb_display[svc->vc_num];
if (!vc->vc_font.data) {
vc->vc_font.data = p->fontdata = t->fontdata;
vc->vc_font.width = (*default_mode)->vc_font.width;
......@@ -929,15 +928,15 @@ static void fbcon_init(struct vc_data *vc, int init)
}
if (!*svc->vc_uni_pagedir_loc)
con_set_default_unimap(display_fg);
con_set_default_unimap(svc);
if (!*vc->vc_uni_pagedir_loc)
con_copy_unimap(vc->vc_num, display_fg);
con_copy_unimap(vc, svc);
cols = vc->vc_cols;
rows = vc->vc_rows;
new_cols = info->var.xres / vc->vc_font.width;
new_rows = info->var.yres / vc->vc_font.height;
vc_resize(vc->vc_num, new_cols, new_rows);
vc_resize(vc, new_cols, new_rows);
/*
* We must always set the mode. The mode of the previous console
* driver could be in the same resolution but we are using different
......@@ -968,7 +967,7 @@ static void fbcon_init(struct vc_data *vc, int init)
if (logo)
fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
if (vc->vc_num == display_fg && softback_buf) {
if (vc == svc && softback_buf) {
int l = fbcon_softback_size / vc->vc_size_row;
if (l > 5)
softback_end = softback_buf + l * vc->vc_size_row;
......@@ -1144,13 +1143,12 @@ static void fbcon_set_disp(struct fb_info *info, struct vc_data *vc)
struct display *p = &fb_display[vc->vc_num], *t;
struct vc_data **default_mode = vc->vc_display_fg;
struct vc_data *svc = *default_mode;
int display_fg = (*default_mode)->vc_num;
int rows, cols, charcnt = 256;
info->var.xoffset = info->var.yoffset = p->yscroll = 0;
if (var_to_display(p, &info->var, info))
return;
t = &fb_display[display_fg];
t = &fb_display[svc->vc_num];
if (!vc->vc_font.data) {
vc->vc_font.data = p->fontdata = t->fontdata;
vc->vc_font.width = (*default_mode)->vc_font.width;
......@@ -1173,15 +1171,15 @@ static void fbcon_set_disp(struct fb_info *info, struct vc_data *vc)
}
if (!*svc->vc_uni_pagedir_loc)
con_set_default_unimap(display_fg);
con_set_default_unimap(svc);
if (!*vc->vc_uni_pagedir_loc)
con_copy_unimap(vc->vc_num, display_fg);
con_copy_unimap(vc, svc);
cols = info->var.xres / vc->vc_font.width;
rows = info->var.yres / vc->vc_font.height;
vc_resize(vc->vc_num, cols, rows);
vc_resize(vc, cols, rows);
if (CON_IS_VISIBLE(vc)) {
update_screen(vc->vc_num);
update_screen(vc);
if (softback_buf) {
int l = fbcon_softback_size / vc->vc_size_row;
......@@ -1987,7 +1985,7 @@ static int fbcon_switch(struct vc_data *vc)
logo_shown = fg_console;
/* This is protected above by initmem_freed */
fb_show_logo(info);
update_region(fg_console,
update_region(vc,
vc->vc_origin + vc->vc_size_row * vc->vc_top,
vc->vc_size_row * (vc->vc_bottom -
vc->vc_top) / 2);
......@@ -2048,7 +2046,7 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
}
if (!blank)
update_screen(vc->vc_num);
update_screen(vc);
}
return 0;
......@@ -2198,7 +2196,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
if (resize) {
/* reset wrap/pan */
info->var.xoffset = info->var.yoffset = p->yscroll = 0;
vc_resize(vc->vc_num, info->var.xres / w, info->var.yres / h);
vc_resize(vc, info->var.xres / w, info->var.yres / h);
if (CON_IS_VISIBLE(vc) && softback_buf) {
int l = fbcon_softback_size / vc->vc_size_row;
if (l > 5)
......@@ -2213,7 +2211,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
} else if (CON_IS_VISIBLE(vc)
&& vt_cons[vc->vc_num]->vc_mode == KD_TEXT) {
fbcon_clear_margins(vc, 0);
update_screen(vc->vc_num);
update_screen(vc);
}
if (old_data && (--REFCOUNT(old_data) == 0))
......@@ -2464,7 +2462,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
vc->vc_size_row);
}
softback_in = p;
update_region(vc->vc_num, vc->vc_origin,
update_region(vc, vc->vc_origin,
logo_lines * vc->vc_cols);
}
logo_shown = FBCON_LOGO_CANSHOW;
......@@ -2545,7 +2543,7 @@ static void fbcon_resumed(struct fb_info *info)
return;
vc = vc_cons[ops->currcon].d;
update_screen(vc->vc_num);
update_screen(vc);
}
static void fbcon_modechanged(struct fb_info *info)
......@@ -2569,13 +2567,13 @@ static void fbcon_modechanged(struct fb_info *info)
var_to_display(p, &info->var, info);
cols = info->var.xres / vc->vc_font.width;
rows = info->var.yres / vc->vc_font.height;
vc_resize(vc->vc_num, cols, rows);
vc_resize(vc, cols, rows);
updatescrollmode(p, info, vc);
scrollback_max = 0;
scrollback_current = 0;
update_var(vc->vc_num, info);
fbcon_set_palette(vc, color_table);
update_screen(vc->vc_num);
update_screen(vc);
if (softback_buf) {
int l = fbcon_softback_size / vc->vc_size_row;
if (l > 5)
......
......@@ -351,9 +351,8 @@ static void mdacon_init(struct vc_data *c, int init)
if (init) {
c->vc_cols = mda_num_columns;
c->vc_rows = mda_num_lines;
} else {
vc_resize(c->vc_num, mda_num_columns, mda_num_lines);
}
} else
vc_resize(c, mda_num_columns, mda_num_lines);
/* make the first MDA console visible */
......
......@@ -155,9 +155,9 @@ promcon_init_unimap(struct vc_data *conp)
k++;
}
set_fs(KERNEL_DS);
con_clear_unimap(conp->vc_num, NULL);
con_set_unimap(conp->vc_num, k, p);
con_protect_unimap(conp->vc_num, 1);
con_clear_unimap(conp, NULL);
con_set_unimap(conp, k, p);
con_protect_unimap(conp, 1);
set_fs(old_fs);
kfree(p);
}
......@@ -175,7 +175,7 @@ promcon_init(struct vc_data *conp, int init)
p = *conp->vc_uni_pagedir_loc;
if (conp->vc_uni_pagedir_loc == &conp->vc_uni_pagedir ||
!--conp->vc_uni_pagedir_loc[1])
con_free_unimap(conp->vc_num);
con_free_unimap(conp);
conp->vc_uni_pagedir_loc = promcon_uni_pagedir;
promcon_uni_pagedir[1]++;
if (!promcon_uni_pagedir[0] && p) {
......@@ -183,7 +183,7 @@ promcon_init(struct vc_data *conp, int init)
}
if (!init) {
if (conp->vc_cols != pw + 1 || conp->vc_rows != ph + 1)
vc_resize(conp->vc_num, pw + 1, ph + 1);
vc_resize(conp, pw + 1, ph + 1);
}
}
......@@ -192,9 +192,9 @@ promcon_deinit(struct vc_data *conp)
{
/* When closing the last console, reset video origin */
if (!--promcon_uni_pagedir[1])
con_free_unimap(conp->vc_num);
con_free_unimap(conp);
conp->vc_uni_pagedir_loc = &conp->vc_uni_pagedir;
con_set_default_unimap(conp->vc_num);
con_set_default_unimap(conp);
}
static int
......
......@@ -217,7 +217,7 @@ static void sticon_init(struct vc_data *c, int init)
} else {
/* vc_rows = (c->vc_rows > vc_rows) ? vc_rows : c->vc_rows; */
/* vc_cols = (c->vc_cols > vc_cols) ? vc_cols : c->vc_cols; */
vc_resize(c->vc_num, vc_cols, vc_rows);
vc_resize(c, vc_cols, vc_rows);
/* vc_resize_con(vc_rows, vc_cols, c->vc_num); */
}
}
......
......@@ -340,11 +340,11 @@ static void vgacon_init(struct vc_data *c, int init)
p = *c->vc_uni_pagedir_loc;
if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir ||
!--c->vc_uni_pagedir_loc[1])
con_free_unimap(c->vc_num);
con_free_unimap(c);
c->vc_uni_pagedir_loc = vgacon_uni_pagedir;
vgacon_uni_pagedir[1]++;
if (!vgacon_uni_pagedir[0] && p)
con_set_default_unimap(c->vc_num);
con_set_default_unimap(c);
}
static inline void vga_set_mem_top(struct vc_data *c)
......@@ -358,10 +358,10 @@ static void vgacon_deinit(struct vc_data *c)
if (!--vgacon_uni_pagedir[1]) {
c->vc_visible_origin = vga_vram_base;
vga_set_mem_top(c);
con_free_unimap(c->vc_num);
con_free_unimap(c);
}
c->vc_uni_pagedir_loc = &c->vc_uni_pagedir;
con_set_default_unimap(c->vc_num);
con_set_default_unimap(c);
}
static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
......@@ -908,7 +908,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight)
c->vc_sw->con_cursor(c, CM_DRAW);
}
c->vc_font.height = fontheight;
vc_resize(c->vc_num, 0, rows); /* Adjust console size */
vc_resize(c, 0, rows); /* Adjust console size */
}
}
return 0;
......
......@@ -1559,7 +1559,7 @@ static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
get_user(data, &user_cfd->chardata))
return -EFAULT;
op.data = compat_ptr(data);
return con_font_op(fg_console, &op);
return con_font_op(vc_cons[fg_console].d, &op);
case GIO_FONTX:
op.op = KD_FONT_OP_GET;
op.flags = 0;
......@@ -1571,7 +1571,7 @@ static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
if (!data)
return 0;
op.data = compat_ptr(data);
i = con_font_op(fg_console, &op);
i = con_font_op(vc_cons[fg_console].d, &op);
if (i)
return i;
if (put_user(op.height, &user_cfd->charheight) ||
......@@ -1608,7 +1608,7 @@ static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar
op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
op.flags |= KD_FONT_FLAG_OLD;
vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data;
i = con_font_op(vt->vc_num, &op);
i = con_font_op(vc_cons[vt->vc_num].d, &op);
if (i) return i;
((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
......@@ -1633,9 +1633,9 @@ static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
switch (cmd) {
case PIO_UNIMAP:
if (!perm) return -EPERM;
return con_set_unimap(fg_console, tmp.entry_ct, compat_ptr(tmp.entries));
return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries));
case GIO_UNIMAP:
return con_get_unimap(fg_console, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries));
}
return 0;
}
......
......@@ -11,5 +11,5 @@
struct vc_data;
extern unsigned char inverse_translate(struct vc_data *conp, int glyph);
extern unsigned short *set_translate(int m,int currcons);
extern unsigned short *set_translate(int m, struct vc_data *vc);
extern int conv_uni_to_pc(struct vc_data *conp, long ucs);
......@@ -41,25 +41,25 @@ extern int kbd_rate(struct kbd_repeat *rep);
int vc_allocate(unsigned int console);
int vc_cons_allocated(unsigned int console);
int vc_resize(int currcons, unsigned int cols, unsigned int lines);
int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
void vc_disallocate(unsigned int console);
void reset_palette(int currcons);
void set_palette(int currcons);
void reset_palette(struct vc_data *vc);
void set_palette(struct vc_data *vc);
void do_blank_screen(int entering_gfx);
void do_unblank_screen(int leaving_gfx);
void unblank_screen(void);
void poke_blanked_console(void);
int con_font_op(int currcons, struct console_font_op *op);
int con_font_set(int currcons, struct console_font_op *op);
int con_font_get(int currcons, struct console_font_op *op);
int con_font_default(int currcons, struct console_font_op *op);
int con_font_copy(int currcons, struct console_font_op *op);
int con_font_op(struct vc_data *vc, struct console_font_op *op);
int con_font_set(struct vc_data *vc, struct console_font_op *op);
int con_font_get(struct vc_data *vc, struct console_font_op *op);
int con_font_default(struct vc_data *vc, struct console_font_op *op);
int con_font_copy(struct vc_data *vc, struct console_font_op *op);
int con_set_cmap(unsigned char __user *cmap);
int con_get_cmap(unsigned char __user *cmap);
void scrollback(int);
void scrollfront(int);
void update_region(int currcons, unsigned long start, int count);
void redraw_screen(int new_console, int is_switch);
void scrollback(struct vc_data *vc, int lines);
void scrollfront(struct vc_data *vc, int lines);
void update_region(struct vc_data *vc, unsigned long start, int count);
void redraw_screen(struct vc_data *vc, int is_switch);
#define update_screen(x) redraw_screen(x, 0)
#define switch_screen(x) redraw_screen(x, 1)
......@@ -75,19 +75,19 @@ int con_set_trans_old(unsigned char __user * table);
int con_get_trans_old(unsigned char __user * table);
int con_set_trans_new(unsigned short __user * table);
int con_get_trans_new(unsigned short __user * table);
int con_clear_unimap(int currcons, struct unimapinit *ui);
int con_set_unimap(int currcons, ushort ct, struct unipair __user *list);
int con_get_unimap(int currcons, ushort ct, ushort __user *uct, struct unipair __user *list);
int con_set_default_unimap(int currcons);
void con_free_unimap(int currcons);
void con_protect_unimap(int currcons, int rdonly);
int con_copy_unimap(int dstcons, int srccons);
int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui);
int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list);
int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list);
int con_set_default_unimap(struct vc_data *vc);
void con_free_unimap(struct vc_data *vc);
void con_protect_unimap(struct vc_data *vc, int rdonly);
int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
/* vt.c */
void complete_change_console(unsigned int new_console);
void complete_change_console(struct vc_data *vc);
int vt_waitactive(int vt);
void change_console(unsigned int);
void reset_vc(unsigned int new_console);
void change_console(struct vc_data *new_vc);
void reset_vc(struct vc_data *vc);
/*
* vc_screen.c shares this temporary buffer with the console write code so that
......
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