2 * linux/drivers/char/console.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
8 * Hopefully this will be a rather complete VT102 implementation.
10 * Beeping thanks to John T Kohl.
12 * Virtual Consoles, Screen Blanking, Screen Dumping, Color, Graphics
13 * Chars, and VT100 enhancements by Peter MacDonald.
15 * Copy and paste function by Andrew Haylett,
16 * some enhancements by Alessandro Rubini.
18 * Code to check for different video-cards mostly by Galen Hunt,
19 * <g-hunt@ee.utah.edu>
21 * Rudimentary ISO 10646/Unicode/UTF-8 character set support by
22 * Markus Kuhn, <mskuhn@immd4.informatik.uni-erlangen.de>.
24 * Dynamic allocation of consoles, aeb@cwi.nl, May 1994
25 * Resizing of consoles, aeb, 940926
27 * Code for xterm like mouse click reporting by Peter Orbaek 20-Jul-94
30 * User-defined bell sound, new setterm control sequences and printk
31 * redirection by Martin Mares <mj@k332.feld.cvut.cz> 19-Nov-95
33 * APM screenblank bug fixed Takashi Manabe <manabe@roy.dsl.tutics.tut.jp>
35 * Merge with the abstract console driver by Geert Uytterhoeven
36 * <geert@linux-m68k.org>, Jan 1997.
38 * Original m68k console driver modifications by
40 * - Arno Griffioen <arno@usn.nl>
41 * - David Carter <carter@cs.bris.ac.uk>
43 * Note that the abstract console driver allows all consoles to be of
44 * potentially different sizes, so the following variables depend on the
45 * current console (currcons):
52 * The abstract console driver provides a generic interface for a text
53 * console. It supports VGA text mode, frame buffer based graphical consoles
54 * and special graphics processors that are only accessible through some
55 * registers (e.g. a TMS340x0 GSP).
57 * The interface to the hardware is specified using a special structure
58 * (struct consw) which contains function pointers to console operations
59 * (see <linux/console.h> for more information).
61 * Support for changeable cursor shape
62 * by Pavel Machek <pavel@atrey.karlin.mff.cuni.cz>, August 1997
64 * Ported to i386 and con_scrolldelta fixed
65 * by Emmanuel Marty <core@ggi-project.org>, April 1998
67 * Resurrected character buffers in videoram plus lots of other trickery
68 * by Martin Mares <mj@atrey.karlin.mff.cuni.cz>, July 1998
71 #include <linux/module.h>
72 #include <linux/sched.h>
73 #include <linux/tty.h>
74 #include <linux/tty_flip.h>
75 #include <linux/kernel.h>
76 #include <linux/string.h>
77 #include <linux/errno.h>
79 #include <linux/malloc.h>
80 #include <linux/major.h>
82 #include <linux/console.h>
83 #include <linux/init.h>
84 #include <linux/devfs_fs_kernel.h>
85 #include <linux/vt_kern.h>
86 #include <linux/selection.h>
87 #include <linux/console_struct.h>
88 #include <linux/kbd_kern.h>
89 #include <linux/consolemap.h>
90 #include <linux/timer.h>
91 #include <linux/interrupt.h>
92 #include <linux/config.h>
93 #include <linux/version.h>
94 #include <linux/tqueue.h>
95 #include <linux/bootmem.h>
99 #include <asm/system.h>
100 #include <asm/uaccess.h>
101 #include <asm/bitops.h>
103 #include <asm/linux_logo.h>
105 #include "console_macros.h"
108 struct consw
*conswitchp
= NULL
;
110 /* A bitmap for codes <32. A bit of 1 indicates that the code
111 * corresponding to that bit number invokes some special action
112 * (such as cursor movement) and should not be displayed as a
113 * glyph unless the disp_ctrl mode is explicitly enabled.
115 #define CTRL_ACTION 0x0d00ff81
116 #define CTRL_ALWAYS 0x0800f501 /* Cannot be overridden by disp_ctrl */
119 * Here is the default bell parameters: 750HZ, 1/8th of a second
121 #define DEFAULT_BELL_PITCH 750
122 #define DEFAULT_BELL_DURATION (HZ/8)
124 extern int tty_register_devfs (struct tty_driver
*driver
, unsigned int flags
,
126 extern void vcs_make_devfs (unsigned int index
, int unregister
);
129 #define MIN(a,b) ((a) < (b) ? (a) : (b))
132 static struct tty_struct
*console_table
[MAX_NR_CONSOLES
];
133 static struct termios
*console_termios
[MAX_NR_CONSOLES
];
134 static struct termios
*console_termios_locked
[MAX_NR_CONSOLES
];
135 struct vc vc_cons
[MAX_NR_CONSOLES
];
137 #ifndef VT_SINGLE_DRIVER
138 static struct consw
*con_driver_map
[MAX_NR_CONSOLES
];
141 static int con_open(struct tty_struct
*, struct file
*);
142 static void vc_init(unsigned int console
, unsigned int rows
,
143 unsigned int cols
, int do_clear
);
144 static void blank_screen(void);
145 static void gotoxy(int currcons
, int new_x
, int new_y
);
146 static void save_cur(int currcons
);
147 static void reset_terminal(int currcons
, int do_clear
);
148 static void con_flush_chars(struct tty_struct
*tty
);
149 static void set_vesa_blanking(unsigned long arg
);
150 static void set_cursor(int currcons
);
151 static void hide_cursor(int currcons
);
153 static int printable
= 0; /* Is console ready for printing? */
155 int do_poke_blanked_console
= 0;
156 int console_blanked
= 0;
158 static int vesa_blank_mode
= 0; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
159 static int blankinterval
= 10*60*HZ
;
160 static int vesa_off_interval
= 0;
163 * fg_console is the current virtual console,
164 * last_console is the last used one,
165 * want_console is the console we want to switch to,
166 * kmsg_redirect is the console for kernel messages,
169 int last_console
= 0;
170 int want_console
= -1;
171 int kmsg_redirect
= 0;
174 * For each existing display, we have a pointer to console currently visible
175 * on that display, allowing consoles other than fg_console to be refreshed
176 * appropriately. Unless the low-level driver supplies its own display_fg
177 * variable, we use this one for the "master display".
179 static struct vc_data
*master_display_fg
= NULL
;
182 * Unfortunately, we need to delay tty echo when we're currently writing to the
183 * console since the code is (and always was) not re-entrant, so we insert
184 * all filp requests to con_task_queue instead of tq_timer and run it from
185 * the console_tasklet. The console_tasklet is protected by the IRQ
186 * protected console_lock.
188 DECLARE_TASK_QUEUE(con_task_queue
);
191 * For the same reason, we defer scrollback to the console tasklet.
193 static int scrollback_delta
= 0;
196 * Hook so that the power management routines can (un)blank
197 * the console on our behalf.
199 int (*console_blank_hook
)(int) = NULL
;
202 * Low-Level Functions
205 #define IS_FG (currcons == fg_console)
206 #define IS_VISIBLE CON_IS_VISIBLE(vc_cons[currcons].d)
208 #ifdef VT_BUF_VRAM_ONLY
211 #define DO_UPDATE IS_VISIBLE
214 static int pm_con_request(struct pm_dev
*dev
, pm_request_t rqst
, void *data
);
215 static struct pm_dev
*pm_con
= NULL
;
217 static inline unsigned short *screenpos(int currcons
, int offset
, int viewed
)
222 p
= (unsigned short *)(origin
+ offset
);
223 else if (!sw
->con_screen_pos
)
224 p
= (unsigned short *)(visible_origin
+ offset
);
226 p
= sw
->con_screen_pos(vc_cons
[currcons
].d
, offset
);
230 static inline void scrolldelta(int lines
)
232 scrollback_delta
+= lines
;
233 tasklet_schedule(&console_tasklet
);
236 static void scrup(int currcons
, unsigned int t
, unsigned int b
, int nr
)
238 unsigned short *d
, *s
;
242 if (b
> video_num_lines
|| t
>= b
|| nr
< 1)
244 if (IS_VISIBLE
&& sw
->con_scroll(vc_cons
[currcons
].d
, t
, b
, SM_UP
, nr
))
246 d
= (unsigned short *) (origin
+video_size_row
*t
);
247 s
= (unsigned short *) (origin
+video_size_row
*(t
+nr
));
248 scr_memcpyw(d
, s
, (b
-t
-nr
) * video_size_row
);
249 scr_memsetw(d
+ (b
-t
-nr
) * video_num_columns
, video_erase_char
, video_size_row
*nr
);
253 scrdown(int currcons
, unsigned int t
, unsigned int b
, int nr
)
260 if (b
> video_num_lines
|| t
>= b
|| nr
< 1)
262 if (IS_VISIBLE
&& sw
->con_scroll(vc_cons
[currcons
].d
, t
, b
, SM_DOWN
, nr
))
264 s
= (unsigned short *) (origin
+video_size_row
*t
);
265 step
= video_num_columns
* nr
;
266 scr_memmovew(s
+ step
, s
, (b
-t
-nr
)*video_size_row
);
267 scr_memsetw(s
, video_erase_char
, 2*step
);
270 static void do_update_region(int currcons
, unsigned long start
, int count
)
272 #ifndef VT_BUF_VRAM_ONLY
273 unsigned int xx
, yy
, offset
;
277 if (!sw
->con_getxy
) {
278 offset
= (start
- origin
) / 2;
279 xx
= offset
% video_num_columns
;
280 yy
= offset
/ video_num_columns
;
283 start
= sw
->con_getxy(vc_cons
[currcons
].d
, start
, &nxx
, &nyy
);
287 u16 attrib
= scr_readw(p
) & 0xff00;
290 while (xx
< video_num_columns
&& count
) {
291 if (attrib
!= (scr_readw(p
) & 0xff00)) {
293 sw
->con_putcs(vc_cons
[currcons
].d
, q
, p
-q
, yy
, startx
);
296 attrib
= scr_readw(p
) & 0xff00;
303 sw
->con_putcs(vc_cons
[currcons
].d
, q
, p
-q
, yy
, startx
);
310 start
= sw
->con_getxy(vc_cons
[currcons
].d
, start
, NULL
, NULL
);
316 void update_region(int currcons
, unsigned long start
, int count
)
319 hide_cursor(currcons
);
320 do_update_region(currcons
, start
, count
);
321 set_cursor(currcons
);
325 /* Structure of attributes is hardware-dependent */
327 static u8
build_attr(int currcons
, u8 _color
, u8 _intensity
, u8 _blink
, u8 _underline
, u8 _reverse
)
329 if (sw
->con_build_attr
)
330 return sw
->con_build_attr(vc_cons
[currcons
].d
, _color
, _intensity
, _blink
, _underline
, _reverse
);
332 #ifndef VT_BUF_VRAM_ONLY
334 * ++roman: I completely changed the attribute format for monochrome
335 * mode (!can_do_color). The formerly used MDA (monochrome display
336 * adapter) format didn't allow the combination of certain effects.
337 * Now the attribute is just a bit vector:
338 * Bit 0..1: intensity (0..2)
347 (_underline
? 4 : 0) |
351 a
= (a
& 0xf0) | ulcolor
;
352 else if (_intensity
== 0)
353 a
= (a
& 0xf0) | halfcolor
;
355 a
= ((a
) & 0x88) | ((((a
) >> 4) | ((a
) << 4)) & 0x77);
360 if (hi_font_mask
== 0x100)
369 static void update_attr(int currcons
)
371 attr
= build_attr(currcons
, color
, intensity
, blink
, underline
, reverse
^ decscnm
);
372 video_erase_char
= (build_attr(currcons
, color
, 1, 0, 0, decscnm
) << 8) | ' ';
375 /* Note: inverting the screen twice should revert to the original state */
377 void invert_screen(int currcons
, int offset
, int count
, int viewed
)
382 p
= screenpos(currcons
, offset
, viewed
);
383 if (sw
->con_invert_region
)
384 sw
->con_invert_region(vc_cons
[currcons
].d
, p
, count
);
385 #ifndef VT_BUF_VRAM_ONLY
391 while (cnt
--) *q
++ ^= 0x0800;
392 } else if (hi_font_mask
== 0x100) {
395 a
= ((a
) & 0x11ff) | (((a
) & 0xe000) >> 4) | (((a
) & 0x0e00) << 4);
401 a
= ((a
) & 0x88ff) | (((a
) & 0x7000) >> 4) | (((a
) & 0x0700) << 4);
408 do_update_region(currcons
, (unsigned long) p
, count
);
411 /* used by selection: complement pointer position */
412 void complement_pos(int currcons
, int offset
)
414 static unsigned short *p
= NULL
;
415 static unsigned short old
= 0;
416 static unsigned short oldx
= 0, oldy
= 0;
421 sw
->con_putc(vc_cons
[currcons
].d
, old
, oldy
, oldx
);
427 p
= screenpos(currcons
, offset
, 1);
429 new = old
^ complement_mask
;
432 oldx
= (offset
>> 1) % video_num_columns
;
433 oldy
= (offset
>> 1) / video_num_columns
;
434 sw
->con_putc(vc_cons
[currcons
].d
, new, oldy
, oldx
);
439 static void insert_char(int currcons
, unsigned int nr
)
441 unsigned short *p
, *q
= (unsigned short *) pos
;
443 p
= q
+ video_num_columns
- nr
- x
;
445 scr_writew(scr_readw(p
), p
+ nr
);
446 scr_memsetw(q
, video_erase_char
, nr
*2);
449 unsigned short oldattr
= attr
;
450 sw
->con_bmove(vc_cons
[currcons
].d
,y
,x
,y
,x
+nr
,1,
451 video_num_columns
-x
-nr
);
452 attr
= video_erase_char
>> 8;
454 sw
->con_putc(vc_cons
[currcons
].d
,
455 video_erase_char
,y
,x
+nr
);
460 static void delete_char(int currcons
, unsigned int nr
)
463 unsigned short *p
= (unsigned short *) pos
;
465 while (++i
<= video_num_columns
- nr
) {
466 scr_writew(scr_readw(p
+nr
), p
);
469 scr_memsetw(p
, video_erase_char
, nr
*2);
472 unsigned short oldattr
= attr
;
473 sw
->con_bmove(vc_cons
[currcons
].d
, y
, x
+nr
, y
, x
, 1,
474 video_num_columns
-x
-nr
);
475 attr
= video_erase_char
>> 8;
477 sw
->con_putc(vc_cons
[currcons
].d
,
479 video_num_columns
-1-nr
);
484 static int softcursor_original
;
486 static void add_softcursor(int currcons
)
488 int i
= scr_readw((u16
*) pos
);
489 u32 type
= cursor_type
;
491 if (! (type
& 0x10)) return;
492 if (softcursor_original
!= -1) return;
493 softcursor_original
= i
;
494 i
|= ((type
>> 8) & 0xff00 );
495 i
^= ((type
) & 0xff00 );
496 if ((type
& 0x20) && ((softcursor_original
& 0x7000) == (i
& 0x7000))) i
^= 0x7000;
497 if ((type
& 0x40) && ((i
& 0x700) == ((i
& 0x7000) >> 4))) i
^= 0x0700;
498 scr_writew(i
, (u16
*) pos
);
500 sw
->con_putc(vc_cons
[currcons
].d
, i
, y
, x
);
503 static void hide_cursor(int currcons
)
505 if (currcons
== sel_cons
)
507 if (softcursor_original
!= -1) {
508 scr_writew(softcursor_original
,(u16
*) pos
);
510 sw
->con_putc(vc_cons
[currcons
].d
, softcursor_original
, y
, x
);
511 softcursor_original
= -1;
513 sw
->con_cursor(vc_cons
[currcons
].d
,CM_ERASE
);
516 static void set_cursor(int currcons
)
518 if (!IS_FG
|| console_blanked
|| vcmode
== KD_GRAPHICS
)
521 if (currcons
== sel_cons
)
523 add_softcursor(currcons
);
524 if ((cursor_type
& 0x0f) != 1)
525 sw
->con_cursor(vc_cons
[currcons
].d
,CM_DRAW
);
527 hide_cursor(currcons
);
530 static void set_origin(int currcons
)
533 !sw
->con_set_origin
||
534 !sw
->con_set_origin(vc_cons
[currcons
].d
))
535 origin
= (unsigned long) screenbuf
;
536 visible_origin
= origin
;
537 scr_end
= origin
+ screenbuf_size
;
538 pos
= origin
+ video_size_row
*y
+ 2*x
;
541 static inline void save_screen(int currcons
)
543 if (sw
->con_save_screen
)
544 sw
->con_save_screen(vc_cons
[currcons
].d
);
548 * Redrawing of screen
551 void redraw_screen(int new_console
, int is_switch
)
554 int currcons
, old_console
;
556 if (!vc_cons_allocated(new_console
)) {
558 /* printk("redraw_screen: tty %d not allocated ??\n", new_console+1); */
563 currcons
= fg_console
;
564 hide_cursor(currcons
);
565 if (fg_console
!= new_console
) {
566 struct vc_data
**display
= vc_cons
[new_console
].d
->vc_display_fg
;
567 old_console
= (*display
) ? (*display
)->vc_num
: fg_console
;
568 *display
= vc_cons
[new_console
].d
;
569 fg_console
= new_console
;
570 currcons
= old_console
;
572 save_screen(currcons
);
573 set_origin(currcons
);
575 currcons
= new_console
;
576 if (old_console
== new_console
)
580 currcons
= new_console
;
581 hide_cursor(currcons
);
585 set_origin(currcons
);
586 set_palette(currcons
);
587 if (sw
->con_switch(vc_cons
[currcons
].d
) && vcmode
!= KD_GRAPHICS
)
588 /* Update the screen contents */
589 do_update_region(currcons
, origin
, screenbuf_size
/2);
591 set_cursor(currcons
);
594 compute_shiftstate();
599 * Allocation, freeing and resizing of VTs.
602 int vc_cons_allocated(unsigned int i
)
604 return (i
< MAX_NR_CONSOLES
&& vc_cons
[i
].d
);
607 static void visual_init(int currcons
, int init
)
609 /* ++Geert: sw->con_init determines console size */
611 #ifndef VT_SINGLE_DRIVER
612 if (con_driver_map
[currcons
])
613 sw
= con_driver_map
[currcons
];
616 display_fg
= &master_display_fg
;
617 vc_cons
[currcons
].d
->vc_uni_pagedir_loc
= &vc_cons
[currcons
].d
->vc_uni_pagedir
;
618 vc_cons
[currcons
].d
->vc_uni_pagedir
= 0;
622 sw
->con_init(vc_cons
[currcons
].d
, init
);
623 if (!complement_mask
)
624 complement_mask
= can_do_color
? 0x7700 : 0x0800;
625 s_complement_mask
= complement_mask
;
626 video_size_row
= video_num_columns
<<1;
627 screenbuf_size
= video_num_lines
*video_size_row
;
630 int vc_allocate(unsigned int currcons
) /* return 0 on success */
632 if (currcons
>= MAX_NR_CONSOLES
)
634 if (!vc_cons
[currcons
].d
) {
637 /* prevent users from taking too much memory */
638 if (currcons
>= MAX_NR_USER_CONSOLES
&& !capable(CAP_SYS_RESOURCE
))
641 /* due to the granularity of kmalloc, we waste some memory here */
642 /* the alloc is done in two steps, to optimize the common situation
643 of a 25x80 console (structsize=216, screenbuf_size=4000) */
644 /* although the numbers above are not valid since long ago, the
645 point is still up-to-date and the comment still has its value
646 even if only as a historical artifact. --mj, July 1998 */
647 p
= (long) kmalloc(structsize
, GFP_KERNEL
);
650 vc_cons
[currcons
].d
= (struct vc_data
*)p
;
651 vt_cons
[currcons
] = (struct vt_struct
*)(p
+sizeof(struct vc_data
));
652 visual_init(currcons
, 1);
653 if (!*vc_cons
[currcons
].d
->vc_uni_pagedir_loc
)
654 con_set_default_unimap(currcons
);
655 q
= (long)kmalloc(screenbuf_size
, GFP_KERNEL
);
657 kfree_s((char *) p
, structsize
);
658 vc_cons
[currcons
].d
= NULL
;
659 vt_cons
[currcons
] = NULL
;
662 screenbuf
= (unsigned short *) q
;
664 vc_init(currcons
, video_num_lines
, video_num_columns
, 1);
667 pm_con
= pm_register(PM_SYS_DEV
,
676 * Change # of rows and columns (0 means unchanged/the size of fg_console)
677 * [this is to be used together with some user program
678 * like resize that changes the hardware videomode]
680 int vc_resize(unsigned int lines
, unsigned int cols
,
681 unsigned int first
, unsigned int last
)
683 unsigned int cc
, ll
, ss
, sr
, todo
= 0;
684 unsigned int currcons
= fg_console
, i
;
685 unsigned short *newscreens
[MAX_NR_CONSOLES
];
687 cc
= (cols
? cols
: video_num_columns
);
688 ll
= (lines
? lines
: video_num_lines
);
692 for (currcons
= first
; currcons
<= last
; currcons
++) {
693 if (!vc_cons_allocated(currcons
) ||
694 (cc
== video_num_columns
&& ll
== video_num_lines
))
695 newscreens
[currcons
] = NULL
;
697 unsigned short *p
= (unsigned short *) kmalloc(ss
, GFP_USER
);
699 for (i
= first
; i
< currcons
; i
++)
701 kfree_s(newscreens
[i
], ss
);
704 newscreens
[currcons
] = p
;
711 for (currcons
= first
; currcons
<= last
; currcons
++) {
712 unsigned int occ
, oll
, oss
, osr
;
713 unsigned long ol
, nl
, nlend
, rlth
, rrem
;
714 if (!newscreens
[currcons
] || !vc_cons_allocated(currcons
))
717 oll
= video_num_lines
;
718 occ
= video_num_columns
;
719 osr
= video_size_row
;
720 oss
= screenbuf_size
;
722 video_num_lines
= ll
;
723 video_num_columns
= cc
;
730 nl
= (long) newscreens
[currcons
];
733 ol
+= (oll
- ll
) * osr
;
735 update_attr(currcons
);
737 while (ol
< scr_end
) {
738 scr_memcpyw((unsigned short *) nl
, (unsigned short *) ol
, rlth
);
740 scr_memsetw((void *)(nl
+ rlth
), video_erase_char
, rrem
);
745 scr_memsetw((void *) nl
, video_erase_char
, nlend
- nl
);
747 kfree_s(screenbuf
, oss
);
748 screenbuf
= newscreens
[currcons
];
751 set_origin(currcons
);
753 /* do part of a reset_terminal() */
755 bottom
= video_num_lines
;
756 gotoxy(currcons
, x
, y
);
759 if (console_table
[currcons
]) {
760 struct winsize ws
, *cws
= &console_table
[currcons
]->winsize
;
761 memset(&ws
, 0, sizeof(ws
));
762 ws
.ws_row
= video_num_lines
;
763 ws
.ws_col
= video_num_columns
;
764 if ((ws
.ws_row
!= cws
->ws_row
|| ws
.ws_col
!= cws
->ws_col
) &&
765 console_table
[currcons
]->pgrp
> 0)
766 kill_pg(console_table
[currcons
]->pgrp
, SIGWINCH
, 1);
771 update_screen(currcons
);
778 void vc_disallocate(unsigned int currcons
)
780 if (vc_cons_allocated(currcons
)) {
781 sw
->con_deinit(vc_cons
[currcons
].d
);
783 kfree_s(screenbuf
, screenbuf_size
);
784 if (currcons
>= MIN_NR_CONSOLES
)
785 kfree_s(vc_cons
[currcons
].d
, structsize
);
786 vc_cons
[currcons
].d
= NULL
;
794 #define set_kbd(x) set_vc_kbd_mode(kbd_table+currcons,x)
795 #define clr_kbd(x) clr_vc_kbd_mode(kbd_table+currcons,x)
796 #define is_kbd(x) vc_kbd_mode(kbd_table+currcons,x)
798 #define decarm VC_REPEAT
799 #define decckm VC_CKMODE
800 #define kbdapplic VC_APPLIC
804 * this is what the terminal answers to a ESC-Z or csi0c query.
806 #define VT100ID "\033[?1;2c"
807 #define VT102ID "\033[?6c"
809 unsigned char color_table
[] = { 0, 4, 2, 6, 1, 5, 3, 7,
810 8,12,10,14, 9,13,11,15 };
812 /* the default colour table, for VGA+ colour systems */
813 int default_red
[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,
814 0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff};
815 int default_grn
[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,
816 0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff};
817 int default_blu
[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
818 0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff};
821 * gotoxy() must verify all boundaries, because the arguments
822 * might also be negative. If the given position is out of
823 * bounds, the cursor is placed at the nearest margin.
825 static void gotoxy(int currcons
, int new_x
, int new_y
)
832 if (new_x
>= video_num_columns
)
833 x
= video_num_columns
- 1;
841 max_y
= video_num_lines
;
845 else if (new_y
>= max_y
)
849 pos
= origin
+ y
*video_size_row
+ (x
<<1);
853 /* for absolute user moves, when decom is set */
854 static void gotoxay(int currcons
, int new_x
, int new_y
)
856 gotoxy(currcons
, new_x
, decom
? (top
+new_y
) : new_y
);
859 void scrollback(int lines
)
861 int currcons
= fg_console
;
864 lines
= video_num_lines
/2;
868 void scrollfront(int lines
)
870 int currcons
= fg_console
;
873 lines
= video_num_lines
/2;
877 static void lf(int currcons
)
879 /* don't scroll if above bottom of scrolling region, or
880 * if below scrolling region
883 scrup(currcons
,top
,bottom
,1);
884 else if (y
< video_num_lines
-1) {
886 pos
+= video_size_row
;
891 static void ri(int currcons
)
893 /* don't scroll if below top of scrolling region, or
894 * if above scrolling region
897 scrdown(currcons
,top
,bottom
,1);
900 pos
-= video_size_row
;
905 static inline void cr(int currcons
)
911 static inline void bs(int currcons
)
920 static inline void del(int currcons
)
925 static void csi_J(int currcons
, int vpar
)
928 unsigned short * start
;
931 case 0: /* erase from cursor to end of display */
932 count
= (scr_end
-pos
)>>1;
933 start
= (unsigned short *) pos
;
935 /* do in two stages */
936 sw
->con_clear(vc_cons
[currcons
].d
, y
, x
, 1,
937 video_num_columns
-x
);
938 sw
->con_clear(vc_cons
[currcons
].d
, y
+1, 0,
943 case 1: /* erase from start to cursor */
944 count
= ((pos
-origin
)>>1)+1;
945 start
= (unsigned short *) origin
;
947 /* do in two stages */
948 sw
->con_clear(vc_cons
[currcons
].d
, 0, 0, y
,
950 sw
->con_clear(vc_cons
[currcons
].d
, y
, 0, 1,
954 case 2: /* erase whole display */
955 count
= video_num_columns
* video_num_lines
;
956 start
= (unsigned short *) origin
;
958 sw
->con_clear(vc_cons
[currcons
].d
, 0, 0,
965 scr_memsetw(start
, video_erase_char
, 2*count
);
969 static void csi_K(int currcons
, int vpar
)
972 unsigned short * start
;
975 case 0: /* erase from cursor to end of line */
976 count
= video_num_columns
-x
;
977 start
= (unsigned short *) pos
;
979 sw
->con_clear(vc_cons
[currcons
].d
, y
, x
, 1,
980 video_num_columns
-x
);
982 case 1: /* erase from start of line to cursor */
983 start
= (unsigned short *) (pos
- (x
<<1));
986 sw
->con_clear(vc_cons
[currcons
].d
, y
, 0, 1,
989 case 2: /* erase whole line */
990 start
= (unsigned short *) (pos
- (x
<<1));
991 count
= video_num_columns
;
993 sw
->con_clear(vc_cons
[currcons
].d
, y
, 0, 1,
999 scr_memsetw(start
, video_erase_char
, 2 * count
);
1003 static void csi_X(int currcons
, int vpar
) /* erase the following vpar positions */
1009 count
= (vpar
> video_num_columns
-x
) ? (video_num_columns
-x
) : vpar
;
1011 scr_memsetw((unsigned short *) pos
, video_erase_char
, 2 * count
);
1013 sw
->con_clear(vc_cons
[currcons
].d
, y
, x
, 1, count
);
1017 static void default_attr(int currcons
)
1026 static void csi_m(int currcons
)
1030 for (i
=0;i
<=npar
;i
++)
1032 case 0: /* all attributes off */
1033 default_attr(currcons
);
1050 case 10: /* ANSI X3.64-1979 (SCO-ish?)
1051 * Select primary font, don't display
1052 * control chars if defined, don't set
1055 translate
= set_translate(charset
== 0
1057 : G1_charset
,currcons
);
1061 case 11: /* ANSI X3.64-1979 (SCO-ish?)
1062 * Select first alternate font, lets
1063 * chars < 32 be displayed as ROM chars.
1065 translate
= set_translate(IBMPC_MAP
,currcons
);
1069 case 12: /* ANSI X3.64-1979 (SCO-ish?)
1070 * Select second alternate font, toggle
1071 * high bit before displaying as ROM char.
1073 translate
= set_translate(IBMPC_MAP
,currcons
);
1090 case 38: /* ANSI X3.64-1979 (SCO-ish?)
1091 * Enables underscore, white foreground
1092 * with white underscore (Linux - use
1093 * default foreground).
1095 color
= (def_color
& 0x0f) | background
;
1098 case 39: /* ANSI X3.64-1979 (SCO-ish?)
1099 * Disable underline option.
1100 * Reset colour to default? It did this
1103 color
= (def_color
& 0x0f) | background
;
1107 color
= (def_color
& 0xf0) | foreground
;
1110 if (par
[i
] >= 30 && par
[i
] <= 37)
1111 color
= color_table
[par
[i
]-30]
1113 else if (par
[i
] >= 40 && par
[i
] <= 47)
1114 color
= (color_table
[par
[i
]-40]<<4)
1118 update_attr(currcons
);
1121 static void respond_string(const char * p
, struct tty_struct
* tty
)
1124 tty_insert_flip_char(tty
, *p
, 0);
1127 con_schedule_flip(tty
);
1130 static void cursor_report(int currcons
, struct tty_struct
* tty
)
1134 sprintf(buf
, "\033[%d;%dR", y
+ (decom
? top
+1 : 1), x
+1);
1135 respond_string(buf
, tty
);
1138 static inline void status_report(struct tty_struct
* tty
)
1140 respond_string("\033[0n", tty
); /* Terminal ok */
1143 static inline void respond_ID(struct tty_struct
* tty
)
1145 respond_string(VT102ID
, tty
);
1148 void mouse_report(struct tty_struct
* tty
, int butt
, int mrx
, int mry
)
1152 sprintf(buf
, "\033[M%c%c%c", (char)(' ' + butt
), (char)('!' + mrx
),
1154 respond_string(buf
, tty
);
1157 /* invoked via ioctl(TIOCLINUX) and through set_selection */
1158 int mouse_reporting(void)
1160 int currcons
= fg_console
;
1162 return report_mouse
;
1165 static void set_mode(int currcons
, int on_off
)
1169 for (i
=0; i
<=npar
; i
++)
1170 if (ques
) switch(par
[i
]) { /* DEC private modes set/reset */
1171 case 1: /* Cursor keys send ^[Ox/^[[x */
1177 case 3: /* 80/132 mode switch unimplemented */
1180 (void) vc_resize(video_num_lines
, deccolm
? 132 : 80);
1181 /* this alone does not suffice; some user mode
1182 utility has to change the hardware regs */
1185 case 5: /* Inverted screen on/off */
1186 if (decscnm
!= on_off
) {
1188 invert_screen(currcons
, 0, screenbuf_size
, 0);
1189 update_attr(currcons
);
1192 case 6: /* Origin relative/absolute */
1194 gotoxay(currcons
,0,0);
1196 case 7: /* Autowrap on/off */
1199 case 8: /* Autorepeat on/off */
1206 report_mouse
= on_off
? 1 : 0;
1208 case 25: /* Cursor on/off */
1212 report_mouse
= on_off
? 2 : 0;
1214 } else switch(par
[i
]) { /* ANSI modes set/reset */
1215 case 3: /* Monitor (display ctrls) */
1218 case 4: /* Insert Mode on/off */
1221 case 20: /* Lf, Enter == CrLf/Lf */
1230 static void setterm_command(int currcons
)
1233 case 1: /* set color for underline mode */
1234 if (can_do_color
&& par
[1] < 16) {
1235 ulcolor
= color_table
[par
[1]];
1237 update_attr(currcons
);
1240 case 2: /* set color for half intensity mode */
1241 if (can_do_color
&& par
[1] < 16) {
1242 halfcolor
= color_table
[par
[1]];
1244 update_attr(currcons
);
1247 case 8: /* store colors as defaults */
1249 if (hi_font_mask
== 0x100)
1251 default_attr(currcons
);
1252 update_attr(currcons
);
1254 case 9: /* set blanking interval */
1255 blankinterval
= ((par
[1] < 60) ? par
[1] : 60) * 60 * HZ
;
1256 poke_blanked_console();
1258 case 10: /* set bell frequency in Hz */
1260 bell_pitch
= par
[1];
1262 bell_pitch
= DEFAULT_BELL_PITCH
;
1264 case 11: /* set bell duration in msec */
1266 bell_duration
= (par
[1] < 2000) ?
1269 bell_duration
= DEFAULT_BELL_DURATION
;
1271 case 12: /* bring specified console to the front */
1272 if (par
[1] >= 1 && vc_cons_allocated(par
[1]-1))
1273 set_console(par
[1] - 1);
1275 case 13: /* unblank the screen */
1276 poke_blanked_console();
1278 case 14: /* set vesa powerdown interval */
1279 vesa_off_interval
= ((par
[1] < 60) ? par
[1] : 60) * 60 * HZ
;
1284 static void insert_line(int currcons
, unsigned int nr
)
1286 scrdown(currcons
,y
,bottom
,nr
);
1291 static void delete_line(int currcons
, unsigned int nr
)
1293 scrup(currcons
,y
,bottom
,nr
);
1297 static void csi_at(int currcons
, unsigned int nr
)
1299 if (nr
> video_num_columns
- x
)
1300 nr
= video_num_columns
- x
;
1303 insert_char(currcons
, nr
);
1306 static void csi_L(int currcons
, unsigned int nr
)
1308 if (nr
> video_num_lines
- y
)
1309 nr
= video_num_lines
- y
;
1312 insert_line(currcons
, nr
);
1315 static void csi_P(int currcons
, unsigned int nr
)
1317 if (nr
> video_num_columns
- x
)
1318 nr
= video_num_columns
- x
;
1321 delete_char(currcons
, nr
);
1324 static void csi_M(int currcons
, unsigned int nr
)
1326 if (nr
> video_num_lines
- y
)
1327 nr
= video_num_lines
- y
;
1330 delete_line(currcons
, nr
);
1333 static void save_cur(int currcons
)
1337 s_intensity
= intensity
;
1338 s_underline
= underline
;
1340 s_reverse
= reverse
;
1341 s_charset
= charset
;
1343 saved_G0
= G0_charset
;
1344 saved_G1
= G1_charset
;
1347 static void restore_cur(int currcons
)
1349 gotoxy(currcons
,saved_x
,saved_y
);
1350 intensity
= s_intensity
;
1351 underline
= s_underline
;
1353 reverse
= s_reverse
;
1354 charset
= s_charset
;
1356 G0_charset
= saved_G0
;
1357 G1_charset
= saved_G1
;
1358 translate
= set_translate(charset
? G1_charset
: G0_charset
,currcons
);
1359 update_attr(currcons
);
1363 enum { ESnormal
, ESesc
, ESsquare
, ESgetpars
, ESgotpars
, ESfunckey
,
1364 EShash
, ESsetG0
, ESsetG1
, ESpercent
, ESignore
, ESnonstd
,
1367 static void reset_terminal(int currcons
, int do_clear
)
1370 bottom
= video_num_lines
;
1371 vc_state
= ESnormal
;
1373 translate
= set_translate(LAT1_MAP
,currcons
);
1374 G0_charset
= LAT1_MAP
;
1375 G1_charset
= GRAF_MAP
;
1395 kbd_table
[currcons
].lockstate
= 0;
1396 kbd_table
[currcons
].slockstate
= 0;
1397 kbd_table
[currcons
].ledmode
= LED_SHOW_FLAGS
;
1398 kbd_table
[currcons
].ledflagstate
= kbd_table
[currcons
].default_ledflagstate
;
1401 cursor_type
= CUR_DEFAULT
;
1402 complement_mask
= s_complement_mask
;
1404 default_attr(currcons
);
1405 update_attr(currcons
);
1407 tab_stop
[0] = 0x01010100;
1411 tab_stop
[4] = 0x01010101;
1413 bell_pitch
= DEFAULT_BELL_PITCH
;
1414 bell_duration
= DEFAULT_BELL_DURATION
;
1416 gotoxy(currcons
,0,0);
1422 static void do_con_trol(struct tty_struct
*tty
, unsigned int currcons
, int c
)
1425 * Control characters can be used in the _middle_
1426 * of an escape sequence.
1433 kd_mksound(bell_pitch
, bell_duration
);
1440 while (x
< video_num_columns
- 1) {
1442 if (tab_stop
[x
>> 5] & (1 << (x
& 31)))
1447 case 10: case 11: case 12:
1456 translate
= set_translate(G1_charset
,currcons
);
1461 translate
= set_translate(G0_charset
,currcons
);
1465 vc_state
= ESnormal
;
1474 vc_state
= ESsquare
;
1479 vc_state
= ESnormal
;
1482 vc_state
= ESsquare
;
1485 vc_state
= ESnonstd
;
1488 vc_state
= ESpercent
;
1501 tab_stop
[x
>> 5] |= (1 << (x
& 31));
1510 restore_cur(currcons
);
1522 reset_terminal(currcons
,1);
1524 case '>': /* Numeric keypad */
1527 case '=': /* Appl. keypad */
1533 if (c
=='P') { /* palette escape sequence */
1534 for (npar
=0; npar
<NPAR
; npar
++)
1537 vc_state
= ESpalette
;
1539 } else if (c
=='R') { /* reset palette */
1540 reset_palette(currcons
);
1541 vc_state
= ESnormal
;
1543 vc_state
= ESnormal
;
1546 if ( (c
>='0'&&c
<='9') || (c
>='A'&&c
<='F') || (c
>='a'&&c
<='f') ) {
1547 par
[npar
++] = (c
>'9' ? (c
&0xDF)-'A'+10 : c
-'0') ;
1549 int i
= par
[0]*3, j
= 1;
1550 palette
[i
] = 16*par
[j
++];
1551 palette
[i
++] += par
[j
++];
1552 palette
[i
] = 16*par
[j
++];
1553 palette
[i
++] += par
[j
++];
1554 palette
[i
] = 16*par
[j
++];
1555 palette
[i
] += par
[j
];
1556 set_palette(currcons
);
1557 vc_state
= ESnormal
;
1560 vc_state
= ESnormal
;
1563 for(npar
= 0 ; npar
< NPAR
; npar
++)
1566 vc_state
= ESgetpars
;
1567 if (c
== '[') { /* Function key */
1575 if (c
==';' && npar
<NPAR
-1) {
1578 } else if (c
>='0' && c
<='9') {
1582 } else vc_state
=ESgotpars
;
1584 vc_state
= ESnormal
;
1587 set_mode(currcons
,1);
1590 set_mode(currcons
,0);
1595 cursor_type
= par
[0] | (par
[1]<<8) | (par
[2]<<16);
1597 cursor_type
= CUR_DEFAULT
;
1605 complement_mask
= par
[0]<<8 | par
[1];
1607 complement_mask
= s_complement_mask
;
1615 else if (par
[0] == 6)
1616 cursor_report(currcons
,tty
);
1626 if (par
[0]) par
[0]--;
1627 gotoxy(currcons
,par
[0],y
);
1630 if (!par
[0]) par
[0]++;
1631 gotoxy(currcons
,x
,y
-par
[0]);
1634 if (!par
[0]) par
[0]++;
1635 gotoxy(currcons
,x
,y
+par
[0]);
1638 if (!par
[0]) par
[0]++;
1639 gotoxy(currcons
,x
+par
[0],y
);
1642 if (!par
[0]) par
[0]++;
1643 gotoxy(currcons
,x
-par
[0],y
);
1646 if (!par
[0]) par
[0]++;
1647 gotoxy(currcons
,0,y
+par
[0]);
1650 if (!par
[0]) par
[0]++;
1651 gotoxy(currcons
,0,y
-par
[0]);
1654 if (par
[0]) par
[0]--;
1655 gotoxay(currcons
,x
,par
[0]);
1658 if (par
[0]) par
[0]--;
1659 if (par
[1]) par
[1]--;
1660 gotoxay(currcons
,par
[1],par
[0]);
1663 csi_J(currcons
,par
[0]);
1666 csi_K(currcons
,par
[0]);
1669 csi_L(currcons
,par
[0]);
1672 csi_M(currcons
,par
[0]);
1675 csi_P(currcons
,par
[0]);
1683 tab_stop
[x
>> 5] &= ~(1 << (x
& 31));
1684 else if (par
[0] == 3) {
1695 case 'q': /* DECLL - but only 3 leds */
1696 /* map 0,1,2,3 to 0,1,2,4 */
1698 setledstate(kbd_table
+ currcons
,
1699 (par
[0] < 3) ? par
[0] : 4);
1705 par
[1] = video_num_lines
;
1706 /* Minimum allowed region is 2 lines */
1707 if (par
[0] < par
[1] &&
1708 par
[1] <= video_num_lines
) {
1711 gotoxay(currcons
,0,0);
1718 restore_cur(currcons
);
1721 csi_X(currcons
, par
[0]);
1724 csi_at(currcons
,par
[0]);
1726 case ']': /* setterm functions */
1727 setterm_command(currcons
);
1732 vc_state
= ESnormal
;
1734 case '@': /* defined in ISO 2022 */
1737 case 'G': /* prelim official escape code */
1738 case '8': /* retained for compatibility */
1744 vc_state
= ESnormal
;
1747 vc_state
= ESnormal
;
1749 /* DEC screen alignment test. kludge :-) */
1751 (video_erase_char
& 0xff00) | 'E';
1754 (video_erase_char
& 0xff00) | ' ';
1755 do_update_region(currcons
, origin
, screenbuf_size
/2);
1760 G0_charset
= GRAF_MAP
;
1762 G0_charset
= LAT1_MAP
;
1764 G0_charset
= IBMPC_MAP
;
1766 G0_charset
= USER_MAP
;
1768 translate
= set_translate(G0_charset
,currcons
);
1769 vc_state
= ESnormal
;
1773 G1_charset
= GRAF_MAP
;
1775 G1_charset
= LAT1_MAP
;
1777 G1_charset
= IBMPC_MAP
;
1779 G1_charset
= USER_MAP
;
1781 translate
= set_translate(G1_charset
,currcons
);
1782 vc_state
= ESnormal
;
1785 vc_state
= ESnormal
;
1789 /* This is a temporary buffer used to prepare a tty console write
1790 * so that we can easily avoid touching user space while holding the
1791 * console spinlock. It is allocated in con_init and is shared by
1792 * this code and the vc_screen read/write tty calls.
1794 * We have to allocate this statically in the kernel data section
1795 * since console_init (and thus con_init) are called before any
1796 * kernel memory allocation is available.
1798 char con_buf
[PAGE_SIZE
];
1799 #define CON_BUF_SIZE PAGE_SIZE
1800 DECLARE_MUTEX(con_buf_sem
);
1802 static int do_con_write(struct tty_struct
* tty
, int from_user
,
1803 const unsigned char *buf
, int count
)
1805 #ifdef VT_BUF_VRAM_ONLY
1806 #define FLUSH do { } while(0);
1808 #define FLUSH if (draw_x >= 0) { \
1809 sw->con_putcs(vc_cons[currcons].d, (u16 *)draw_from, (u16 *)draw_to-(u16 *)draw_from, y, draw_x); \
1814 int c
, tc
, ok
, n
= 0, draw_x
= -1;
1815 unsigned int currcons
;
1816 unsigned long draw_from
= 0, draw_to
= 0;
1817 struct vt_struct
*vt
= (struct vt_struct
*)tty
->driver_data
;
1818 u16 himask
, charmask
;
1819 const unsigned char *orig_buf
= NULL
;
1822 currcons
= vt
->vc_num
;
1823 if (!vc_cons_allocated(currcons
)) {
1824 /* could this happen? */
1825 static int error
= 0;
1828 printk("con_write: tty %d not allocated\n", currcons
+1);
1840 if (count
> CON_BUF_SIZE
)
1841 count
= CON_BUF_SIZE
;
1842 if (copy_from_user(con_buf
, buf
, count
)) {
1843 n
= 0; /* ?? are error codes legal here ?? */
1850 /* At this point 'buf' is guarenteed to be a kernel buffer
1851 * and therefore no access to userspace (and therefore sleeping)
1852 * will be needed. The con_buf_sem serializes all tty based
1853 * console rendering and vcs write/read operations. We hold
1854 * the console spinlock during the entire write.
1857 spin_lock_irq(&console_lock
);
1859 himask
= hi_font_mask
;
1860 charmask
= himask
? 0x1ff : 0xff;
1862 /* undraw cursor first */
1864 hide_cursor(currcons
);
1866 while (!tty
->stopped
&& count
) {
1873 /* Combine UTF-8 into Unicode */
1874 /* Incomplete characters silently ignored */
1876 if (utf_count
> 0 && (c
& 0xc0) == 0x80) {
1877 utf_char
= (utf_char
<< 6) | (c
& 0x3f);
1883 if ((c
& 0xe0) == 0xc0) {
1885 utf_char
= (c
& 0x1f);
1886 } else if ((c
& 0xf0) == 0xe0) {
1888 utf_char
= (c
& 0x0f);
1889 } else if ((c
& 0xf8) == 0xf0) {
1891 utf_char
= (c
& 0x07);
1892 } else if ((c
& 0xfc) == 0xf8) {
1894 utf_char
= (c
& 0x03);
1895 } else if ((c
& 0xfe) == 0xfc) {
1897 utf_char
= (c
& 0x01);
1906 } else { /* no utf */
1907 tc
= translate
[toggle_meta
? (c
|0x80) : c
];
1910 /* If the original code was a control character we
1911 * only allow a glyph to be displayed if the code is
1912 * not normally used (such as for cursor movement) or
1913 * if the disp_ctrl mode has been explicitly enabled.
1914 * Certain characters (as given by the CTRL_ALWAYS
1915 * bitmap) are always displayed as control characters,
1916 * as the console would be pretty useless without
1917 * them; to display an arbitrary font position use the
1918 * direct-to-font zone in UTF-8 mode.
1920 ok
= tc
&& (c
>= 32 ||
1921 (!utf
&& !(((disp_ctrl
? CTRL_ALWAYS
1922 : CTRL_ACTION
) >> c
) & 1)))
1923 && (c
!= 127 || disp_ctrl
)
1926 if (vc_state
== ESnormal
&& ok
) {
1927 /* Now try to find out how to display it */
1928 tc
= conv_uni_to_pc(vc_cons
[currcons
].d
, tc
);
1930 /* If we got -4 (not found) then see if we have
1931 defined a replacement character (U+FFFD) */
1932 tc
= conv_uni_to_pc(vc_cons
[currcons
].d
, 0xfffd);
1934 /* One reason for the -4 can be that we just
1935 did a clear_unimap();
1936 try at least to show something. */
1939 } else if ( tc
== -3 ) {
1940 /* Bad hash table -- hope for the best */
1944 continue; /* Conversion failed */
1946 if (need_wrap
|| decim
)
1953 insert_char(currcons
, 1);
1955 ((attr
<< 8) & ~himask
) + ((tc
& 0x100) ? himask
: 0) + (tc
& 0xff) :
1958 if (DO_UPDATE
&& draw_x
< 0) {
1962 if (x
== video_num_columns
- 1) {
1972 do_con_trol(tty
, currcons
, c
);
1975 spin_unlock_irq(&console_lock
);
1979 /* If the user requested something larger than
1980 * the CON_BUF_SIZE, and the tty is not stopped,
1983 if ((orig_count
> CON_BUF_SIZE
) && !tty
->stopped
) {
1984 orig_count
-= CON_BUF_SIZE
;
1985 orig_buf
+= CON_BUF_SIZE
;
1999 * This is the console switching tasklet.
2001 * Doing console switching in a tasklet allows
2002 * us to do the switches asynchronously (needed when we want
2003 * to switch due to a keyboard interrupt). Synchronization
2004 * with other console code and prevention of re-entrancy is
2005 * ensured with console_lock.
2007 static void console_softint(unsigned long ignored
)
2009 /* Runs the task queue outside of the console lock. These
2010 * callbacks can come back into the console code and thus
2011 * will perform their own locking.
2013 run_task_queue(&con_task_queue
);
2015 spin_lock_irq(&console_lock
);
2017 if (want_console
>= 0) {
2018 if (want_console
!= fg_console
&& vc_cons_allocated(want_console
)) {
2019 hide_cursor(fg_console
);
2020 change_console(want_console
);
2021 /* we only changed when the console had already
2022 been allocated - a new console is not created
2023 in an interrupt routine */
2027 if (do_poke_blanked_console
) { /* do not unblank for a LED change */
2028 do_poke_blanked_console
= 0;
2029 poke_blanked_console();
2031 if (scrollback_delta
) {
2032 int currcons
= fg_console
;
2034 if (vcmode
== KD_TEXT
)
2035 sw
->con_scrolldelta(vc_cons
[currcons
].d
, scrollback_delta
);
2036 scrollback_delta
= 0;
2039 spin_unlock_irq(&console_lock
);
2042 #ifdef CONFIG_VT_CONSOLE
2045 * Console on virtual terminal
2047 * The console_lock must be held when we get here.
2050 void vt_console_print(struct console
*co
, const char * b
, unsigned count
)
2052 int currcons
= fg_console
;
2054 static unsigned long printing
= 0;
2055 const ushort
*start
;
2059 /* console busy or not yet initialized */
2060 if (!printable
|| test_and_set_bit(0, &printing
))
2065 if (kmsg_redirect
&& vc_cons_allocated(kmsg_redirect
- 1))
2066 currcons
= kmsg_redirect
- 1;
2068 /* read `x' only after setting currecons properly (otherwise
2069 the `x' macro will read the x of the foreground console). */
2072 if (!vc_cons_allocated(currcons
)) {
2074 /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */
2078 if (vcmode
!= KD_TEXT
)
2081 /* undraw cursor first */
2083 hide_cursor(currcons
);
2085 start
= (ushort
*)pos
;
2087 /* Contrived structure to try to emulate original need_wrap behaviour
2088 * Problems caused when we have need_wrap set on '\n' character */
2091 if (c
== 10 || c
== 13 || c
== 8 || need_wrap
) {
2094 sw
->con_putcs(vc_cons
[currcons
].d
, start
, cnt
, y
, x
);
2100 if (c
== 8) { /* backspace */
2102 start
= (ushort
*)pos
;
2109 start
= (ushort
*)pos
;
2111 if (c
== 10 || c
== 13)
2114 scr_writew((attr
<< 8) + c
, (unsigned short *) pos
);
2116 if (myx
== video_num_columns
- 1) {
2125 sw
->con_putcs(vc_cons
[currcons
].d
, start
, cnt
, y
, x
);
2127 if (x
== video_num_columns
) {
2132 set_cursor(currcons
);
2133 poke_blanked_console();
2136 clear_bit(0, &printing
);
2139 static kdev_t
vt_console_device(struct console
*c
)
2141 return MKDEV(TTY_MAJOR
, c
->index
? c
->index
: fg_console
+ 1);
2144 struct console vt_console_driver
= {
2149 keyboard_wait_for_keypress
,
2160 * Handling of Linux-specific VC ioctls
2163 int tioclinux(struct tty_struct
*tty
, unsigned long arg
)
2167 if (tty
->driver
.type
!= TTY_DRIVER_TYPE_CONSOLE
)
2169 if (current
->tty
!= tty
&& !suser())
2171 if (get_user(type
, (char *)arg
))
2176 return set_selection(arg
, tty
, 1);
2178 return paste_selection(tty
);
2183 return sel_loadlut(arg
);
2187 * Make it possible to react to Shift+Mousebutton.
2188 * Note that 'shift_state' is an undocumented
2189 * kernel-internal variable; programs not closely
2190 * related to the kernel should not use this.
2193 return __put_user(data
, (char *) arg
);
2195 data
= mouse_reporting();
2196 return __put_user(data
, (char *) arg
);
2198 set_vesa_blanking(arg
);
2200 case 11: /* set kmsg redirect */
2203 if (get_user(data
, (char *)arg
+1))
2205 kmsg_redirect
= data
;
2207 case 12: /* get fg_console */
2214 * /dev/ttyN handling
2217 static int con_write(struct tty_struct
* tty
, int from_user
,
2218 const unsigned char *buf
, int count
)
2223 retval
= do_con_write(tty
, from_user
, buf
, count
);
2224 con_flush_chars(tty
);
2229 static void con_put_char(struct tty_struct
*tty
, unsigned char ch
)
2232 do_con_write(tty
, 0, &ch
, 1);
2235 static int con_write_room(struct tty_struct
*tty
)
2239 return 4096; /* No limit, really; we're not buffering */
2242 static int con_chars_in_buffer(struct tty_struct
*tty
)
2244 return 0; /* we're not buffering */
2248 * con_throttle and con_unthrottle are only used for
2249 * paste_selection(), which has to stuff in a large number of
2252 static void con_throttle(struct tty_struct
*tty
)
2256 static void con_unthrottle(struct tty_struct
*tty
)
2258 struct vt_struct
*vt
= (struct vt_struct
*) tty
->driver_data
;
2260 wake_up_interruptible(&vt
->paste_wait
);
2264 * Turn the Scroll-Lock LED on when the tty is stopped
2266 static void con_stop(struct tty_struct
*tty
)
2271 console_num
= MINOR(tty
->device
) - (tty
->driver
.minor_start
);
2272 if (!vc_cons_allocated(console_num
))
2274 set_vc_kbd_led(kbd_table
+ console_num
, VC_SCROLLOCK
);
2279 * Turn the Scroll-Lock LED off when the console is started
2281 static void con_start(struct tty_struct
*tty
)
2286 console_num
= MINOR(tty
->device
) - (tty
->driver
.minor_start
);
2287 if (!vc_cons_allocated(console_num
))
2289 clr_vc_kbd_led(kbd_table
+ console_num
, VC_SCROLLOCK
);
2293 static void con_flush_chars(struct tty_struct
*tty
)
2295 struct vt_struct
*vt
= (struct vt_struct
*)tty
->driver_data
;
2298 set_cursor(vt
->vc_num
);
2302 * Allocate the console screen memory.
2304 static int con_open(struct tty_struct
*tty
, struct file
* filp
)
2306 unsigned int currcons
;
2309 currcons
= MINOR(tty
->device
) - tty
->driver
.minor_start
;
2311 i
= vc_allocate(currcons
);
2315 vt_cons
[currcons
]->vc_num
= currcons
;
2316 tty
->driver_data
= vt_cons
[currcons
];
2318 if (!tty
->winsize
.ws_row
&& !tty
->winsize
.ws_col
) {
2319 tty
->winsize
.ws_row
= video_num_lines
;
2320 tty
->winsize
.ws_col
= video_num_columns
;
2322 if (tty
->count
== 1)
2323 vcs_make_devfs (currcons
, 0);
2327 static void con_close(struct tty_struct
*tty
, struct file
* filp
)
2331 if (tty
->count
!= 1) return;
2332 vcs_make_devfs (MINOR (tty
->device
) - tty
->driver
.minor_start
, 1);
2333 tty
->driver_data
= 0;
2336 static void vc_init(unsigned int currcons
, unsigned int rows
, unsigned int cols
, int do_clear
)
2340 video_num_columns
= cols
;
2341 video_num_lines
= rows
;
2342 video_size_row
= cols
<<1;
2343 screenbuf_size
= video_num_lines
* video_size_row
;
2345 set_origin(currcons
);
2348 for (j
=k
=0; j
<16; j
++) {
2349 vc_cons
[currcons
].d
->vc_palette
[k
++] = default_red
[j
] ;
2350 vc_cons
[currcons
].d
->vc_palette
[k
++] = default_grn
[j
] ;
2351 vc_cons
[currcons
].d
->vc_palette
[k
++] = default_blu
[j
] ;
2353 def_color
= 0x07; /* white */
2354 ulcolor
= 0x0f; /* bold white */
2355 halfcolor
= 0x08; /* grey */
2356 init_waitqueue_head(&vt_cons
[currcons
]->paste_wait
);
2357 reset_terminal(currcons
, do_clear
);
2361 * This routine initializes console interrupts, and does nothing
2362 * else. If you want the screen to clear, call tty_write with
2363 * the appropriate escape-sequence.
2366 struct tty_driver console_driver
;
2367 static int console_refcount
;
2369 DECLARE_TASKLET_DISABLED(console_tasklet
, console_softint
, 0);
2371 void __init
con_init(void)
2373 const char *display_desc
= NULL
;
2374 unsigned int currcons
= 0;
2377 display_desc
= conswitchp
->con_startup();
2378 if (!display_desc
) {
2383 memset(&console_driver
, 0, sizeof(struct tty_driver
));
2384 console_driver
.magic
= TTY_DRIVER_MAGIC
;
2385 console_driver
.name
= "vc/%d";
2386 console_driver
.name_base
= 1;
2387 console_driver
.major
= TTY_MAJOR
;
2388 console_driver
.minor_start
= 1;
2389 console_driver
.num
= MAX_NR_CONSOLES
;
2390 console_driver
.type
= TTY_DRIVER_TYPE_CONSOLE
;
2391 console_driver
.init_termios
= tty_std_termios
;
2392 console_driver
.flags
= TTY_DRIVER_REAL_RAW
| TTY_DRIVER_RESET_TERMIOS
;
2393 /* Tell tty_register_driver() to skip consoles because they are
2394 * registered before kmalloc() is ready. We'll patch them in later.
2395 * See comments at console_init(); see also con_init_devfs().
2397 console_driver
.flags
|= TTY_DRIVER_NO_DEVFS
;
2398 console_driver
.refcount
= &console_refcount
;
2399 console_driver
.table
= console_table
;
2400 console_driver
.termios
= console_termios
;
2401 console_driver
.termios_locked
= console_termios_locked
;
2403 console_driver
.open
= con_open
;
2404 console_driver
.close
= con_close
;
2405 console_driver
.write
= con_write
;
2406 console_driver
.write_room
= con_write_room
;
2407 console_driver
.put_char
= con_put_char
;
2408 console_driver
.flush_chars
= con_flush_chars
;
2409 console_driver
.chars_in_buffer
= con_chars_in_buffer
;
2410 console_driver
.ioctl
= vt_ioctl
;
2411 console_driver
.stop
= con_stop
;
2412 console_driver
.start
= con_start
;
2413 console_driver
.throttle
= con_throttle
;
2414 console_driver
.unthrottle
= con_unthrottle
;
2416 if (tty_register_driver(&console_driver
))
2417 panic("Couldn't register console driver\n");
2419 timer_table
[BLANK_TIMER
].fn
= blank_screen
;
2420 timer_table
[BLANK_TIMER
].expires
= 0;
2421 if (blankinterval
) {
2422 timer_table
[BLANK_TIMER
].expires
= jiffies
+ blankinterval
;
2423 timer_active
|= 1<<BLANK_TIMER
;
2427 * kmalloc is not running yet - we use the bootmem allocator.
2429 for (currcons
= 0; currcons
< MIN_NR_CONSOLES
; currcons
++) {
2432 vc_cons
[currcons
].d
= (struct vc_data
*)
2433 alloc_bootmem(sizeof(struct vc_data
));
2434 vt_cons
[currcons
] = (struct vt_struct
*)
2435 alloc_bootmem(sizeof(struct vt_struct
));
2436 visual_init(currcons
, 1);
2437 screenbuf
= (unsigned short *) alloc_bootmem(screenbuf_size
);
2439 vc_init(currcons
, video_num_lines
, video_num_columns
,
2440 currcons
|| !sw
->con_save_screen
);
2441 for (j
=k
=0; j
<16; j
++) {
2442 vc_cons
[currcons
].d
->vc_palette
[k
++] = default_red
[j
] ;
2443 vc_cons
[currcons
].d
->vc_palette
[k
++] = default_grn
[j
] ;
2444 vc_cons
[currcons
].d
->vc_palette
[k
++] = default_blu
[j
] ;
2447 currcons
= fg_console
= 0;
2448 master_display_fg
= vc_cons
[currcons
].d
;
2449 set_origin(currcons
);
2450 save_screen(currcons
);
2451 gotoxy(currcons
,x
,y
);
2453 update_screen(fg_console
);
2454 printk("Console: %s %s %dx%d",
2455 can_do_color
? "colour" : "mono",
2456 display_desc
, video_num_columns
, video_num_lines
);
2460 #ifdef CONFIG_VT_CONSOLE
2461 register_console(&vt_console_driver
);
2464 tasklet_enable(&console_tasklet
);
2465 tasklet_schedule(&console_tasklet
);
2468 #ifndef VT_SINGLE_DRIVER
2470 static void clear_buffer_attributes(int currcons
)
2472 unsigned short *p
= (unsigned short *) origin
;
2473 int count
= screenbuf_size
/2;
2474 int mask
= hi_font_mask
| 0xff;
2476 for (; count
> 0; count
--, p
++) {
2477 scr_writew((scr_readw(p
)&mask
) | (video_erase_char
&~mask
), p
);
2482 * If we support more console drivers, this function is used
2483 * when a driver wants to take over some existing consoles
2484 * and become default driver for newly opened ones.
2487 void take_over_console(struct consw
*csw
, int first
, int last
, int deflt
)
2492 desc
= csw
->con_startup();
2497 for (i
= first
; i
<= last
; i
++) {
2501 con_driver_map
[i
] = csw
;
2503 if (!vc_cons
[i
].d
|| !vc_cons
[i
].d
->vc_sw
)
2509 old_was_color
= vc_cons
[i
].d
->vc_can_do_color
;
2510 vc_cons
[i
].d
->vc_sw
->con_deinit(vc_cons
[i
].d
);
2514 /* If the console changed between mono <-> color, then
2515 * the attributes in the screenbuf will be wrong. The
2516 * following resets all attributes to something sane.
2518 if (old_was_color
!= vc_cons
[i
].d
->vc_can_do_color
)
2519 clear_buffer_attributes(i
);
2524 printk("Console: switching ");
2526 printk("consoles %d-%d ", first
+1, last
+1);
2528 printk("to %s %s %dx%d\n",
2529 vc_cons
[j
].d
->vc_can_do_color
? "colour" : "mono",
2530 desc
, vc_cons
[j
].d
->vc_cols
, vc_cons
[j
].d
->vc_rows
);
2532 printk("to %s\n", desc
);
2535 void give_up_console(struct consw
*csw
)
2539 for(i
= 0; i
< MAX_NR_CONSOLES
; i
++)
2540 if (con_driver_map
[i
] == csw
)
2541 con_driver_map
[i
] = NULL
;
2550 static void set_vesa_blanking(unsigned long arg
)
2552 char *argp
= (char *)arg
+ 1;
2554 get_user(mode
, argp
);
2555 vesa_blank_mode
= (mode
< 4) ? mode
: 0;
2558 /* We can't register the console with devfs during con_init(), because it
2559 * is called before kmalloc() works. This function is called later to
2560 * do the registration.
2562 void __init
con_init_devfs (void)
2566 for (i
= 0; i
< console_driver
.num
; i
++)
2567 tty_register_devfs (&console_driver
, 0,
2568 console_driver
.minor_start
+ i
);
2571 static void vesa_powerdown(void)
2573 struct vc_data
*c
= vc_cons
[fg_console
].d
;
2575 * Power down if currently suspended (1 or 2),
2576 * suspend if currently blanked (0),
2577 * else do nothing (i.e. already powered down (3)).
2578 * Called only if powerdown features are allowed.
2580 switch (vesa_blank_mode
) {
2581 case VESA_NO_BLANKING
:
2582 c
->vc_sw
->con_blank(c
, VESA_VSYNC_SUSPEND
+1);
2584 case VESA_VSYNC_SUSPEND
:
2585 case VESA_HSYNC_SUSPEND
:
2586 c
->vc_sw
->con_blank(c
, VESA_POWERDOWN
+1);
2591 static void vesa_powerdown_screen(void)
2593 timer_active
&= ~(1<<BLANK_TIMER
);
2594 timer_table
[BLANK_TIMER
].fn
= unblank_screen
;
2599 void do_blank_screen(int entering_gfx
)
2601 int currcons
= fg_console
;
2604 if (console_blanked
)
2607 /* entering graphics mode? */
2609 hide_cursor(currcons
);
2610 save_screen(currcons
);
2611 sw
->con_blank(vc_cons
[currcons
].d
, -1);
2612 console_blanked
= fg_console
+ 1;
2613 set_origin(currcons
);
2617 /* don't blank graphics */
2618 if (vcmode
!= KD_TEXT
) {
2619 console_blanked
= fg_console
+ 1;
2623 hide_cursor(currcons
);
2624 if (vesa_off_interval
) {
2625 timer_table
[BLANK_TIMER
].fn
= vesa_powerdown_screen
;
2626 timer_table
[BLANK_TIMER
].expires
= jiffies
+ vesa_off_interval
;
2627 timer_active
|= (1<<BLANK_TIMER
);
2629 timer_active
&= ~(1<<BLANK_TIMER
);
2630 timer_table
[BLANK_TIMER
].fn
= unblank_screen
;
2633 save_screen(currcons
);
2634 /* In case we need to reset origin, blanking hook returns 1 */
2635 i
= sw
->con_blank(vc_cons
[currcons
].d
, 1);
2636 console_blanked
= fg_console
+ 1;
2638 set_origin(currcons
);
2640 if (console_blank_hook
&& console_blank_hook(1))
2642 if (vesa_blank_mode
)
2643 sw
->con_blank(vc_cons
[currcons
].d
, vesa_blank_mode
+ 1);
2646 void unblank_screen(void)
2650 if (!console_blanked
)
2652 if (!vc_cons_allocated(fg_console
)) {
2654 printk("unblank_screen: tty %d not allocated ??\n", fg_console
+1);
2657 timer_table
[BLANK_TIMER
].fn
= blank_screen
;
2658 if (blankinterval
) {
2659 timer_table
[BLANK_TIMER
].expires
= jiffies
+ blankinterval
;
2660 timer_active
|= 1<<BLANK_TIMER
;
2663 currcons
= fg_console
;
2664 console_blanked
= 0;
2665 if (console_blank_hook
)
2666 console_blank_hook(0);
2667 if (sw
->con_blank(vc_cons
[currcons
].d
, 0))
2668 /* Low-level driver cannot restore -> do it ourselves */
2669 update_screen(fg_console
);
2670 set_cursor(fg_console
);
2673 static void blank_screen(void)
2678 void poke_blanked_console(void)
2680 timer_active
&= ~(1<<BLANK_TIMER
);
2681 if (vt_cons
[fg_console
]->vc_mode
== KD_GRAPHICS
)
2683 if (console_blanked
) {
2684 timer_table
[BLANK_TIMER
].fn
= unblank_screen
;
2685 timer_table
[BLANK_TIMER
].expires
= jiffies
; /* Now */
2686 timer_active
|= 1<<BLANK_TIMER
;
2687 } else if (blankinterval
) {
2688 timer_table
[BLANK_TIMER
].expires
= jiffies
+ blankinterval
;
2689 timer_active
|= 1<<BLANK_TIMER
;
2697 void set_palette(int currcons
)
2699 if (vcmode
!= KD_GRAPHICS
)
2700 sw
->con_set_palette(vc_cons
[currcons
].d
, color_table
);
2703 static int set_get_cmap(unsigned char *arg
, int set
)
2707 for (i
= 0; i
< 16; i
++)
2709 get_user(default_red
[i
], arg
++);
2710 get_user(default_grn
[i
], arg
++);
2711 get_user(default_blu
[i
], arg
++);
2713 put_user(default_red
[i
], arg
++);
2714 put_user(default_grn
[i
], arg
++);
2715 put_user(default_blu
[i
], arg
++);
2718 for (i
= 0; i
< MAX_NR_CONSOLES
; i
++)
2719 if (vc_cons_allocated(i
)) {
2720 for (j
= k
= 0; j
< 16; j
++) {
2721 vc_cons
[i
].d
->vc_palette
[k
++] = default_red
[j
];
2722 vc_cons
[i
].d
->vc_palette
[k
++] = default_grn
[j
];
2723 vc_cons
[i
].d
->vc_palette
[k
++] = default_blu
[j
];
2732 * Load palette into the DAC registers. arg points to a colour
2733 * map, 3 bytes per colour, 16 colours, range from 0 to 255.
2736 int con_set_cmap(unsigned char *arg
)
2738 return set_get_cmap (arg
,1);
2741 int con_get_cmap(unsigned char *arg
)
2743 return set_get_cmap (arg
,0);
2746 void reset_palette(int currcons
)
2749 for (j
=k
=0; j
<16; j
++) {
2750 palette
[k
++] = default_red
[j
];
2751 palette
[k
++] = default_grn
[j
];
2752 palette
[k
++] = default_blu
[j
];
2754 set_palette(currcons
);
2760 * Currently we only support fonts up to 32 pixels wide, at a maximum height
2761 * of 32 pixels. Userspace fontdata is stored with 32 bytes (shorts/ints,
2762 * depending on width) reserved for each character which is kinda wasty, but
2763 * this is done in order to maintain compatibility with the EGA/VGA fonts. It
2764 * is upto the actual low-level console-driver convert data into its favorite
2765 * format (maybe we should add a `fontoffset' field to the `display'
2766 * structure so we wont have to convert the fontdata all the time.
2770 #define max_font_size 65536
2772 int con_font_op(int currcons
, struct console_font_op
*op
)
2775 int size
= max_font_size
, set
;
2777 struct console_font_op old_op
;
2779 if (vt_cons
[currcons
]->vc_mode
!= KD_TEXT
)
2781 memcpy(&old_op
, op
, sizeof(old_op
));
2782 if (op
->op
== KD_FONT_OP_SET
) {
2785 if (op
->charcount
> 512)
2787 if (!op
->height
) { /* Need to guess font height [compat] */
2789 u8
*charmap
= op
->data
, tmp
;
2791 /* If from KDFONTOP ioctl, don't allow things which can be done in userland,
2792 so that we can get rid of this soon */
2793 if (!(op
->flags
& KD_FONT_FLAG_OLD
))
2796 for (h
= 32; h
> 0; h
--)
2797 for (i
= 0; i
< op
->charcount
; i
++) {
2798 if (get_user(tmp
, &charmap
[32*i
+h
-1]))
2809 if (op
->width
> 32 || op
->height
> 32)
2811 size
= (op
->width
+7)/8 * 32 * op
->charcount
;
2812 if (size
> max_font_size
)
2815 } else if (op
->op
== KD_FONT_OP_GET
)
2818 return sw
->con_font_op(vc_cons
[currcons
].d
, op
);
2820 temp
= kmalloc(size
, GFP_KERNEL
);
2823 if (set
&& copy_from_user(temp
, op
->data
, size
)) {
2830 spin_lock_irq(&console_lock
);
2831 rc
= sw
->con_font_op(vc_cons
[currcons
].d
, op
);
2832 spin_unlock_irq(&console_lock
);
2834 op
->data
= old_op
.data
;
2836 int c
= (op
->width
+7)/8 * 32 * op
->charcount
;
2838 if (op
->data
&& op
->charcount
> old_op
.charcount
)
2840 if (!(op
->flags
& KD_FONT_FLAG_OLD
)) {
2841 if (op
->width
> old_op
.width
||
2842 op
->height
> old_op
.height
)
2847 else if ((old_op
.height
&& op
->height
> old_op
.height
) ||
2851 if (!rc
&& op
->data
&& copy_to_user(op
->data
, temp
, c
))
2855 kfree_s(temp
, size
);
2860 * Interface exported to selection and vcs.
2863 /* used by selection */
2864 u16
screen_glyph(int currcons
, int offset
)
2866 u16 w
= scr_readw(screenpos(currcons
, offset
, 1));
2869 if (w
& hi_font_mask
)
2874 /* used by vcs - note the word offset */
2875 unsigned short *screen_pos(int currcons
, int w_offset
, int viewed
)
2877 return screenpos(currcons
, 2 * w_offset
, viewed
);
2880 void getconsxy(int currcons
, char *p
)
2886 void putconsxy(int currcons
, char *p
)
2888 gotoxy(currcons
, p
[0], p
[1]);
2889 set_cursor(currcons
);
2892 u16
vcs_scr_readw(int currcons
, const u16
*org
)
2894 if ((unsigned long)org
== pos
&& softcursor_original
!= -1)
2895 return softcursor_original
;
2896 return scr_readw(org
);
2899 void vcs_scr_writew(int currcons
, u16 val
, u16
*org
)
2901 scr_writew(val
, org
);
2902 if ((unsigned long)org
== pos
) {
2903 softcursor_original
= -1;
2904 add_softcursor(currcons
);
2908 static int pm_con_request(struct pm_dev
*dev
, pm_request_t rqst
, void *data
)
2923 * Visible symbols for modules
2926 EXPORT_SYMBOL(color_table
);
2927 EXPORT_SYMBOL(default_red
);
2928 EXPORT_SYMBOL(default_grn
);
2929 EXPORT_SYMBOL(default_blu
);
2930 EXPORT_SYMBOL(video_font_height
);
2931 EXPORT_SYMBOL(video_scan_lines
);
2932 EXPORT_SYMBOL(vc_resize
);
2933 EXPORT_SYMBOL(fg_console
);
2935 #ifndef VT_SINGLE_DRIVER
2936 EXPORT_SYMBOL(take_over_console
);
2937 EXPORT_SYMBOL(give_up_console
);