Commit 77aa6cbf authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] cleanup virtual console <-> selection.c interface

Pass around pointers instead of indices into a global array between various
files of the virtual console implementation and stop using obsfucting
macros that expect certain variables to be in scope.

This is a first step to get rid of the various global arrays in the VC
code.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cd3ae7b3
...@@ -33,7 +33,7 @@ extern void poke_blanked_console(void); ...@@ -33,7 +33,7 @@ extern void poke_blanked_console(void);
/* Variables for selection control. */ /* Variables for selection control. */
/* Use a dynamic buffer, instead of static (Dec 1994) */ /* Use a dynamic buffer, instead of static (Dec 1994) */
int sel_cons; /* must not be disallocated */ struct vc_data *sel_cons; /* must not be disallocated */
static volatile int sel_start = -1; /* cleared by clear_selection */ static volatile int sel_start = -1; /* cleared by clear_selection */
static int sel_end; static int sel_end;
static int sel_buffer_lth; static int sel_buffer_lth;
...@@ -44,20 +44,22 @@ static char *sel_buffer; ...@@ -44,20 +44,22 @@ static char *sel_buffer;
/* set reverse video on characters s-e of console with selection. */ /* set reverse video on characters s-e of console with selection. */
inline static void inline static void
highlight(const int s, const int e) { highlight(const int s, const int e)
{
invert_screen(sel_cons, s, e-s+2, 1); invert_screen(sel_cons, s, e-s+2, 1);
} }
/* use complementary color to show the pointer */ /* use complementary color to show the pointer */
inline static void inline static void
highlight_pointer(const int where) { highlight_pointer(const int where)
{
complement_pos(sel_cons, where); complement_pos(sel_cons, where);
} }
static unsigned char static unsigned char
sel_pos(int n) sel_pos(int n)
{ {
return inverse_translate(vc_cons[sel_cons].d, screen_glyph(sel_cons, n)); return inverse_translate(sel_cons, screen_glyph(sel_cons, n));
} }
/* remove the current selection highlight, if any, /* remove the current selection highlight, if any,
...@@ -111,10 +113,10 @@ static inline unsigned short limit(const unsigned short v, const unsigned short ...@@ -111,10 +113,10 @@ static inline unsigned short limit(const unsigned short v, const unsigned short
/* set the current selection. Invoked by ioctl() or by kernel code. */ /* set the current selection. Invoked by ioctl() or by kernel code. */
int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty) int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty)
{ {
struct vc_data *vc = vc_cons[fg_console].d;
int sel_mode, new_sel_start, new_sel_end, spc; int sel_mode, new_sel_start, new_sel_end, spc;
char *bp, *obp; char *bp, *obp;
int i, ps, pe; int i, ps, pe;
unsigned int currcons = fg_console;
poke_blanked_console(); poke_blanked_console();
...@@ -128,12 +130,12 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -128,12 +130,12 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
__get_user(ye, &sel->ye); __get_user(ye, &sel->ye);
__get_user(sel_mode, &sel->sel_mode); __get_user(sel_mode, &sel->sel_mode);
xs--; ys--; xe--; ye--; xs--; ys--; xe--; ye--;
xs = limit(xs, video_num_columns - 1); xs = limit(xs, vc->vc_cols - 1);
ys = limit(ys, video_num_lines - 1); ys = limit(ys, vc->vc_rows - 1);
xe = limit(xe, video_num_columns - 1); xe = limit(xe, vc->vc_cols - 1);
ye = limit(ye, video_num_lines - 1); ye = limit(ye, vc->vc_rows - 1);
ps = ys * video_size_row + (xs << 1); ps = ys * vc->vc_size_row + (xs << 1);
pe = ye * video_size_row + (xe << 1); pe = ye * vc->vc_size_row + (xe << 1);
if (sel_mode == TIOCL_SELCLEAR) { if (sel_mode == TIOCL_SELCLEAR) {
/* useful for screendump without selection highlights */ /* useful for screendump without selection highlights */
...@@ -154,9 +156,9 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -154,9 +156,9 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
pe = tmp; pe = tmp;
} }
if (sel_cons != fg_console) { if (sel_cons != vc_cons[fg_console].d) {
clear_selection(); clear_selection();
sel_cons = fg_console; sel_cons = vc_cons[fg_console].d;
} }
switch (sel_mode) switch (sel_mode)
...@@ -173,7 +175,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -173,7 +175,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
(!spc && !inword(sel_pos(ps)))) (!spc && !inword(sel_pos(ps))))
break; break;
new_sel_start = ps; new_sel_start = ps;
if (!(ps % video_size_row)) if (!(ps % vc->vc_size_row))
break; break;
} }
spc = isspace(sel_pos(pe)); spc = isspace(sel_pos(pe));
...@@ -183,14 +185,14 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -183,14 +185,14 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
(!spc && !inword(sel_pos(pe)))) (!spc && !inword(sel_pos(pe))))
break; break;
new_sel_end = pe; new_sel_end = pe;
if (!((pe + 2) % video_size_row)) if (!((pe + 2) % vc->vc_size_row))
break; break;
} }
break; break;
case TIOCL_SELLINE: /* line-by-line selection */ case TIOCL_SELLINE: /* line-by-line selection */
new_sel_start = ps - ps % video_size_row; new_sel_start = ps - ps % vc->vc_size_row;
new_sel_end = pe + video_size_row new_sel_end = pe + vc->vc_size_row
- pe % video_size_row - 2; - pe % vc->vc_size_row - 2;
break; break;
case TIOCL_SELPOINTER: case TIOCL_SELPOINTER:
highlight_pointer(pe); highlight_pointer(pe);
...@@ -204,11 +206,11 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -204,11 +206,11 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
/* select to end of line if on trailing space */ /* select to end of line if on trailing space */
if (new_sel_end > new_sel_start && if (new_sel_end > new_sel_start &&
!atedge(new_sel_end, video_size_row) && !atedge(new_sel_end, vc->vc_size_row) &&
isspace(sel_pos(new_sel_end))) { isspace(sel_pos(new_sel_end))) {
for (pe = new_sel_end + 2; ; pe += 2) for (pe = new_sel_end + 2; ; pe += 2)
if (!isspace(sel_pos(pe)) || if (!isspace(sel_pos(pe)) ||
atedge(pe, video_size_row)) atedge(pe, vc->vc_size_row))
break; break;
if (isspace(sel_pos(pe))) if (isspace(sel_pos(pe)))
new_sel_end = pe; new_sel_end = pe;
...@@ -255,7 +257,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t ...@@ -255,7 +257,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
*bp = sel_pos(i); *bp = sel_pos(i);
if (!isspace(*bp++)) if (!isspace(*bp++))
obp = bp; obp = bp;
if (! ((i + 2) % video_size_row)) { if (! ((i + 2) % vc->vc_size_row)) {
/* strip trailing blanks from line and add newline, /* strip trailing blanks from line and add newline,
unless non-space at end of line. */ unless non-space at end of line. */
if (obp != bp) { if (obp != bp) {
......
...@@ -59,7 +59,7 @@ vcs_size(struct inode *inode) ...@@ -59,7 +59,7 @@ vcs_size(struct inode *inode)
if (!vc_cons_allocated(currcons)) if (!vc_cons_allocated(currcons))
return -ENXIO; return -ENXIO;
size = video_num_lines * video_num_columns; size = vc_cons[currcons].d->vc_rows * vc_cons[currcons].d->vc_cols;
if (minor & 128) if (minor & 128)
size = 2*size + HEADER_SIZE; size = 2*size + HEADER_SIZE;
...@@ -99,6 +99,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -99,6 +99,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{ {
struct inode *inode = file->f_dentry->d_inode; struct inode *inode = file->f_dentry->d_inode;
unsigned int currcons = iminor(inode); unsigned int currcons = iminor(inode);
struct vc_data *vc;
long pos; long pos;
long viewed, attr, read; long viewed, attr, read;
int col, maxcol; int col, maxcol;
...@@ -126,6 +127,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -126,6 +127,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
ret = -ENXIO; ret = -ENXIO;
if (!vc_cons_allocated(currcons)) if (!vc_cons_allocated(currcons))
goto unlock_out; goto unlock_out;
vc = vc_cons[currcons].d;
ret = -EINVAL; ret = -EINVAL;
if (pos < 0) if (pos < 0)
...@@ -159,15 +161,15 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -159,15 +161,15 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
con_buf_start = con_buf0 = con_buf; con_buf_start = con_buf0 = con_buf;
orig_count = this_round; orig_count = this_round;
maxcol = video_num_columns; maxcol = vc->vc_cols;
if (!attr) { if (!attr) {
org = screen_pos(currcons, p, viewed); org = screen_pos(vc, p, viewed);
col = p % maxcol; col = p % maxcol;
p += maxcol - col; p += maxcol - col;
while (this_round-- > 0) { while (this_round-- > 0) {
*con_buf0++ = (vcs_scr_readw(currcons, org++) & 0xff); *con_buf0++ = (vcs_scr_readw(vc, org++) & 0xff);
if (++col == maxcol) { if (++col == maxcol) {
org = screen_pos(currcons, p, viewed); org = screen_pos(vc, p, viewed);
col = 0; col = 0;
p += maxcol; p += maxcol;
} }
...@@ -176,9 +178,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -176,9 +178,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (p < HEADER_SIZE) { if (p < HEADER_SIZE) {
size_t tmp_count; size_t tmp_count;
con_buf0[0] = (char) video_num_lines; con_buf0[0] = (char)vc->vc_rows;
con_buf0[1] = (char) video_num_columns; con_buf0[1] = (char)vc->vc_cols;
getconsxy(currcons, con_buf0 + 2); getconsxy(vc, con_buf0 + 2);
con_buf_start += p; con_buf_start += p;
this_round += p; this_round += p;
...@@ -214,7 +216,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -214,7 +216,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
p /= 2; p /= 2;
col = p % maxcol; col = p % maxcol;
org = screen_pos(currcons, p, viewed); org = screen_pos(vc, p, viewed);
p += maxcol - col; p += maxcol - col;
/* Buffer has even length, so we can always copy /* Buffer has even length, so we can always copy
...@@ -224,10 +226,10 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -224,10 +226,10 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
this_round = (this_round + 1) >> 1; this_round = (this_round + 1) >> 1;
while (this_round) { while (this_round) {
*tmp_buf++ = vcs_scr_readw(currcons, org++); *tmp_buf++ = vcs_scr_readw(vc, org++);
this_round --; this_round --;
if (++col == maxcol) { if (++col == maxcol) {
org = screen_pos(currcons, p, viewed); org = screen_pos(vc, p, viewed);
col = 0; col = 0;
p += maxcol; p += maxcol;
} }
...@@ -270,6 +272,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -270,6 +272,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{ {
struct inode *inode = file->f_dentry->d_inode; struct inode *inode = file->f_dentry->d_inode;
unsigned int currcons = iminor(inode); unsigned int currcons = iminor(inode);
struct vc_data *vc;
long pos; long pos;
long viewed, attr, size, written; long viewed, attr, size, written;
char *con_buf0; char *con_buf0;
...@@ -299,6 +302,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -299,6 +302,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
ret = -ENXIO; ret = -ENXIO;
if (!vc_cons_allocated(currcons)) if (!vc_cons_allocated(currcons))
goto unlock_out; goto unlock_out;
vc = vc_cons[currcons].d;
size = vcs_size(inode); size = vcs_size(inode);
ret = -EINVAL; ret = -EINVAL;
...@@ -351,10 +355,10 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -351,10 +355,10 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
con_buf0 = con_buf; con_buf0 = con_buf;
orig_count = this_round; orig_count = this_round;
maxcol = video_num_columns; maxcol = vc->vc_cols;
p = pos; p = pos;
if (!attr) { if (!attr) {
org0 = org = screen_pos(currcons, p, viewed); org0 = org = screen_pos(vc, p, viewed);
col = p % maxcol; col = p % maxcol;
p += maxcol - col; p += maxcol - col;
...@@ -362,11 +366,11 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -362,11 +366,11 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
unsigned char c = *con_buf0++; unsigned char c = *con_buf0++;
this_round--; this_round--;
vcs_scr_writew(currcons, vcs_scr_writew(vc,
(vcs_scr_readw(currcons, org) & 0xff00) | c, org); (vcs_scr_readw(vc, org) & 0xff00) | c, org);
org++; org++;
if (++col == maxcol) { if (++col == maxcol) {
org = screen_pos(currcons, p, viewed); org = screen_pos(vc, p, viewed);
col = 0; col = 0;
p += maxcol; p += maxcol;
} }
...@@ -375,34 +379,34 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -375,34 +379,34 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
if (p < HEADER_SIZE) { if (p < HEADER_SIZE) {
char header[HEADER_SIZE]; char header[HEADER_SIZE];
getconsxy(currcons, header + 2); getconsxy(vc, header + 2);
while (p < HEADER_SIZE && this_round > 0) { while (p < HEADER_SIZE && this_round > 0) {
this_round--; this_round--;
header[p++] = *con_buf0++; header[p++] = *con_buf0++;
} }
if (!viewed) if (!viewed)
putconsxy(currcons, header + 2); putconsxy(vc, header + 2);
} }
p -= HEADER_SIZE; p -= HEADER_SIZE;
col = (p/2) % maxcol; col = (p/2) % maxcol;
if (this_round > 0) { if (this_round > 0) {
org0 = org = screen_pos(currcons, p/2, viewed); org0 = org = screen_pos(vc, p/2, viewed);
if ((p & 1) && this_round > 0) { if ((p & 1) && this_round > 0) {
char c; char c;
this_round--; this_round--;
c = *con_buf0++; c = *con_buf0++;
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
vcs_scr_writew(currcons, c | vcs_scr_writew(vc, c |
(vcs_scr_readw(currcons, org) & 0xff00), org); (vcs_scr_readw(vc, org) & 0xff00), org);
#else #else
vcs_scr_writew(currcons, (c << 8) | vcs_scr_writew(vc, (c << 8) |
(vcs_scr_readw(currcons, org) & 0xff), org); (vcs_scr_readw(vc, org) & 0xff), org);
#endif #endif
org++; org++;
p++; p++;
if (++col == maxcol) { if (++col == maxcol) {
org = screen_pos(currcons, p/2, viewed); org = screen_pos(vc, p/2, viewed);
col = 0; col = 0;
} }
} }
...@@ -413,11 +417,11 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -413,11 +417,11 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
unsigned short w; unsigned short w;
w = get_unaligned(((const unsigned short *)con_buf0)); w = get_unaligned(((const unsigned short *)con_buf0));
vcs_scr_writew(currcons, w, org++); vcs_scr_writew(vc, w, org++);
con_buf0 += 2; con_buf0 += 2;
this_round -= 2; this_round -= 2;
if (++col == maxcol) { if (++col == maxcol) {
org = screen_pos(currcons, p, viewed); org = screen_pos(vc, p, viewed);
col = 0; col = 0;
p += maxcol; p += maxcol;
} }
...@@ -427,9 +431,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -427,9 +431,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
c = *con_buf0++; c = *con_buf0++;
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
vcs_scr_writew(currcons, (vcs_scr_readw(currcons, org) & 0xff) | (c << 8), org); vcs_scr_writew(vc, (vcs_scr_readw(vc, org) & 0xff) | (c << 8), org);
#else #else
vcs_scr_writew(currcons, (vcs_scr_readw(currcons, org) & 0xff00) | c, org); vcs_scr_writew(vc, (vcs_scr_readw(vc, org) & 0xff00) | c, org);
#endif #endif
} }
} }
......
...@@ -40,15 +40,6 @@ ...@@ -40,15 +40,6 @@
* - Arno Griffioen <arno@usn.nl> * - Arno Griffioen <arno@usn.nl>
* - David Carter <carter@cs.bris.ac.uk> * - David Carter <carter@cs.bris.ac.uk>
* *
* Note that the abstract console driver allows all consoles to be of
* potentially different sizes, so the following variables depend on the
* current console (currcons):
*
* - video_num_columns
* - video_num_lines
* - video_size_row
* - can_do_color
*
* The abstract console driver provides a generic interface for a text * The abstract console driver provides a generic interface for a text
* console. It supports VGA text mode, frame buffer based graphical consoles * console. It supports VGA text mode, frame buffer based graphical consoles
* and special graphics processors that are only accessible through some * and special graphics processors that are only accessible through some
...@@ -146,13 +137,13 @@ static const struct consw *con_driver_map[MAX_NR_CONSOLES]; ...@@ -146,13 +137,13 @@ static const struct consw *con_driver_map[MAX_NR_CONSOLES];
static int con_open(struct tty_struct *, struct file *); static int con_open(struct tty_struct *, struct file *);
static void vc_init(unsigned int console, unsigned int rows, static void vc_init(unsigned int console, unsigned int rows,
unsigned int cols, int do_clear); unsigned int cols, int do_clear);
static void gotoxy(int currcons, int new_x, int new_y); static void gotoxy(struct vc_data *vc, int new_x, int new_y);
static void save_cur(int currcons); static void save_cur(int currcons);
static void reset_terminal(int currcons, int do_clear); static void reset_terminal(int currcons, int do_clear);
static void con_flush_chars(struct tty_struct *tty); static void con_flush_chars(struct tty_struct *tty);
static void set_vesa_blanking(char __user *p); static void set_vesa_blanking(char __user *p);
static void set_cursor(int currcons); static void set_cursor(struct vc_data *vc);
static void hide_cursor(int currcons); static void hide_cursor(struct vc_data *vc);
static void console_callback(void *ignored); static void console_callback(void *ignored);
static void blank_screen_t(unsigned long dummy); static void blank_screen_t(unsigned long dummy);
...@@ -224,27 +215,31 @@ enum { ...@@ -224,27 +215,31 @@ enum {
*/ */
#define IS_FG (currcons == fg_console) #define IS_FG (currcons == fg_console)
#define IS_FG_VC(vc) (vc == vc_cons[fg_console].d)
#define IS_VISIBLE CON_IS_VISIBLE(vc_cons[currcons].d) #define IS_VISIBLE CON_IS_VISIBLE(vc_cons[currcons].d)
#ifdef VT_BUF_VRAM_ONLY #ifdef VT_BUF_VRAM_ONLY
#define DO_UPDATE 0 #define DO_UPDATE 0
#define DO_UPDATE_VC(vc) 0
#else #else
#define DO_UPDATE IS_VISIBLE #define DO_UPDATE IS_VISIBLE
#define DO_UPDATE_VC(vc) CON_IS_VISIBLE(vc)
#endif #endif
static int pm_con_request(struct pm_dev *dev, pm_request_t rqst, void *data); static int pm_con_request(struct pm_dev *dev, pm_request_t rqst, void *data);
static struct pm_dev *pm_con; static struct pm_dev *pm_con;
static inline unsigned short *screenpos(int currcons, int offset, int viewed) static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed)
{ {
unsigned short *p; unsigned short *p;
if (!viewed) if (!viewed)
p = (unsigned short *)(origin + offset); p = (unsigned short *)(vc->vc_origin + offset);
else if (!sw->con_screen_pos) else if (!vc->vc_sw->con_screen_pos)
p = (unsigned short *)(visible_origin + offset); p = (unsigned short *)(vc->vc_visible_origin + offset);
else else
p = sw->con_screen_pos(vc_cons[currcons].d, offset); p = vc->vc_sw->con_screen_pos(vc, offset);
return p; return p;
} }
...@@ -265,14 +260,15 @@ static void scrup(int currcons, unsigned int t, unsigned int b, int nr) ...@@ -265,14 +260,15 @@ static void scrup(int currcons, unsigned int t, unsigned int b, int nr)
if (t+nr >= b) if (t+nr >= b)
nr = b - t - 1; nr = b - t - 1;
if (b > video_num_lines || t >= b || nr < 1) if (b > vc_cons[currcons].d->vc_rows || t >= b || nr < 1)
return; return;
if (IS_VISIBLE && sw->con_scroll(vc_cons[currcons].d, t, b, SM_UP, nr)) if (IS_VISIBLE && sw->con_scroll(vc_cons[currcons].d, t, b, SM_UP, nr))
return; return;
d = (unsigned short *) (origin+video_size_row*t); d = (unsigned short *) (origin+vc_cons[currcons].d->vc_size_row*t);
s = (unsigned short *) (origin+video_size_row*(t+nr)); s = (unsigned short *) (origin+vc_cons[currcons].d->vc_size_row*(t+nr));
scr_memmovew(d, s, (b-t-nr) * video_size_row); scr_memmovew(d, s, (b-t-nr) * vc_cons[currcons].d->vc_size_row);
scr_memsetw(d + (b-t-nr) * video_num_columns, video_erase_char, video_size_row*nr); scr_memsetw(d + (b-t-nr) * vc_cons[currcons].d->vc_cols, video_erase_char,
vc_cons[currcons].d->vc_size_row * nr);
} }
static void static void
...@@ -283,40 +279,40 @@ scrdown(int currcons, unsigned int t, unsigned int b, int nr) ...@@ -283,40 +279,40 @@ scrdown(int currcons, unsigned int t, unsigned int b, int nr)
if (t+nr >= b) if (t+nr >= b)
nr = b - t - 1; nr = b - t - 1;
if (b > video_num_lines || t >= b || nr < 1) if (b > vc_cons[currcons].d->vc_rows || t >= b || nr < 1)
return; return;
if (IS_VISIBLE && sw->con_scroll(vc_cons[currcons].d, t, b, SM_DOWN, nr)) if (IS_VISIBLE && sw->con_scroll(vc_cons[currcons].d, t, b, SM_DOWN, nr))
return; return;
s = (unsigned short *) (origin+video_size_row*t); s = (unsigned short *) (origin+vc_cons[currcons].d->vc_size_row*t);
step = video_num_columns * nr; step = vc_cons[currcons].d->vc_cols * nr;
scr_memmovew(s + step, s, (b-t-nr)*video_size_row); scr_memmovew(s + step, s, (b-t-nr)*vc_cons[currcons].d->vc_size_row);
scr_memsetw(s, video_erase_char, 2*step); scr_memsetw(s, video_erase_char, 2*step);
} }
static void do_update_region(int currcons, unsigned long start, int count) static void do_update_region(struct vc_data *vc, unsigned long start, int count)
{ {
#ifndef VT_BUF_VRAM_ONLY #ifndef VT_BUF_VRAM_ONLY
unsigned int xx, yy, offset; unsigned int xx, yy, offset;
u16 *p; u16 *p;
p = (u16 *) start; p = (u16 *) start;
if (!sw->con_getxy) { if (!vc->vc_sw->con_getxy) {
offset = (start - origin) / 2; offset = (start - vc->vc_origin) / 2;
xx = offset % video_num_columns; xx = offset % vc->vc_cols;
yy = offset / video_num_columns; yy = offset / vc->vc_cols;
} else { } else {
int nxx, nyy; int nxx, nyy;
start = sw->con_getxy(vc_cons[currcons].d, start, &nxx, &nyy); start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy);
xx = nxx; yy = nyy; xx = nxx; yy = nyy;
} }
for(;;) { for(;;) {
u16 attrib = scr_readw(p) & 0xff00; u16 attrib = scr_readw(p) & 0xff00;
int startx = xx; int startx = xx;
u16 *q = p; u16 *q = p;
while (xx < video_num_columns && count) { while (xx < vc->vc_cols && count) {
if (attrib != (scr_readw(p) & 0xff00)) { if (attrib != (scr_readw(p) & 0xff00)) {
if (p > q) if (p > q)
sw->con_putcs(vc_cons[currcons].d, q, p-q, yy, startx); vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
startx = xx; startx = xx;
q = p; q = p;
attrib = scr_readw(p) & 0xff00; attrib = scr_readw(p) & 0xff00;
...@@ -326,14 +322,14 @@ static void do_update_region(int currcons, unsigned long start, int count) ...@@ -326,14 +322,14 @@ static void do_update_region(int currcons, unsigned long start, int count)
count--; count--;
} }
if (p > q) if (p > q)
sw->con_putcs(vc_cons[currcons].d, q, p-q, yy, startx); vc->vc_sw->con_putcs(vc, q, p-q, yy, startx);
if (!count) if (!count)
break; break;
xx = 0; xx = 0;
yy++; yy++;
if (sw->con_getxy) { if (vc->vc_sw->con_getxy) {
p = (u16 *)start; p = (u16 *)start;
start = sw->con_getxy(vc_cons[currcons].d, start, NULL, NULL); start = vc->vc_sw->con_getxy(vc, start, NULL, NULL);
} }
} }
#endif #endif
...@@ -344,9 +340,9 @@ void update_region(int currcons, unsigned long start, int count) ...@@ -344,9 +340,9 @@ void update_region(int currcons, unsigned long start, int count)
WARN_CONSOLE_UNLOCKED(); WARN_CONSOLE_UNLOCKED();
if (DO_UPDATE) { if (DO_UPDATE) {
hide_cursor(currcons); hide_cursor(vc_cons[currcons].d);
do_update_region(currcons, start, count); do_update_region(vc_cons[currcons].d, start, count);
set_cursor(currcons); set_cursor(vc_cons[currcons].d);
} }
} }
...@@ -370,7 +366,7 @@ static u8 build_attr(int currcons, u8 _color, u8 _intensity, u8 _blink, u8 _unde ...@@ -370,7 +366,7 @@ static u8 build_attr(int currcons, u8 _color, u8 _intensity, u8 _blink, u8 _unde
*/ */
{ {
u8 a = color; u8 a = color;
if (!can_do_color) if (!vc_cons[currcons].d->vc_can_do_color)
return _intensity | return _intensity |
(_underline ? 4 : 0) | (_underline ? 4 : 0) |
(_reverse ? 8 : 0) | (_reverse ? 8 : 0) |
...@@ -401,31 +397,30 @@ static void update_attr(int currcons) ...@@ -401,31 +397,30 @@ static void update_attr(int currcons)
} }
/* Note: inverting the screen twice should revert to the original state */ /* Note: inverting the screen twice should revert to the original state */
void invert_screen(struct vc_data *vc, int offset, int count, int viewed)
void invert_screen(int currcons, int offset, int count, int viewed)
{ {
unsigned short *p; unsigned short *p;
WARN_CONSOLE_UNLOCKED(); WARN_CONSOLE_UNLOCKED();
count /= 2; count /= 2;
p = screenpos(currcons, offset, viewed); p = screenpos(vc, offset, viewed);
if (sw->con_invert_region) if (vc->vc_sw->con_invert_region)
sw->con_invert_region(vc_cons[currcons].d, p, count); vc->vc_sw->con_invert_region(vc, p, count);
#ifndef VT_BUF_VRAM_ONLY #ifndef VT_BUF_VRAM_ONLY
else { else {
u16 *q = p; u16 *q = p;
int cnt = count; int cnt = count;
u16 a; u16 a;
if (!can_do_color) { if (!vc->vc_can_do_color) {
while (cnt--) { while (cnt--) {
a = scr_readw(q); a = scr_readw(q);
a ^= 0x0800; a ^= 0x0800;
scr_writew(a, q); scr_writew(a, q);
q++; q++;
} }
} else if (hi_font_mask == 0x100) { } else if (vc->vc_hi_font_mask == 0x100) {
while (cnt--) { while (cnt--) {
a = scr_readw(q); a = scr_readw(q);
a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | (((a) & 0x0e00) << 4); a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | (((a) & 0x0e00) << 4);
...@@ -442,12 +437,12 @@ void invert_screen(int currcons, int offset, int count, int viewed) ...@@ -442,12 +437,12 @@ void invert_screen(int currcons, int offset, int count, int viewed)
} }
} }
#endif #endif
if (DO_UPDATE) if (DO_UPDATE_VC(vc))
do_update_region(currcons, (unsigned long) p, count); do_update_region(vc, (unsigned long) p, count);
} }
/* used by selection: complement pointer position */ /* used by selection: complement pointer position */
void complement_pos(int currcons, int offset) void complement_pos(struct vc_data *vc, int offset)
{ {
static unsigned short *p; static unsigned short *p;
static unsigned short old; static unsigned short old;
...@@ -457,21 +452,21 @@ void complement_pos(int currcons, int offset) ...@@ -457,21 +452,21 @@ void complement_pos(int currcons, int offset)
if (p) { if (p) {
scr_writew(old, p); scr_writew(old, p);
if (DO_UPDATE) if (DO_UPDATE_VC(vc))
sw->con_putc(vc_cons[currcons].d, old, oldy, oldx); vc->vc_sw->con_putc(vc, old, oldy, oldx);
} }
if (offset == -1) if (offset == -1)
p = NULL; p = NULL;
else { else {
unsigned short new; unsigned short new;
p = screenpos(currcons, offset, 1); p = screenpos(vc, offset, 1);
old = scr_readw(p); old = scr_readw(p);
new = old ^ complement_mask; new = old ^ vc->vc_complement_mask;
scr_writew(new, p); scr_writew(new, p);
if (DO_UPDATE) { if (DO_UPDATE_VC(vc)) {
oldx = (offset >> 1) % video_num_columns; oldx = (offset >> 1) % vc->vc_cols;
oldy = (offset >> 1) / video_num_columns; oldy = (offset >> 1) / vc->vc_cols;
sw->con_putc(vc_cons[currcons].d, new, oldy, oldx); vc->vc_sw->con_putc(vc, new, oldy, oldx);
} }
} }
} }
...@@ -480,7 +475,7 @@ static void insert_char(int currcons, unsigned int nr) ...@@ -480,7 +475,7 @@ static void insert_char(int currcons, unsigned int nr)
{ {
unsigned short *p, *q = (unsigned short *) pos; unsigned short *p, *q = (unsigned short *) pos;
p = q + video_num_columns - nr - x; p = q + vc_cons[currcons].d->vc_cols - nr - x;
while (--p >= q) while (--p >= q)
scr_writew(scr_readw(p), p + nr); scr_writew(scr_readw(p), p + nr);
scr_memsetw(q, video_erase_char, nr*2); scr_memsetw(q, video_erase_char, nr*2);
...@@ -488,7 +483,7 @@ static void insert_char(int currcons, unsigned int nr) ...@@ -488,7 +483,7 @@ static void insert_char(int currcons, unsigned int nr)
if (DO_UPDATE) { if (DO_UPDATE) {
unsigned short oldattr = attr; unsigned short oldattr = attr;
sw->con_bmove(vc_cons[currcons].d,y,x,y,x+nr,1, sw->con_bmove(vc_cons[currcons].d,y,x,y,x+nr,1,
video_num_columns-x-nr); vc_cons[currcons].d->vc_cols-x-nr);
attr = video_erase_char >> 8; attr = video_erase_char >> 8;
while (nr--) while (nr--)
sw->con_putc(vc_cons[currcons].d, sw->con_putc(vc_cons[currcons].d,
...@@ -502,7 +497,7 @@ static void delete_char(int currcons, unsigned int nr) ...@@ -502,7 +497,7 @@ static void delete_char(int currcons, unsigned int nr)
unsigned int i = x; unsigned int i = x;
unsigned short *p = (unsigned short *) pos; unsigned short *p = (unsigned short *) pos;
while (++i <= video_num_columns - nr) { while (++i <= vc_cons[currcons].d->vc_cols - nr) {
scr_writew(scr_readw(p+nr), p); scr_writew(scr_readw(p+nr), p);
p++; p++;
} }
...@@ -511,22 +506,22 @@ static void delete_char(int currcons, unsigned int nr) ...@@ -511,22 +506,22 @@ static void delete_char(int currcons, unsigned int nr)
if (DO_UPDATE) { if (DO_UPDATE) {
unsigned short oldattr = attr; unsigned short oldattr = attr;
sw->con_bmove(vc_cons[currcons].d, y, x+nr, y, x, 1, sw->con_bmove(vc_cons[currcons].d, y, x+nr, y, x, 1,
video_num_columns-x-nr); vc_cons[currcons].d->vc_cols-x-nr);
attr = video_erase_char >> 8; attr = video_erase_char >> 8;
while (nr--) while (nr--)
sw->con_putc(vc_cons[currcons].d, sw->con_putc(vc_cons[currcons].d,
video_erase_char, y, video_erase_char, y,
video_num_columns-1-nr); vc_cons[currcons].d->vc_cols-1-nr);
attr = oldattr; attr = oldattr;
} }
} }
static int softcursor_original; static int softcursor_original;
static void add_softcursor(int currcons) static void add_softcursor(struct vc_data *vc)
{ {
int i = scr_readw((u16 *) pos); int i = scr_readw((u16 *) vc->vc_pos);
u32 type = cursor_type; u32 type = vc->vc_cursor_type;
if (! (type & 0x10)) return; if (! (type & 0x10)) return;
if (softcursor_original != -1) return; if (softcursor_original != -1) return;
...@@ -535,41 +530,43 @@ static void add_softcursor(int currcons) ...@@ -535,41 +530,43 @@ static void add_softcursor(int currcons)
i ^= ((type) & 0xff00 ); i ^= ((type) & 0xff00 );
if ((type & 0x20) && ((softcursor_original & 0x7000) == (i & 0x7000))) i ^= 0x7000; if ((type & 0x20) && ((softcursor_original & 0x7000) == (i & 0x7000))) i ^= 0x7000;
if ((type & 0x40) && ((i & 0x700) == ((i & 0x7000) >> 4))) i ^= 0x0700; if ((type & 0x40) && ((i & 0x700) == ((i & 0x7000) >> 4))) i ^= 0x0700;
scr_writew(i, (u16 *) pos); scr_writew(i, (u16 *) vc->vc_pos);
if (DO_UPDATE) if (DO_UPDATE_VC(vc))
sw->con_putc(vc_cons[currcons].d, i, y, x); vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x);
} }
static void hide_softcursor(int currcons) static void hide_softcursor(struct vc_data *vc)
{ {
if (softcursor_original != -1) { if (softcursor_original != -1) {
scr_writew(softcursor_original,(u16 *) pos); scr_writew(softcursor_original, (u16 *)vc->vc_pos);
if (DO_UPDATE) if (DO_UPDATE_VC(vc))
sw->con_putc(vc_cons[currcons].d, softcursor_original, y, x); vc->vc_sw->con_putc(vc, softcursor_original,
vc->vc_y, vc->vc_x);
softcursor_original = -1; softcursor_original = -1;
} }
} }
static void hide_cursor(int currcons) static void hide_cursor(struct vc_data *vc)
{ {
if (currcons == sel_cons) if (vc == sel_cons)
clear_selection(); clear_selection();
sw->con_cursor(vc_cons[currcons].d,CM_ERASE); vc->vc_sw->con_cursor(vc, CM_ERASE);
hide_softcursor(currcons); hide_softcursor(vc);
} }
static void set_cursor(int currcons) static void set_cursor(struct vc_data *vc)
{ {
if (!IS_FG || console_blanked || vcmode == KD_GRAPHICS) if (!IS_FG_VC(vc) || console_blanked ||
vc->vc_vt->vc_mode == KD_GRAPHICS)
return; return;
if (deccm) { if (vc->vc_deccm) {
if (currcons == sel_cons) if (vc == sel_cons)
clear_selection(); clear_selection();
add_softcursor(currcons); add_softcursor(vc);
if ((cursor_type & 0x0f) != 1) if ((vc->vc_cursor_type & 0x0f) != 1)
sw->con_cursor(vc_cons[currcons].d,CM_DRAW); vc->vc_sw->con_cursor(vc, CM_DRAW);
} else } else
hide_cursor(currcons); hide_cursor(vc);
} }
static void set_origin(int currcons) static void set_origin(int currcons)
...@@ -582,7 +579,7 @@ static void set_origin(int currcons) ...@@ -582,7 +579,7 @@ static void set_origin(int currcons)
origin = (unsigned long) screenbuf; origin = (unsigned long) screenbuf;
visible_origin = origin; visible_origin = origin;
scr_end = origin + screenbuf_size; scr_end = origin + screenbuf_size;
pos = origin + video_size_row*y + 2*x; pos = origin + vc_cons[currcons].d->vc_size_row*y + 2*x;
} }
static inline void save_screen(int currcons) static inline void save_screen(int currcons)
...@@ -623,7 +620,7 @@ void redraw_screen(int new_console, int is_switch) ...@@ -623,7 +620,7 @@ void redraw_screen(int new_console, int is_switch)
if (is_switch) { if (is_switch) {
currcons = fg_console; currcons = fg_console;
hide_cursor(currcons); hide_cursor(vc_cons[currcons].d);
if (fg_console != new_console) { if (fg_console != new_console) {
struct vc_data **display = vc_cons[new_console].d->vc_display_fg; struct vc_data **display = vc_cons[new_console].d->vc_display_fg;
old_console = (*display) ? (*display)->vc_num : fg_console; old_console = (*display) ? (*display)->vc_num : fg_console;
...@@ -640,7 +637,7 @@ void redraw_screen(int new_console, int is_switch) ...@@ -640,7 +637,7 @@ void redraw_screen(int new_console, int is_switch)
} }
} else { } else {
currcons = new_console; currcons = new_console;
hide_cursor(currcons); hide_cursor(vc_cons[currcons].d);
} }
if (redraw) { if (redraw) {
...@@ -661,9 +658,9 @@ void redraw_screen(int new_console, int is_switch) ...@@ -661,9 +658,9 @@ void redraw_screen(int new_console, int is_switch)
clear_buffer_attributes(currcons); clear_buffer_attributes(currcons);
} }
if (update && vcmode != KD_GRAPHICS) if (update && vcmode != KD_GRAPHICS)
do_update_region(currcons, origin, screenbuf_size/2); do_update_region(vc_cons[currcons].d, origin, screenbuf_size/2);
} }
set_cursor(currcons); set_cursor(vc_cons[currcons].d);
if (is_switch) { if (is_switch) {
set_leds(); set_leds();
compute_shiftstate(); compute_shiftstate();
...@@ -696,13 +693,14 @@ static void visual_init(int currcons, int init) ...@@ -696,13 +693,14 @@ static void visual_init(int currcons, int init)
vc_cons[currcons].d->vc_uni_pagedir = 0; vc_cons[currcons].d->vc_uni_pagedir = 0;
hi_font_mask = 0; hi_font_mask = 0;
complement_mask = 0; complement_mask = 0;
can_do_color = 0; vc_cons[currcons].d->vc_can_do_color = 0;
sw->con_init(vc_cons[currcons].d, init); sw->con_init(vc_cons[currcons].d, init);
if (!complement_mask) if (!complement_mask)
complement_mask = can_do_color ? 0x7700 : 0x0800; complement_mask =
vc_cons[currcons].d->vc_can_do_color ? 0x7700 : 0x0800;
s_complement_mask = complement_mask; s_complement_mask = complement_mask;
video_size_row = video_num_columns<<1; vc_cons[currcons].d->vc_size_row = vc_cons[currcons].d->vc_cols<<1;
screenbuf_size = video_num_lines*video_size_row; screenbuf_size = vc_cons[currcons].d->vc_rows * vc_cons[currcons].d->vc_size_row;
} }
int vc_allocate(unsigned int currcons) /* return 0 on success */ int vc_allocate(unsigned int currcons) /* return 0 on success */
...@@ -730,6 +728,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ ...@@ -730,6 +728,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
memset((void *)p, 0, structsize); memset((void *)p, 0, structsize);
vc_cons[currcons].d = (struct vc_data *)p; vc_cons[currcons].d = (struct vc_data *)p;
vt_cons[currcons] = (struct vt_struct *)(p+sizeof(struct vc_data)); vt_cons[currcons] = (struct vt_struct *)(p+sizeof(struct vc_data));
vc_cons[currcons].d->vc_vt = vt_cons[currcons];
visual_init(currcons, 1); visual_init(currcons, 1);
if (!*vc_cons[currcons].d->vc_uni_pagedir_loc) if (!*vc_cons[currcons].d->vc_uni_pagedir_loc)
con_set_default_unimap(currcons); con_set_default_unimap(currcons);
...@@ -742,7 +741,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ ...@@ -742,7 +741,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
} }
screenbuf = (unsigned short *) q; screenbuf = (unsigned short *) q;
kmalloced = 1; kmalloced = 1;
vc_init(currcons, video_num_lines, video_num_columns, 1); vc_init(currcons, vc_cons[currcons].d->vc_rows, vc_cons[currcons].d->vc_cols, 1);
if (!pm_con) { if (!pm_con) {
pm_con = pm_register(PM_SYS_DEV, pm_con = pm_register(PM_SYS_DEV,
...@@ -785,21 +784,21 @@ int vc_resize(int currcons, unsigned int cols, unsigned int lines) ...@@ -785,21 +784,21 @@ int vc_resize(int currcons, unsigned int cols, unsigned int lines)
if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW) if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
return -EINVAL; return -EINVAL;
new_cols = (cols ? cols : video_num_columns); new_cols = (cols ? cols : vc_cons[currcons].d->vc_cols);
new_rows = (lines ? lines : video_num_lines); new_rows = (lines ? lines : vc_cons[currcons].d->vc_rows);
new_row_size = new_cols << 1; new_row_size = new_cols << 1;
new_screen_size = new_row_size * new_rows; new_screen_size = new_row_size * new_rows;
if (new_cols == video_num_columns && new_rows == video_num_lines) if (new_cols == vc_cons[currcons].d->vc_cols && new_rows == vc_cons[currcons].d->vc_rows)
return 0; return 0;
newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER); newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER);
if (!newscreen) if (!newscreen)
return -ENOMEM; return -ENOMEM;
old_rows = video_num_lines; old_rows = vc_cons[currcons].d->vc_rows;
old_cols = video_num_columns; old_cols = vc_cons[currcons].d->vc_cols;
old_row_size = video_size_row; old_row_size = vc_cons[currcons].d->vc_size_row;
old_screen_size = screenbuf_size; old_screen_size = screenbuf_size;
err = resize_screen(currcons, new_cols, new_rows); err = resize_screen(currcons, new_cols, new_rows);
...@@ -808,9 +807,9 @@ int vc_resize(int currcons, unsigned int cols, unsigned int lines) ...@@ -808,9 +807,9 @@ int vc_resize(int currcons, unsigned int cols, unsigned int lines)
return err; return err;
} }
video_num_lines = new_rows; vc_cons[currcons].d->vc_rows = new_rows;
video_num_columns = new_cols; vc_cons[currcons].d->vc_cols = new_cols;
video_size_row = new_row_size; vc_cons[currcons].d->vc_size_row = new_row_size;
screenbuf_size = new_screen_size; screenbuf_size = new_screen_size;
rlth = min(old_row_size, new_row_size); rlth = min(old_row_size, new_row_size);
...@@ -841,16 +840,16 @@ int vc_resize(int currcons, unsigned int cols, unsigned int lines) ...@@ -841,16 +840,16 @@ int vc_resize(int currcons, unsigned int cols, unsigned int lines)
/* do part of a reset_terminal() */ /* do part of a reset_terminal() */
top = 0; top = 0;
bottom = video_num_lines; bottom = vc_cons[currcons].d->vc_rows;
gotoxy(currcons, x, y); gotoxy(vc_cons[currcons].d, x, y);
save_cur(currcons); save_cur(currcons);
if (vc_cons[currcons].d->vc_tty) { if (vc_cons[currcons].d->vc_tty) {
struct winsize ws, *cws = &vc_cons[currcons].d->vc_tty->winsize; struct winsize ws, *cws = &vc_cons[currcons].d->vc_tty->winsize;
memset(&ws, 0, sizeof(ws)); memset(&ws, 0, sizeof(ws));
ws.ws_row = video_num_lines; ws.ws_row = vc_cons[currcons].d->vc_rows;
ws.ws_col = video_num_columns; ws.ws_col = vc_cons[currcons].d->vc_cols;
ws.ws_ypixel = video_scan_lines; ws.ws_ypixel = video_scan_lines;
if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) && if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) &&
vc_cons[currcons].d->vc_tty->pgrp > 0) vc_cons[currcons].d->vc_tty->pgrp > 0)
...@@ -913,38 +912,40 @@ int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa, ...@@ -913,38 +912,40 @@ int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
* might also be negative. If the given position is out of * might also be negative. If the given position is out of
* bounds, the cursor is placed at the nearest margin. * bounds, the cursor is placed at the nearest margin.
*/ */
static void gotoxy(int currcons, int new_x, int new_y) static void gotoxy(struct vc_data *vc, int new_x, int new_y)
{ {
int min_y, max_y; int min_y, max_y;
if (new_x < 0) if (new_x < 0)
x = 0; vc->vc_x = 0;
else else {
if (new_x >= video_num_columns) if (new_x >= vc->vc_cols)
x = video_num_columns - 1; vc->vc_x = vc->vc_cols - 1;
else else
x = new_x; vc->vc_x = new_x;
if (decom) { }
min_y = top;
max_y = bottom; if (vc->vc_decom) {
min_y = vc->vc_top;
max_y = vc->vc_bottom;
} else { } else {
min_y = 0; min_y = 0;
max_y = video_num_lines; max_y = vc->vc_rows;
} }
if (new_y < min_y) if (new_y < min_y)
y = min_y; vc->vc_y = min_y;
else if (new_y >= max_y) else if (new_y >= max_y)
y = max_y - 1; vc->vc_y = max_y - 1;
else else
y = new_y; vc->vc_y = new_y;
pos = origin + y*video_size_row + (x<<1); vc->vc_pos = vc->vc_origin + vc->vc_y * vc->vc_size_row + (vc->vc_x<<1);
need_wrap = 0; vc->vc_need_wrap = 0;
} }
/* for absolute user moves, when decom is set */ /* for absolute user moves, when decom is set */
static void gotoxay(int currcons, int new_x, int new_y) static void gotoxay(int currcons, int new_x, int new_y)
{ {
gotoxy(currcons, new_x, decom ? (top+new_y) : new_y); gotoxy(vc_cons[currcons].d, new_x, decom ? (top+new_y) : new_y);
} }
void scrollback(int lines) void scrollback(int lines)
...@@ -952,7 +953,7 @@ void scrollback(int lines) ...@@ -952,7 +953,7 @@ void scrollback(int lines)
int currcons = fg_console; int currcons = fg_console;
if (!lines) if (!lines)
lines = video_num_lines/2; lines = vc_cons[currcons].d->vc_rows/2;
scrolldelta(-lines); scrolldelta(-lines);
} }
...@@ -961,7 +962,7 @@ void scrollfront(int lines) ...@@ -961,7 +962,7 @@ void scrollfront(int lines)
int currcons = fg_console; int currcons = fg_console;
if (!lines) if (!lines)
lines = video_num_lines/2; lines = vc_cons[currcons].d->vc_rows/2;
scrolldelta(lines); scrolldelta(lines);
} }
...@@ -972,9 +973,9 @@ static void lf(int currcons) ...@@ -972,9 +973,9 @@ static void lf(int currcons)
*/ */
if (y+1 == bottom) if (y+1 == bottom)
scrup(currcons,top,bottom,1); scrup(currcons,top,bottom,1);
else if (y < video_num_lines-1) { else if (y < vc_cons[currcons].d->vc_rows-1) {
y++; y++;
pos += video_size_row; pos += vc_cons[currcons].d->vc_size_row;
} }
need_wrap = 0; need_wrap = 0;
} }
...@@ -988,7 +989,7 @@ static void ri(int currcons) ...@@ -988,7 +989,7 @@ static void ri(int currcons)
scrdown(currcons,top,bottom,1); scrdown(currcons,top,bottom,1);
else if (y > 0) { else if (y > 0) {
y--; y--;
pos -= video_size_row; pos -= vc_cons[currcons].d->vc_size_row;
} }
need_wrap = 0; need_wrap = 0;
} }
...@@ -1025,10 +1026,10 @@ static void csi_J(int currcons, int vpar) ...@@ -1025,10 +1026,10 @@ static void csi_J(int currcons, int vpar)
if (DO_UPDATE) { if (DO_UPDATE) {
/* do in two stages */ /* do in two stages */
sw->con_clear(vc_cons[currcons].d, y, x, 1, sw->con_clear(vc_cons[currcons].d, y, x, 1,
video_num_columns-x); vc_cons[currcons].d->vc_cols-x);
sw->con_clear(vc_cons[currcons].d, y+1, 0, sw->con_clear(vc_cons[currcons].d, y+1, 0,
video_num_lines-y-1, vc_cons[currcons].d->vc_rows-y-1,
video_num_columns); vc_cons[currcons].d->vc_cols);
} }
break; break;
case 1: /* erase from start to cursor */ case 1: /* erase from start to cursor */
...@@ -1037,18 +1038,18 @@ static void csi_J(int currcons, int vpar) ...@@ -1037,18 +1038,18 @@ static void csi_J(int currcons, int vpar)
if (DO_UPDATE) { if (DO_UPDATE) {
/* do in two stages */ /* do in two stages */
sw->con_clear(vc_cons[currcons].d, 0, 0, y, sw->con_clear(vc_cons[currcons].d, 0, 0, y,
video_num_columns); vc_cons[currcons].d->vc_cols);
sw->con_clear(vc_cons[currcons].d, y, 0, 1, sw->con_clear(vc_cons[currcons].d, y, 0, 1,
x + 1); x + 1);
} }
break; break;
case 2: /* erase whole display */ case 2: /* erase whole display */
count = video_num_columns * video_num_lines; count = vc_cons[currcons].d->vc_cols * vc_cons[currcons].d->vc_rows;
start = (unsigned short *) origin; start = (unsigned short *) origin;
if (DO_UPDATE) if (DO_UPDATE)
sw->con_clear(vc_cons[currcons].d, 0, 0, sw->con_clear(vc_cons[currcons].d, 0, 0,
video_num_lines, vc_cons[currcons].d->vc_rows,
video_num_columns); vc_cons[currcons].d->vc_cols);
break; break;
default: default:
return; return;
...@@ -1064,11 +1065,11 @@ static void csi_K(int currcons, int vpar) ...@@ -1064,11 +1065,11 @@ static void csi_K(int currcons, int vpar)
switch (vpar) { switch (vpar) {
case 0: /* erase from cursor to end of line */ case 0: /* erase from cursor to end of line */
count = video_num_columns-x; count = vc_cons[currcons].d->vc_cols-x;
start = (unsigned short *) pos; start = (unsigned short *) pos;
if (DO_UPDATE) if (DO_UPDATE)
sw->con_clear(vc_cons[currcons].d, y, x, 1, sw->con_clear(vc_cons[currcons].d, y, x, 1,
video_num_columns-x); vc_cons[currcons].d->vc_cols-x);
break; break;
case 1: /* erase from start of line to cursor */ case 1: /* erase from start of line to cursor */
start = (unsigned short *) (pos - (x<<1)); start = (unsigned short *) (pos - (x<<1));
...@@ -1079,10 +1080,10 @@ static void csi_K(int currcons, int vpar) ...@@ -1079,10 +1080,10 @@ static void csi_K(int currcons, int vpar)
break; break;
case 2: /* erase whole line */ case 2: /* erase whole line */
start = (unsigned short *) (pos - (x<<1)); start = (unsigned short *) (pos - (x<<1));
count = video_num_columns; count = vc_cons[currcons].d->vc_cols;
if (DO_UPDATE) if (DO_UPDATE)
sw->con_clear(vc_cons[currcons].d, y, 0, 1, sw->con_clear(vc_cons[currcons].d, y, 0, 1,
video_num_columns); vc_cons[currcons].d->vc_cols);
break; break;
default: default:
return; return;
...@@ -1097,7 +1098,7 @@ static void csi_X(int currcons, int vpar) /* erase the following vpar positions ...@@ -1097,7 +1098,7 @@ static void csi_X(int currcons, int vpar) /* erase the following vpar positions
if (!vpar) if (!vpar)
vpar++; vpar++;
count = (vpar > video_num_columns-x) ? (video_num_columns-x) : vpar; count = (vpar > vc_cons[currcons].d->vc_cols-x) ? (vc_cons[currcons].d->vc_cols-x) : vpar;
scr_memsetw((unsigned short *) pos, video_erase_char, 2 * count); scr_memsetw((unsigned short *) pos, video_erase_char, 2 * count);
if (DO_UPDATE) if (DO_UPDATE)
...@@ -1270,7 +1271,7 @@ static void set_mode(int currcons, int on_off) ...@@ -1270,7 +1271,7 @@ static void set_mode(int currcons, int on_off)
case 3: /* 80/132 mode switch unimplemented */ case 3: /* 80/132 mode switch unimplemented */
deccolm = on_off; deccolm = on_off;
#if 0 #if 0
(void) vc_resize(deccolm ? 132 : 80, video_num_lines); (void) vc_resize(deccolm ? 132 : 80, vc_cons[currcons].d->vc_rows);
/* this alone does not suffice; some user mode /* this alone does not suffice; some user mode
utility has to change the hardware regs */ utility has to change the hardware regs */
#endif #endif
...@@ -1278,7 +1279,7 @@ static void set_mode(int currcons, int on_off) ...@@ -1278,7 +1279,7 @@ static void set_mode(int currcons, int on_off)
case 5: /* Inverted screen on/off */ case 5: /* Inverted screen on/off */
if (decscnm != on_off) { if (decscnm != on_off) {
decscnm = on_off; decscnm = on_off;
invert_screen(currcons, 0, screenbuf_size, 0); invert_screen(vc_cons[currcons].d, 0, screenbuf_size, 0);
update_attr(currcons); update_attr(currcons);
} }
break; break;
...@@ -1325,14 +1326,16 @@ static void setterm_command(int currcons) ...@@ -1325,14 +1326,16 @@ static void setterm_command(int currcons)
{ {
switch(par[0]) { switch(par[0]) {
case 1: /* set color for underline mode */ case 1: /* set color for underline mode */
if (can_do_color && par[1] < 16) { if (vc_cons[currcons].d->vc_can_do_color &&
par[1] < 16) {
ulcolor = color_table[par[1]]; ulcolor = color_table[par[1]];
if (underline) if (underline)
update_attr(currcons); update_attr(currcons);
} }
break; break;
case 2: /* set color for half intensity mode */ case 2: /* set color for half intensity mode */
if (can_do_color && par[1] < 16) { if (vc_cons[currcons].d->vc_can_do_color &&
par[1] < 16) {
halfcolor = color_table[par[1]]; halfcolor = color_table[par[1]];
if (intensity == 0) if (intensity == 0)
update_attr(currcons); update_attr(currcons);
...@@ -1381,8 +1384,8 @@ static void setterm_command(int currcons) ...@@ -1381,8 +1384,8 @@ static void setterm_command(int currcons)
/* console_sem is held */ /* console_sem is held */
static void csi_at(int currcons, unsigned int nr) static void csi_at(int currcons, unsigned int nr)
{ {
if (nr > video_num_columns - x) if (nr > vc_cons[currcons].d->vc_cols - x)
nr = video_num_columns - x; nr = vc_cons[currcons].d->vc_cols - x;
else if (!nr) else if (!nr)
nr = 1; nr = 1;
insert_char(currcons, nr); insert_char(currcons, nr);
...@@ -1391,8 +1394,8 @@ static void csi_at(int currcons, unsigned int nr) ...@@ -1391,8 +1394,8 @@ static void csi_at(int currcons, unsigned int nr)
/* console_sem is held */ /* console_sem is held */
static void csi_L(int currcons, unsigned int nr) static void csi_L(int currcons, unsigned int nr)
{ {
if (nr > video_num_lines - y) if (nr > vc_cons[currcons].d->vc_rows - y)
nr = video_num_lines - y; nr = vc_cons[currcons].d->vc_rows - y;
else if (!nr) else if (!nr)
nr = 1; nr = 1;
scrdown(currcons,y,bottom,nr); scrdown(currcons,y,bottom,nr);
...@@ -1402,8 +1405,8 @@ static void csi_L(int currcons, unsigned int nr) ...@@ -1402,8 +1405,8 @@ static void csi_L(int currcons, unsigned int nr)
/* console_sem is held */ /* console_sem is held */
static void csi_P(int currcons, unsigned int nr) static void csi_P(int currcons, unsigned int nr)
{ {
if (nr > video_num_columns - x) if (nr > vc_cons[currcons].d->vc_cols - x)
nr = video_num_columns - x; nr = vc_cons[currcons].d->vc_cols - x;
else if (!nr) else if (!nr)
nr = 1; nr = 1;
delete_char(currcons, nr); delete_char(currcons, nr);
...@@ -1412,8 +1415,8 @@ static void csi_P(int currcons, unsigned int nr) ...@@ -1412,8 +1415,8 @@ static void csi_P(int currcons, unsigned int nr)
/* console_sem is held */ /* console_sem is held */
static void csi_M(int currcons, unsigned int nr) static void csi_M(int currcons, unsigned int nr)
{ {
if (nr > video_num_lines - y) if (nr > vc_cons[currcons].d->vc_rows - y)
nr = video_num_lines - y; nr = vc_cons[currcons].d->vc_rows - y;
else if (!nr) else if (!nr)
nr=1; nr=1;
scrup(currcons,y,bottom,nr); scrup(currcons,y,bottom,nr);
...@@ -1438,7 +1441,7 @@ static void save_cur(int currcons) ...@@ -1438,7 +1441,7 @@ static void save_cur(int currcons)
/* console_sem is held */ /* console_sem is held */
static void restore_cur(int currcons) static void restore_cur(int currcons)
{ {
gotoxy(currcons,saved_x,saved_y); gotoxy(vc_cons[currcons].d,saved_x,saved_y);
intensity = s_intensity; intensity = s_intensity;
underline = s_underline; underline = s_underline;
blink = s_blink; blink = s_blink;
...@@ -1460,7 +1463,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey, ...@@ -1460,7 +1463,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
static void reset_terminal(int currcons, int do_clear) static void reset_terminal(int currcons, int do_clear)
{ {
top = 0; top = 0;
bottom = video_num_lines; bottom = vc_cons[currcons].d->vc_rows;
vc_state = ESnormal; vc_state = ESnormal;
ques = 0; ques = 0;
translate = set_translate(LAT1_MAP,currcons); translate = set_translate(LAT1_MAP,currcons);
...@@ -1507,7 +1510,7 @@ static void reset_terminal(int currcons, int do_clear) ...@@ -1507,7 +1510,7 @@ static void reset_terminal(int currcons, int do_clear)
bell_pitch = DEFAULT_BELL_PITCH; bell_pitch = DEFAULT_BELL_PITCH;
bell_duration = DEFAULT_BELL_DURATION; bell_duration = DEFAULT_BELL_DURATION;
gotoxy(currcons,0,0); gotoxy(vc_cons[currcons].d, 0, 0);
save_cur(currcons); save_cur(currcons);
if (do_clear) if (do_clear)
csi_J(currcons,2); csi_J(currcons,2);
...@@ -1532,7 +1535,7 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c) ...@@ -1532,7 +1535,7 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c)
return; return;
case 9: case 9:
pos -= (x << 1); pos -= (x << 1);
while (x < video_num_columns - 1) { while (x < vc_cons[currcons].d->vc_cols - 1) {
x++; x++;
if (tab_stop[x >> 5] & (1 << (x & 31))) if (tab_stop[x >> 5] & (1 << (x & 31)))
break; break;
...@@ -1719,31 +1722,31 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c) ...@@ -1719,31 +1722,31 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c)
switch(c) { switch(c) {
case 'G': case '`': case 'G': case '`':
if (par[0]) par[0]--; if (par[0]) par[0]--;
gotoxy(currcons,par[0],y); gotoxy(vc_cons[currcons].d, par[0], y);
return; return;
case 'A': case 'A':
if (!par[0]) par[0]++; if (!par[0]) par[0]++;
gotoxy(currcons,x,y-par[0]); gotoxy(vc_cons[currcons].d, x, y-par[0]);
return; return;
case 'B': case 'e': case 'B': case 'e':
if (!par[0]) par[0]++; if (!par[0]) par[0]++;
gotoxy(currcons,x,y+par[0]); gotoxy(vc_cons[currcons].d, x, y+par[0]);
return; return;
case 'C': case 'a': case 'C': case 'a':
if (!par[0]) par[0]++; if (!par[0]) par[0]++;
gotoxy(currcons,x+par[0],y); gotoxy(vc_cons[currcons].d, x+par[0], y);
return; return;
case 'D': case 'D':
if (!par[0]) par[0]++; if (!par[0]) par[0]++;
gotoxy(currcons,x-par[0],y); gotoxy(vc_cons[currcons].d, x-par[0], y);
return; return;
case 'E': case 'E':
if (!par[0]) par[0]++; if (!par[0]) par[0]++;
gotoxy(currcons,0,y+par[0]); gotoxy(vc_cons[currcons].d, 0, y+par[0]);
return; return;
case 'F': case 'F':
if (!par[0]) par[0]++; if (!par[0]) par[0]++;
gotoxy(currcons,0,y-par[0]); gotoxy(vc_cons[currcons].d, 0, y-par[0]);
return; return;
case 'd': case 'd':
if (par[0]) par[0]--; if (par[0]) par[0]--;
...@@ -1797,10 +1800,10 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c) ...@@ -1797,10 +1800,10 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c)
if (!par[0]) if (!par[0])
par[0]++; par[0]++;
if (!par[1]) if (!par[1])
par[1] = video_num_lines; par[1] = vc_cons[currcons].d->vc_rows;
/* Minimum allowed region is 2 lines */ /* Minimum allowed region is 2 lines */
if (par[0] < par[1] && if (par[0] < par[1] &&
par[1] <= video_num_lines) { par[1] <= vc_cons[currcons].d->vc_rows) {
top=par[0]-1; top=par[0]-1;
bottom=par[1]; bottom=par[1];
gotoxay(currcons,0,0); gotoxay(currcons,0,0);
...@@ -1847,7 +1850,7 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c) ...@@ -1847,7 +1850,7 @@ static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c)
csi_J(currcons, 2); csi_J(currcons, 2);
video_erase_char = video_erase_char =
(video_erase_char & 0xff00) | ' '; (video_erase_char & 0xff00) | ' ';
do_update_region(currcons, origin, screenbuf_size/2); do_update_region(vc_cons[currcons].d, origin, screenbuf_size/2);
} }
return; return;
case ESsetG0: case ESsetG0:
...@@ -1963,7 +1966,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co ...@@ -1963,7 +1966,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
/* undraw cursor first */ /* undraw cursor first */
if (IS_FG) if (IS_FG)
hide_cursor(currcons); hide_cursor(vc_cons[currcons].d);
while (!tty->stopped && count) { while (!tty->stopped && count) {
int orig = *buf; int orig = *buf;
...@@ -2065,7 +2068,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co ...@@ -2065,7 +2068,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
draw_x = x; draw_x = x;
draw_from = pos; draw_from = pos;
} }
if (x == video_num_columns - 1) { if (x == vc_cons[currcons].d->vc_cols - 1) {
need_wrap = decawm; need_wrap = decawm;
draw_to = pos+2; draw_to = pos+2;
} else { } else {
...@@ -2102,7 +2105,7 @@ static void console_callback(void *ignored) ...@@ -2102,7 +2105,7 @@ static void console_callback(void *ignored)
if (want_console >= 0) { if (want_console >= 0) {
if (want_console != fg_console && if (want_console != fg_console &&
vc_cons_allocated(want_console)) { vc_cons_allocated(want_console)) {
hide_cursor(fg_console); hide_cursor(vc_cons[fg_console].d);
change_console(want_console); change_console(want_console);
/* we only changed when the console had already /* we only changed when the console had already
been allocated - a new console is not created been allocated - a new console is not created
...@@ -2176,7 +2179,7 @@ void vt_console_print(struct console *co, const char *b, unsigned count) ...@@ -2176,7 +2179,7 @@ void vt_console_print(struct console *co, const char *b, unsigned count)
/* undraw cursor first */ /* undraw cursor first */
if (IS_FG) if (IS_FG)
hide_cursor(currcons); hide_cursor(vc_cons[currcons].d);
start = (ushort *)pos; start = (ushort *)pos;
...@@ -2209,7 +2212,7 @@ void vt_console_print(struct console *co, const char *b, unsigned count) ...@@ -2209,7 +2212,7 @@ void vt_console_print(struct console *co, const char *b, unsigned count)
} }
scr_writew((attr << 8) + c, (unsigned short *) pos); scr_writew((attr << 8) + c, (unsigned short *) pos);
cnt++; cnt++;
if (myx == video_num_columns - 1) { if (myx == vc_cons[currcons].d->vc_cols - 1) {
need_wrap = 1; need_wrap = 1;
continue; continue;
} }
...@@ -2220,12 +2223,12 @@ void vt_console_print(struct console *co, const char *b, unsigned count) ...@@ -2220,12 +2223,12 @@ void vt_console_print(struct console *co, const char *b, unsigned count)
if (IS_VISIBLE) if (IS_VISIBLE)
sw->con_putcs(vc_cons[currcons].d, start, cnt, y, x); sw->con_putcs(vc_cons[currcons].d, start, cnt, y, x);
x += cnt; x += cnt;
if (x == video_num_columns) { if (x == vc_cons[currcons].d->vc_cols) {
x--; x--;
need_wrap = 1; need_wrap = 1;
} }
} }
set_cursor(currcons); set_cursor(vc_cons[currcons].d);
if (!oops_in_progress) if (!oops_in_progress)
poke_blanked_console(); poke_blanked_console();
...@@ -2438,7 +2441,7 @@ static void con_flush_chars(struct tty_struct *tty) ...@@ -2438,7 +2441,7 @@ static void con_flush_chars(struct tty_struct *tty)
acquire_console_sem(); acquire_console_sem();
vt = tty->driver_data; vt = tty->driver_data;
if (vt) if (vt)
set_cursor(vt->vc_num); set_cursor(vc_cons[vt->vc_num].d);
release_console_sem(); release_console_sem();
} }
...@@ -2459,8 +2462,8 @@ static int con_open(struct tty_struct *tty, struct file *filp) ...@@ -2459,8 +2462,8 @@ static int con_open(struct tty_struct *tty, struct file *filp)
vc_cons[currcons].d->vc_tty = tty; vc_cons[currcons].d->vc_tty = tty;
if (!tty->winsize.ws_row && !tty->winsize.ws_col) { if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
tty->winsize.ws_row = video_num_lines; tty->winsize.ws_row = vc_cons[currcons].d->vc_rows;
tty->winsize.ws_col = video_num_columns; tty->winsize.ws_col = vc_cons[currcons].d->vc_cols;
} }
release_console_sem(); release_console_sem();
vcs_make_devfs(tty); vcs_make_devfs(tty);
...@@ -2507,10 +2510,10 @@ static void vc_init(unsigned int currcons, unsigned int rows, ...@@ -2507,10 +2510,10 @@ static void vc_init(unsigned int currcons, unsigned int rows,
{ {
int j, k ; int j, k ;
video_num_columns = cols; vc_cons[currcons].d->vc_cols = cols;
video_num_lines = rows; vc_cons[currcons].d->vc_rows = rows;
video_size_row = cols<<1; vc_cons[currcons].d->vc_size_row = cols<<1;
screenbuf_size = video_num_lines * video_size_row; screenbuf_size = vc_cons[currcons].d->vc_rows * vc_cons[currcons].d->vc_size_row;
set_origin(currcons); set_origin(currcons);
pos = origin; pos = origin;
...@@ -2563,22 +2566,23 @@ static int __init con_init(void) ...@@ -2563,22 +2566,23 @@ static int __init con_init(void)
alloc_bootmem(sizeof(struct vc_data)); alloc_bootmem(sizeof(struct vc_data));
vt_cons[currcons] = (struct vt_struct *) vt_cons[currcons] = (struct vt_struct *)
alloc_bootmem(sizeof(struct vt_struct)); alloc_bootmem(sizeof(struct vt_struct));
vc_cons[currcons].d->vc_vt = vt_cons[currcons];
visual_init(currcons, 1); visual_init(currcons, 1);
screenbuf = (unsigned short *) alloc_bootmem(screenbuf_size); screenbuf = (unsigned short *) alloc_bootmem(screenbuf_size);
kmalloced = 0; kmalloced = 0;
vc_init(currcons, video_num_lines, video_num_columns, vc_init(currcons, vc_cons[currcons].d->vc_rows, vc_cons[currcons].d->vc_cols,
currcons || !sw->con_save_screen); currcons || !sw->con_save_screen);
} }
currcons = fg_console = 0; currcons = fg_console = 0;
master_display_fg = vc_cons[currcons].d; master_display_fg = vc_cons[currcons].d;
set_origin(currcons); set_origin(currcons);
save_screen(currcons); save_screen(currcons);
gotoxy(currcons,x,y); gotoxy(vc_cons[currcons].d, x, y);
csi_J(currcons, 0); csi_J(currcons, 0);
update_screen(fg_console); update_screen(fg_console);
printk("Console: %s %s %dx%d", printk("Console: %s %s %dx%d",
can_do_color ? "colour" : "mono", vc_cons[currcons].d->vc_can_do_color ? "colour" : "mono",
display_desc, video_num_columns, video_num_lines); display_desc, vc_cons[currcons].d->vc_cols, vc_cons[currcons].d->vc_rows);
printable = 1; printable = 1;
printk("\n"); printk("\n");
...@@ -2690,7 +2694,7 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt) ...@@ -2690,7 +2694,7 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt)
origin = (unsigned long) screenbuf; origin = (unsigned long) screenbuf;
visible_origin = origin; visible_origin = origin;
scr_end = origin + screenbuf_size; scr_end = origin + screenbuf_size;
pos = origin + video_size_row*y + 2*x; pos = origin + vc_cons[currcons].d->vc_size_row*y + 2*x;
visual_init(i, 0); visual_init(i, 0);
update_attr(i); update_attr(i);
...@@ -2788,7 +2792,7 @@ void do_blank_screen(int entering_gfx) ...@@ -2788,7 +2792,7 @@ void do_blank_screen(int entering_gfx)
/* entering graphics mode? */ /* entering graphics mode? */
if (entering_gfx) { if (entering_gfx) {
hide_cursor(currcons); hide_cursor(vc_cons[currcons].d);
save_screen(currcons); save_screen(currcons);
sw->con_blank(vc_cons[currcons].d, -1, 1); sw->con_blank(vc_cons[currcons].d, -1, 1);
console_blanked = fg_console + 1; console_blanked = fg_console + 1;
...@@ -2802,7 +2806,7 @@ void do_blank_screen(int entering_gfx) ...@@ -2802,7 +2806,7 @@ void do_blank_screen(int entering_gfx)
return; return;
} }
hide_cursor(currcons); hide_cursor(vc_cons[currcons].d);
del_timer_sync(&console_timer); del_timer_sync(&console_timer);
blank_timer_expired = 0; blank_timer_expired = 0;
...@@ -2859,7 +2863,7 @@ void do_unblank_screen(int leaving_gfx) ...@@ -2859,7 +2863,7 @@ void do_unblank_screen(int leaving_gfx)
if (console_blank_hook) if (console_blank_hook)
console_blank_hook(0); console_blank_hook(0);
set_palette(currcons); set_palette(currcons);
set_cursor(fg_console); set_cursor(vc_cons[fg_console].d);
} }
EXPORT_SYMBOL(do_unblank_screen); EXPORT_SYMBOL(do_unblank_screen);
...@@ -3185,47 +3189,47 @@ int con_font_op(int currcons, struct console_font_op *op) ...@@ -3185,47 +3189,47 @@ int con_font_op(int currcons, struct console_font_op *op)
*/ */
/* used by selection */ /* used by selection */
u16 screen_glyph(int currcons, int offset) u16 screen_glyph(struct vc_data *vc, int offset)
{ {
u16 w = scr_readw(screenpos(currcons, offset, 1)); u16 w = scr_readw(screenpos(vc, offset, 1));
u16 c = w & 0xff; u16 c = w & 0xff;
if (w & hi_font_mask) if (w & vc->vc_hi_font_mask)
c |= 0x100; c |= 0x100;
return c; return c;
} }
/* used by vcs - note the word offset */ /* used by vcs - note the word offset */
unsigned short *screen_pos(int currcons, int w_offset, int viewed) unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed)
{ {
return screenpos(currcons, 2 * w_offset, viewed); return screenpos(vc, 2 * w_offset, viewed);
} }
void getconsxy(int currcons, unsigned char *p) void getconsxy(struct vc_data *vc, unsigned char *p)
{ {
p[0] = x; p[0] = vc->vc_x;
p[1] = y; p[1] = vc->vc_y;
} }
void putconsxy(int currcons, unsigned char *p) void putconsxy(struct vc_data *vc, unsigned char *p)
{ {
gotoxy(currcons, p[0], p[1]); gotoxy(vc, p[0], p[1]);
set_cursor(currcons); set_cursor(vc);
} }
u16 vcs_scr_readw(int currcons, const u16 *org) u16 vcs_scr_readw(struct vc_data *vc, const u16 *org)
{ {
if ((unsigned long)org == pos && softcursor_original != -1) if ((unsigned long)org == vc->vc_pos && softcursor_original != -1)
return softcursor_original; return softcursor_original;
return scr_readw(org); return scr_readw(org);
} }
void vcs_scr_writew(int currcons, u16 val, u16 *org) void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
{ {
scr_writew(val, org); scr_writew(val, org);
if ((unsigned long)org == pos) { if ((unsigned long)org == vc->vc_pos) {
softcursor_original = -1; softcursor_original = -1;
add_softcursor(currcons); add_softcursor(vc);
} }
} }
......
...@@ -37,7 +37,7 @@ char vt_dont_switch; ...@@ -37,7 +37,7 @@ char vt_dont_switch;
extern struct tty_driver *console_driver; extern struct tty_driver *console_driver;
#define VT_IS_IN_USE(i) (console_driver->ttys[i] && console_driver->ttys[i]->count) #define VT_IS_IN_USE(i) (console_driver->ttys[i] && console_driver->ttys[i]->count)
#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || i == sel_cons) #define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || vc_cons[i].d == sel_cons)
/* /*
* Console (vt and kd) routines, as defined by USL SVR4 manual, and by * Console (vt and kd) routines, as defined by USL SVR4 manual, and by
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* to achieve effects such as fast scrolling by changing the origin. * to achieve effects such as fast scrolling by changing the origin.
*/ */
struct vt_struct;
#define NPAR 16 #define NPAR 16
struct vc_data { struct vc_data {
...@@ -87,6 +89,7 @@ struct vc_data { ...@@ -87,6 +89,7 @@ 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 */
}; };
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <linux/tiocl.h> #include <linux/tiocl.h>
#include <linux/vt_buffer.h> #include <linux/vt_buffer.h>
extern int sel_cons; extern struct vc_data *sel_cons;
extern void clear_selection(void); extern void clear_selection(void);
extern int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty); extern int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty);
...@@ -19,11 +19,6 @@ extern int sel_loadlut(char __user *p); ...@@ -19,11 +19,6 @@ extern int sel_loadlut(char __user *p);
extern int mouse_reporting(void); extern int mouse_reporting(void);
extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry); extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry);
#define video_num_columns (vc_cons[currcons].d->vc_cols)
#define video_num_lines (vc_cons[currcons].d->vc_rows)
#define video_size_row (vc_cons[currcons].d->vc_size_row)
#define can_do_color (vc_cons[currcons].d->vc_can_do_color)
extern int console_blanked; extern int console_blanked;
extern unsigned char color_table[]; extern unsigned char color_table[];
...@@ -31,15 +26,15 @@ extern int default_red[]; ...@@ -31,15 +26,15 @@ extern int default_red[];
extern int default_grn[]; extern int default_grn[];
extern int default_blu[]; extern int default_blu[];
extern unsigned short *screen_pos(int currcons, int w_offset, int viewed); extern unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed);
extern u16 screen_glyph(int currcons, int offset); extern u16 screen_glyph(struct vc_data *vc, int offset);
extern void complement_pos(int currcons, int offset); extern void complement_pos(struct vc_data *vc, int offset);
extern void invert_screen(int currcons, int offset, int count, int shift); extern void invert_screen(struct vc_data *vc, int offset, int count, int shift);
extern void getconsxy(int currcons, unsigned char *p); extern void getconsxy(struct vc_data *vc, unsigned char *p);
extern void putconsxy(int currcons, unsigned char *p); extern void putconsxy(struct vc_data *vc, unsigned char *p);
extern u16 vcs_scr_readw(int currcons, const u16 *org); extern u16 vcs_scr_readw(struct vc_data *vc, const u16 *org);
extern void vcs_scr_writew(int currcons, u16 val, u16 *org); extern void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org);
#endif #endif
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