2 * linux/drivers/char/vt.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
70 * Removed old-style timers, introduced console_timer, made timer
71 * deletion SMP-safe. 17Jun00, Andrew Morton <andrewm@uow.edu.au>
73 * Removed console_lock, enabled interrupts across all console operations
74 * 13 March 2001, Andrew Morton
77 #include <linux/module.h>
78 #include <linux/types.h>
79 #include <linux/sched.h>
80 #include <linux/tty.h>
81 #include <linux/tty_flip.h>
82 #include <linux/kernel.h>
83 #include <linux/string.h>
84 #include <linux/errno.h>
86 #include <linux/slab.h>
87 #include <linux/major.h>
89 #include <linux/console.h>
90 #include <linux/init.h>
91 #include <linux/devfs_fs_kernel.h>
92 #include <linux/vt_kern.h>
93 #include <linux/selection.h>
94 #include <linux/tiocl.h>
95 #include <linux/kbd_kern.h>
96 #include <linux/consolemap.h>
97 #include <linux/timer.h>
98 #include <linux/interrupt.h>
99 #include <linux/config.h>
100 #include <linux/workqueue.h>
101 #include <linux/bootmem.h>
102 #include <linux/pm.h>
103 #include <linux/font.h>
106 #include <asm/system.h>
107 #include <asm/uaccess.h>
108 #include <asm/bitops.h>
110 #include "console_macros.h"
113 const struct consw *conswitchp;
115 /* A bitmap for codes <32. A bit of 1 indicates that the code
116 * corresponding to that bit number invokes some special action
117 * (such as cursor movement) and should not be displayed as a
118 * glyph unless the disp_ctrl mode is explicitly enabled.
120 #define CTRL_ACTION 0x0d00ff81
121 #define CTRL_ALWAYS 0x0800f501 /* Cannot be overridden by disp_ctrl */
124 * Here is the default bell parameters: 750HZ, 1/8th of a second
126 #define DEFAULT_BELL_PITCH 750
127 #define DEFAULT_BELL_DURATION (HZ/8)
129 extern void vcs_make_devfs(struct tty_struct *tty);
130 extern void vcs_remove_devfs(struct tty_struct *tty);
132 extern void console_map_init(void);
133 #ifdef CONFIG_PROM_CONSOLE
134 extern void prom_con_init(void);
136 #ifdef CONFIG_MDA_CONSOLE
137 extern int mda_console_init(void);
140 struct vc vc_cons [MAX_NR_CONSOLES];
142 #ifndef VT_SINGLE_DRIVER
143 static const struct consw *con_driver_map[MAX_NR_CONSOLES];
146 static int con_open(struct tty_struct *, struct file *);
147 static void vc_init(unsigned int console, unsigned int rows,
148 unsigned int cols, int do_clear);
149 static void gotoxy(int currcons, int new_x, int new_y);
150 static void save_cur(int currcons);
151 static void reset_terminal(int currcons, int do_clear);
152 static void con_flush_chars(struct tty_struct *tty);
153 static void set_vesa_blanking(char __user *p);
154 static void set_cursor(int currcons);
155 static void hide_cursor(int currcons);
156 static void console_callback(void *ignored);
157 static void blank_screen_t(unsigned long dummy);
159 static int printable; /* Is console ready for printing? */
162 * ignore_poke: don't unblank the screen when things are typed. This is
163 * mainly for the privacy of braille terminal users.
165 static int ignore_poke;
167 int do_poke_blanked_console;
170 static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
171 static int blankinterval = 10*60*HZ;
172 static int vesa_off_interval;
174 static DECLARE_WORK(console_work, console_callback, NULL);
177 * fg_console is the current virtual console,
178 * last_console is the last used one,
179 * want_console is the console we want to switch to,
180 * kmsg_redirect is the console for kernel messages,
184 int want_console = -1;
188 * For each existing display, we have a pointer to console currently visible
189 * on that display, allowing consoles other than fg_console to be refreshed
190 * appropriately. Unless the low-level driver supplies its own display_fg
191 * variable, we use this one for the "master display".
193 static struct vc_data *master_display_fg;
196 * Unfortunately, we need to delay tty echo when we're currently writing to the
197 * console since the code is (and always was) not re-entrant, so we schedule
198 * all flip requests to process context with schedule-task() and run it from
199 * console_callback().
203 * For the same reason, we defer scrollback to the console callback.
205 static int scrollback_delta;
208 * Hook so that the power management routines can (un)blank
209 * the console on our behalf.
211 int (*console_blank_hook)(int);
213 static struct timer_list console_timer;
214 static int blank_state;
215 static int blank_timer_expired;
223 * Low-Level Functions
226 #define IS_FG (currcons == fg_console)
227 #define IS_VISIBLE CON_IS_VISIBLE(vc_cons[currcons].d)
229 #ifdef VT_BUF_VRAM_ONLY
232 #define DO_UPDATE IS_VISIBLE
235 static int pm_con_request(struct pm_dev *dev, pm_request_t rqst, void *data);
236 static struct pm_dev *pm_con;
238 static inline unsigned short *screenpos(int currcons, int offset, int viewed)
243 p = (unsigned short *)(origin + offset);
244 else if (!sw->con_screen_pos)
245 p = (unsigned short *)(visible_origin + offset);
247 p = sw->con_screen_pos(vc_cons[currcons].d, offset);
251 static inline void scrolldelta(int lines)
253 scrollback_delta += lines;
254 schedule_console_callback();
257 void schedule_console_callback(void)
259 schedule_work(&console_work);
262 static void scrup(int currcons, unsigned int t, unsigned int b, int nr)
264 unsigned short *d, *s;
268 if (b > video_num_lines || t >= b || nr < 1)
270 if (IS_VISIBLE && sw->con_scroll(vc_cons[currcons].d, t, b, SM_UP, nr))
272 d = (unsigned short *) (origin+video_size_row*t);
273 s = (unsigned short *) (origin+video_size_row*(t+nr));
274 scr_memmovew(d, s, (b-t-nr) * video_size_row);
275 scr_memsetw(d + (b-t-nr) * video_num_columns, video_erase_char, video_size_row*nr);
279 scrdown(int currcons, unsigned int t, unsigned int b, int nr)
286 if (b > video_num_lines || t >= b || nr < 1)
288 if (IS_VISIBLE && sw->con_scroll(vc_cons[currcons].d, t, b, SM_DOWN, nr))
290 s = (unsigned short *) (origin+video_size_row*t);
291 step = video_num_columns * nr;
292 scr_memmovew(s + step, s, (b-t-nr)*video_size_row);
293 scr_memsetw(s, video_erase_char, 2*step);
296 static void do_update_region(int currcons, unsigned long start, int count)
298 #ifndef VT_BUF_VRAM_ONLY
299 unsigned int xx, yy, offset;
303 if (!sw->con_getxy) {
304 offset = (start - origin) / 2;
305 xx = offset % video_num_columns;
306 yy = offset / video_num_columns;
309 start = sw->con_getxy(vc_cons[currcons].d, start, &nxx, &nyy);
313 u16 attrib = scr_readw(p) & 0xff00;
316 while (xx < video_num_columns && count) {
317 if (attrib != (scr_readw(p) & 0xff00)) {
319 sw->con_putcs(vc_cons[currcons].d, q, p-q, yy, startx);
322 attrib = scr_readw(p) & 0xff00;
329 sw->con_putcs(vc_cons[currcons].d, q, p-q, yy, startx);
336 start = sw->con_getxy(vc_cons[currcons].d, start, NULL, NULL);
342 void update_region(int currcons, unsigned long start, int count)
344 WARN_CONSOLE_UNLOCKED();
347 hide_cursor(currcons);
348 do_update_region(currcons, start, count);
349 set_cursor(currcons);
353 /* Structure of attributes is hardware-dependent */
355 static u8 build_attr(int currcons, u8 _color, u8 _intensity, u8 _blink, u8 _underline, u8 _reverse)
357 if (sw->con_build_attr)
358 return sw->con_build_attr(vc_cons[currcons].d, _color, _intensity, _blink, _underline, _reverse);
360 #ifndef VT_BUF_VRAM_ONLY
362 * ++roman: I completely changed the attribute format for monochrome
363 * mode (!can_do_color). The formerly used MDA (monochrome display
364 * adapter) format didn't allow the combination of certain effects.
365 * Now the attribute is just a bit vector:
366 * Bit 0..1: intensity (0..2)
375 (_underline ? 4 : 0) |
379 a = (a & 0xf0) | ulcolor;
380 else if (_intensity == 0)
381 a = (a & 0xf0) | halfcolor;
383 a = ((a) & 0x88) | ((((a) >> 4) | ((a) << 4)) & 0x77);
388 if (hi_font_mask == 0x100)
397 static void update_attr(int currcons)
399 attr = build_attr(currcons, color, intensity, blink, underline, reverse ^ decscnm);
400 video_erase_char = (build_attr(currcons, color, 1, blink, 0, decscnm) << 8) | ' ';
403 /* Note: inverting the screen twice should revert to the original state */
405 void invert_screen(int currcons, int offset, int count, int viewed)
409 WARN_CONSOLE_UNLOCKED();
412 p = screenpos(currcons, offset, viewed);
413 if (sw->con_invert_region)
414 sw->con_invert_region(vc_cons[currcons].d, p, count);
415 #ifndef VT_BUF_VRAM_ONLY
428 } else if (hi_font_mask == 0x100) {
431 a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | (((a) & 0x0e00) << 4);
438 a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | (((a) & 0x0700) << 4);
446 do_update_region(currcons, (unsigned long) p, count);
449 /* used by selection: complement pointer position */
450 void complement_pos(int currcons, int offset)
452 static unsigned short *p;
453 static unsigned short old;
454 static unsigned short oldx, oldy;
456 WARN_CONSOLE_UNLOCKED();
461 sw->con_putc(vc_cons[currcons].d, old, oldy, oldx);
467 p = screenpos(currcons, offset, 1);
469 new = old ^ complement_mask;
472 oldx = (offset >> 1) % video_num_columns;
473 oldy = (offset >> 1) / video_num_columns;
474 sw->con_putc(vc_cons[currcons].d, new, oldy, oldx);
479 static void insert_char(int currcons, unsigned int nr)
481 unsigned short *p, *q = (unsigned short *) pos;
483 p = q + video_num_columns - nr - x;
485 scr_writew(scr_readw(p), p + nr);
486 scr_memsetw(q, video_erase_char, nr*2);
489 unsigned short oldattr = attr;
490 sw->con_bmove(vc_cons[currcons].d,y,x,y,x+nr,1,
491 video_num_columns-x-nr);
492 attr = video_erase_char >> 8;
494 sw->con_putc(vc_cons[currcons].d,
495 video_erase_char,y,x+nr);
500 static void delete_char(int currcons, unsigned int nr)
503 unsigned short *p = (unsigned short *) pos;
505 while (++i <= video_num_columns - nr) {
506 scr_writew(scr_readw(p+nr), p);
509 scr_memsetw(p, video_erase_char, nr*2);
512 unsigned short oldattr = attr;
513 sw->con_bmove(vc_cons[currcons].d, y, x+nr, y, x, 1,
514 video_num_columns-x-nr);
515 attr = video_erase_char >> 8;
517 sw->con_putc(vc_cons[currcons].d,
519 video_num_columns-1-nr);
524 static int softcursor_original;
526 static void add_softcursor(int currcons)
528 int i = scr_readw((u16 *) pos);
529 u32 type = cursor_type;
531 if (! (type & 0x10)) return;
532 if (softcursor_original != -1) return;
533 softcursor_original = i;
534 i |= ((type >> 8) & 0xff00 );
535 i ^= ((type) & 0xff00 );
536 if ((type & 0x20) && ((softcursor_original & 0x7000) == (i & 0x7000))) i ^= 0x7000;
537 if ((type & 0x40) && ((i & 0x700) == ((i & 0x7000) >> 4))) i ^= 0x0700;
538 scr_writew(i, (u16 *) pos);
540 sw->con_putc(vc_cons[currcons].d, i, y, x);
543 static void hide_softcursor(int currcons)
545 if (softcursor_original != -1) {
546 scr_writew(softcursor_original,(u16 *) pos);
548 sw->con_putc(vc_cons[currcons].d, softcursor_original, y, x);
549 softcursor_original = -1;
553 static void hide_cursor(int currcons)
555 if (currcons == sel_cons)
557 sw->con_cursor(vc_cons[currcons].d,CM_ERASE);
558 hide_softcursor(currcons);
561 static void set_cursor(int currcons)
563 if (!IS_FG || console_blanked || vcmode == KD_GRAPHICS)
566 if (currcons == sel_cons)
568 add_softcursor(currcons);
569 if ((cursor_type & 0x0f) != 1)
570 sw->con_cursor(vc_cons[currcons].d,CM_DRAW);
572 hide_cursor(currcons);
575 static void set_origin(int currcons)
577 WARN_CONSOLE_UNLOCKED();
580 !sw->con_set_origin ||
581 !sw->con_set_origin(vc_cons[currcons].d))
582 origin = (unsigned long) screenbuf;
583 visible_origin = origin;
584 scr_end = origin + screenbuf_size;
585 pos = origin + video_size_row*y + 2*x;
588 static inline void save_screen(int currcons)
590 WARN_CONSOLE_UNLOCKED();
592 if (sw->con_save_screen)
593 sw->con_save_screen(vc_cons[currcons].d);
597 * Redrawing of screen
600 static void clear_buffer_attributes(int currcons)
602 unsigned short *p = (unsigned short *) origin;
603 int count = screenbuf_size/2;
604 int mask = hi_font_mask | 0xff;
606 for (; count > 0; count--, p++) {
607 scr_writew((scr_readw(p)&mask) | (video_erase_char&~mask), p);
611 void redraw_screen(int new_console, int is_switch)
614 int currcons, old_console;
616 WARN_CONSOLE_UNLOCKED();
618 if (!vc_cons_allocated(new_console)) {
620 /* printk("redraw_screen: tty %d not allocated ??\n", new_console+1); */
625 currcons = fg_console;
626 hide_cursor(currcons);
627 if (fg_console != new_console) {
628 struct vc_data **display = vc_cons[new_console].d->vc_display_fg;
629 old_console = (*display) ? (*display)->vc_num : fg_console;
630 *display = vc_cons[new_console].d;
631 fg_console = new_console;
632 currcons = old_console;
634 save_screen(currcons);
635 set_origin(currcons);
637 currcons = new_console;
638 if (old_console == new_console)
642 currcons = new_console;
643 hide_cursor(currcons);
648 int old_was_color = vc_cons[currcons].d->vc_can_do_color;
650 set_origin(currcons);
651 update = sw->con_switch(vc_cons[currcons].d);
652 set_palette(currcons);
654 * If console changed from mono<->color, the best we can do
655 * is to clear the buffer attributes. As it currently stands,
656 * rebuilding new attributes from the old buffer is not doable
657 * without overly complex code.
659 if (old_was_color != vc_cons[currcons].d->vc_can_do_color) {
660 update_attr(currcons);
661 clear_buffer_attributes(currcons);
663 if (update && vcmode != KD_GRAPHICS)
664 do_update_region(currcons, origin, screenbuf_size/2);
666 set_cursor(currcons);
669 compute_shiftstate();
674 * Allocation, freeing and resizing of VTs.
677 int vc_cons_allocated(unsigned int i)
679 return (i < MAX_NR_CONSOLES && vc_cons[i].d);
682 static void visual_init(int currcons, int init)
684 /* ++Geert: sw->con_init determines console size */
686 module_put(sw->owner);
688 #ifndef VT_SINGLE_DRIVER
689 if (con_driver_map[currcons])
690 sw = con_driver_map[currcons];
692 __module_get(sw->owner);
694 display_fg = &master_display_fg;
695 vc_cons[currcons].d->vc_uni_pagedir_loc = &vc_cons[currcons].d->vc_uni_pagedir;
696 vc_cons[currcons].d->vc_uni_pagedir = 0;
700 sw->con_init(vc_cons[currcons].d, init);
701 if (!complement_mask)
702 complement_mask = can_do_color ? 0x7700 : 0x0800;
703 s_complement_mask = complement_mask;
704 video_size_row = video_num_columns<<1;
705 screenbuf_size = video_num_lines*video_size_row;
708 int vc_allocate(unsigned int currcons) /* return 0 on success */
710 WARN_CONSOLE_UNLOCKED();
712 if (currcons >= MAX_NR_CONSOLES)
714 if (!vc_cons[currcons].d) {
717 /* prevent users from taking too much memory */
718 if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE))
721 /* due to the granularity of kmalloc, we waste some memory here */
722 /* the alloc is done in two steps, to optimize the common situation
723 of a 25x80 console (structsize=216, screenbuf_size=4000) */
724 /* although the numbers above are not valid since long ago, the
725 point is still up-to-date and the comment still has its value
726 even if only as a historical artifact. --mj, July 1998 */
727 p = (long) kmalloc(structsize, GFP_KERNEL);
730 memset((void *)p, 0, structsize);
731 vc_cons[currcons].d = (struct vc_data *)p;
732 vt_cons[currcons] = (struct vt_struct *)(p+sizeof(struct vc_data));
733 visual_init(currcons, 1);
734 if (!*vc_cons[currcons].d->vc_uni_pagedir_loc)
735 con_set_default_unimap(currcons);
736 q = (long)kmalloc(screenbuf_size, GFP_KERNEL);
739 vc_cons[currcons].d = NULL;
740 vt_cons[currcons] = NULL;
743 screenbuf = (unsigned short *) q;
745 vc_init(currcons, video_num_lines, video_num_columns, 1);
748 pm_con = pm_register(PM_SYS_DEV,
756 inline int resize_screen(int currcons, int width, int height)
758 /* Resizes the resolution of the display adapater */
761 if (vcmode != KD_GRAPHICS && sw->con_resize)
762 err = sw->con_resize(vc_cons[currcons].d, width, height);
767 * Change # of rows and columns (0 means unchanged/the size of fg_console)
768 * [this is to be used together with some user program
769 * like resize that changes the hardware videomode]
771 int vc_resize(int currcons, unsigned int cols, unsigned int lines)
773 unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0;
774 unsigned int old_cols, old_rows, old_row_size, old_screen_size;
775 unsigned int new_cols, new_rows, new_row_size, new_screen_size;
776 unsigned short *newscreen;
778 WARN_CONSOLE_UNLOCKED();
780 if (!vc_cons_allocated(currcons))
783 new_cols = (cols ? cols : video_num_columns);
784 new_rows = (lines ? lines : video_num_lines);
785 new_row_size = new_cols << 1;
786 new_screen_size = new_row_size * new_rows;
788 if (new_cols == video_num_columns && new_rows == video_num_lines)
791 newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER);
795 old_rows = video_num_lines;
796 old_cols = video_num_columns;
797 old_row_size = video_size_row;
798 old_screen_size = screenbuf_size;
800 err = resize_screen(currcons, new_cols, new_rows);
806 video_num_lines = new_rows;
807 video_num_columns = new_cols;
808 video_size_row = new_row_size;
809 screenbuf_size = new_screen_size;
811 rlth = min(old_row_size, new_row_size);
812 rrem = new_row_size - rlth;
814 new_origin = (long) newscreen;
815 new_scr_end = new_origin + new_screen_size;
816 if (new_rows < old_rows)
817 old_origin += (old_rows - new_rows) * old_row_size;
819 update_attr(currcons);
821 while (old_origin < scr_end) {
822 scr_memcpyw((unsigned short *) new_origin, (unsigned short *) old_origin, rlth);
824 scr_memsetw((void *)(new_origin + rlth), video_erase_char, rrem);
825 old_origin += old_row_size;
826 new_origin += new_row_size;
828 if (new_scr_end > new_origin)
829 scr_memsetw((void *) new_origin, video_erase_char, new_scr_end - new_origin);
832 screenbuf = newscreen;
834 screenbuf_size = new_screen_size;
835 set_origin(currcons);
837 /* do part of a reset_terminal() */
839 bottom = video_num_lines;
840 gotoxy(currcons, x, y);
843 if (vc_cons[currcons].d->vc_tty) {
844 struct winsize ws, *cws = &vc_cons[currcons].d->vc_tty->winsize;
846 memset(&ws, 0, sizeof(ws));
847 ws.ws_row = video_num_lines;
848 ws.ws_col = video_num_columns;
849 ws.ws_ypixel = video_scan_lines;
850 if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) &&
851 vc_cons[currcons].d->vc_tty->pgrp > 0)
852 kill_pg(vc_cons[currcons].d->vc_tty->pgrp, SIGWINCH, 1);
857 update_screen(currcons);
862 void vc_disallocate(unsigned int currcons)
864 WARN_CONSOLE_UNLOCKED();
866 if (vc_cons_allocated(currcons)) {
867 sw->con_deinit(vc_cons[currcons].d);
870 if (currcons >= MIN_NR_CONSOLES)
871 kfree(vc_cons[currcons].d);
872 vc_cons[currcons].d = NULL;
880 #define set_kbd(x) set_vc_kbd_mode(kbd_table+currcons,x)
881 #define clr_kbd(x) clr_vc_kbd_mode(kbd_table+currcons,x)
882 #define is_kbd(x) vc_kbd_mode(kbd_table+currcons,x)
884 #define decarm VC_REPEAT
885 #define decckm VC_CKMODE
886 #define kbdapplic VC_APPLIC
890 * this is what the terminal answers to a ESC-Z or csi0c query.
892 #define VT100ID "\033[?1;2c"
893 #define VT102ID "\033[?6c"
895 unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
896 8,12,10,14, 9,13,11,15 };
898 /* the default colour table, for VGA+ colour systems */
899 int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,
900 0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff};
901 int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,
902 0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff};
903 int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
904 0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff};
907 * gotoxy() must verify all boundaries, because the arguments
908 * might also be negative. If the given position is out of
909 * bounds, the cursor is placed at the nearest margin.
911 static void gotoxy(int currcons, int new_x, int new_y)
918 if (new_x >= video_num_columns)
919 x = video_num_columns - 1;
927 max_y = video_num_lines;
931 else if (new_y >= max_y)
935 pos = origin + y*video_size_row + (x<<1);
939 /* for absolute user moves, when decom is set */
940 static void gotoxay(int currcons, int new_x, int new_y)
942 gotoxy(currcons, new_x, decom ? (top+new_y) : new_y);
945 void scrollback(int lines)
947 int currcons = fg_console;
950 lines = video_num_lines/2;
954 void scrollfront(int lines)
956 int currcons = fg_console;
959 lines = video_num_lines/2;
963 static void lf(int currcons)
965 /* don't scroll if above bottom of scrolling region, or
966 * if below scrolling region
969 scrup(currcons,top,bottom,1);
970 else if (y < video_num_lines-1) {
972 pos += video_size_row;
977 static void ri(int currcons)
979 /* don't scroll if below top of scrolling region, or
980 * if above scrolling region
983 scrdown(currcons,top,bottom,1);
986 pos -= video_size_row;
991 static inline void cr(int currcons)
997 static inline void bs(int currcons)
1006 static inline void del(int currcons)
1011 static void csi_J(int currcons, int vpar)
1014 unsigned short * start;
1017 case 0: /* erase from cursor to end of display */
1018 count = (scr_end-pos)>>1;
1019 start = (unsigned short *) pos;
1021 /* do in two stages */
1022 sw->con_clear(vc_cons[currcons].d, y, x, 1,
1023 video_num_columns-x);
1024 sw->con_clear(vc_cons[currcons].d, y+1, 0,
1025 video_num_lines-y-1,
1029 case 1: /* erase from start to cursor */
1030 count = ((pos-origin)>>1)+1;
1031 start = (unsigned short *) origin;
1033 /* do in two stages */
1034 sw->con_clear(vc_cons[currcons].d, 0, 0, y,
1036 sw->con_clear(vc_cons[currcons].d, y, 0, 1,
1040 case 2: /* erase whole display */
1041 count = video_num_columns * video_num_lines;
1042 start = (unsigned short *) origin;
1044 sw->con_clear(vc_cons[currcons].d, 0, 0,
1051 scr_memsetw(start, video_erase_char, 2*count);
1055 static void csi_K(int currcons, int vpar)
1058 unsigned short * start;
1061 case 0: /* erase from cursor to end of line */
1062 count = video_num_columns-x;
1063 start = (unsigned short *) pos;
1065 sw->con_clear(vc_cons[currcons].d, y, x, 1,
1066 video_num_columns-x);
1068 case 1: /* erase from start of line to cursor */
1069 start = (unsigned short *) (pos - (x<<1));
1072 sw->con_clear(vc_cons[currcons].d, y, 0, 1,
1075 case 2: /* erase whole line */
1076 start = (unsigned short *) (pos - (x<<1));
1077 count = video_num_columns;
1079 sw->con_clear(vc_cons[currcons].d, y, 0, 1,
1085 scr_memsetw(start, video_erase_char, 2 * count);
1089 static void csi_X(int currcons, int vpar) /* erase the following vpar positions */
1095 count = (vpar > video_num_columns-x) ? (video_num_columns-x) : vpar;
1097 scr_memsetw((unsigned short *) pos, video_erase_char, 2 * count);
1099 sw->con_clear(vc_cons[currcons].d, y, x, 1, count);
1103 static void default_attr(int currcons)
1112 /* console_sem is held */
1113 static void csi_m(int currcons)
1117 for (i=0;i<=npar;i++)
1119 case 0: /* all attributes off */
1120 default_attr(currcons);
1137 case 10: /* ANSI X3.64-1979 (SCO-ish?)
1138 * Select primary font, don't display
1139 * control chars if defined, don't set
1142 translate = set_translate(charset == 0
1144 : G1_charset,currcons);
1148 case 11: /* ANSI X3.64-1979 (SCO-ish?)
1149 * Select first alternate font, lets
1150 * chars < 32 be displayed as ROM chars.
1152 translate = set_translate(IBMPC_MAP,currcons);
1156 case 12: /* ANSI X3.64-1979 (SCO-ish?)
1157 * Select second alternate font, toggle
1158 * high bit before displaying as ROM char.
1160 translate = set_translate(IBMPC_MAP,currcons);
1177 case 38: /* ANSI X3.64-1979 (SCO-ish?)
1178 * Enables underscore, white foreground
1179 * with white underscore (Linux - use
1180 * default foreground).
1182 color = (def_color & 0x0f) | background;
1185 case 39: /* ANSI X3.64-1979 (SCO-ish?)
1186 * Disable underline option.
1187 * Reset colour to default? It did this
1190 color = (def_color & 0x0f) | background;
1194 color = (def_color & 0xf0) | foreground;
1197 if (par[i] >= 30 && par[i] <= 37)
1198 color = color_table[par[i]-30]
1200 else if (par[i] >= 40 && par[i] <= 47)
1201 color = (color_table[par[i]-40]<<4)
1205 update_attr(currcons);
1208 static void respond_string(const char *p, struct tty_struct *tty)
1211 tty_insert_flip_char(tty, *p, 0);
1214 con_schedule_flip(tty);
1217 static void cursor_report(int currcons, struct tty_struct *tty)
1221 sprintf(buf, "\033[%d;%dR", y + (decom ? top+1 : 1), x+1);
1222 respond_string(buf, tty);
1225 static inline void status_report(struct tty_struct *tty)
1227 respond_string("\033[0n", tty); /* Terminal ok */
1230 static inline void respond_ID(struct tty_struct * tty)
1232 respond_string(VT102ID, tty);
1235 void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry)
1239 sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx),
1241 respond_string(buf, tty);
1244 /* invoked via ioctl(TIOCLINUX) and through set_selection */
1245 int mouse_reporting(void)
1247 int currcons = fg_console;
1249 return report_mouse;
1252 /* console_sem is held */
1253 static void set_mode(int currcons, int on_off)
1257 for (i=0; i<=npar; i++)
1258 if (ques) switch(par[i]) { /* DEC private modes set/reset */
1259 case 1: /* Cursor keys send ^[Ox/^[[x */
1265 case 3: /* 80/132 mode switch unimplemented */
1268 (void) vc_resize(deccolm ? 132 : 80, video_num_lines);
1269 /* this alone does not suffice; some user mode
1270 utility has to change the hardware regs */
1273 case 5: /* Inverted screen on/off */
1274 if (decscnm != on_off) {
1276 invert_screen(currcons, 0, screenbuf_size, 0);
1277 update_attr(currcons);
1280 case 6: /* Origin relative/absolute */
1282 gotoxay(currcons,0,0);
1284 case 7: /* Autowrap on/off */
1287 case 8: /* Autorepeat on/off */
1294 report_mouse = on_off ? 1 : 0;
1296 case 25: /* Cursor on/off */
1300 report_mouse = on_off ? 2 : 0;
1302 } else switch(par[i]) { /* ANSI modes set/reset */
1303 case 3: /* Monitor (display ctrls) */
1306 case 4: /* Insert Mode on/off */
1309 case 20: /* Lf, Enter == CrLf/Lf */
1318 /* console_sem is held */
1319 static void setterm_command(int currcons)
1322 case 1: /* set color for underline mode */
1323 if (can_do_color && par[1] < 16) {
1324 ulcolor = color_table[par[1]];
1326 update_attr(currcons);
1329 case 2: /* set color for half intensity mode */
1330 if (can_do_color && par[1] < 16) {
1331 halfcolor = color_table[par[1]];
1333 update_attr(currcons);
1336 case 8: /* store colors as defaults */
1338 if (hi_font_mask == 0x100)
1340 default_attr(currcons);
1341 update_attr(currcons);
1343 case 9: /* set blanking interval */
1344 blankinterval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ;
1345 poke_blanked_console();
1347 case 10: /* set bell frequency in Hz */
1349 bell_pitch = par[1];
1351 bell_pitch = DEFAULT_BELL_PITCH;
1353 case 11: /* set bell duration in msec */
1355 bell_duration = (par[1] < 2000) ?
1358 bell_duration = DEFAULT_BELL_DURATION;
1360 case 12: /* bring specified console to the front */
1361 if (par[1] >= 1 && vc_cons_allocated(par[1]-1))
1362 set_console(par[1] - 1);
1364 case 13: /* unblank the screen */
1365 poke_blanked_console();
1367 case 14: /* set vesa powerdown interval */
1368 vesa_off_interval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ;
1370 case 15: /* activate the previous console */
1371 set_console(last_console);
1376 /* console_sem is held */
1377 static void csi_at(int currcons, unsigned int nr)
1379 if (nr > video_num_columns - x)
1380 nr = video_num_columns - x;
1383 insert_char(currcons, nr);
1386 /* console_sem is held */
1387 static void csi_L(int currcons, unsigned int nr)
1389 if (nr > video_num_lines - y)
1390 nr = video_num_lines - y;
1393 scrdown(currcons,y,bottom,nr);
1397 /* console_sem is held */
1398 static void csi_P(int currcons, unsigned int nr)
1400 if (nr > video_num_columns - x)
1401 nr = video_num_columns - x;
1404 delete_char(currcons, nr);
1407 /* console_sem is held */
1408 static void csi_M(int currcons, unsigned int nr)
1410 if (nr > video_num_lines - y)
1411 nr = video_num_lines - y;
1414 scrup(currcons,y,bottom,nr);
1418 /* console_sem is held (except via vc_init->reset_terminal */
1419 static void save_cur(int currcons)
1423 s_intensity = intensity;
1424 s_underline = underline;
1426 s_reverse = reverse;
1427 s_charset = charset;
1429 saved_G0 = G0_charset;
1430 saved_G1 = G1_charset;
1433 /* console_sem is held */
1434 static void restore_cur(int currcons)
1436 gotoxy(currcons,saved_x,saved_y);
1437 intensity = s_intensity;
1438 underline = s_underline;
1440 reverse = s_reverse;
1441 charset = s_charset;
1443 G0_charset = saved_G0;
1444 G1_charset = saved_G1;
1445 translate = set_translate(charset ? G1_charset : G0_charset,currcons);
1446 update_attr(currcons);
1450 enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
1451 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
1454 /* console_sem is held (except via vc_init()) */
1455 static void reset_terminal(int currcons, int do_clear)
1458 bottom = video_num_lines;
1459 vc_state = ESnormal;
1461 translate = set_translate(LAT1_MAP,currcons);
1462 G0_charset = LAT1_MAP;
1463 G1_charset = GRAF_MAP;
1483 kbd_table[currcons].lockstate = 0;
1484 kbd_table[currcons].slockstate = 0;
1485 kbd_table[currcons].ledmode = LED_SHOW_FLAGS;
1486 kbd_table[currcons].ledflagstate = kbd_table[currcons].default_ledflagstate;
1487 /* do not do set_leds here because this causes an endless tasklet loop
1488 when the keyboard hasn't been initialized yet */
1490 cursor_type = CUR_DEFAULT;
1491 complement_mask = s_complement_mask;
1493 default_attr(currcons);
1494 update_attr(currcons);
1496 tab_stop[0] = 0x01010100;
1500 tab_stop[4] = 0x01010101;
1502 bell_pitch = DEFAULT_BELL_PITCH;
1503 bell_duration = DEFAULT_BELL_DURATION;
1505 gotoxy(currcons,0,0);
1511 /* console_sem is held */
1512 static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c)
1515 * Control characters can be used in the _middle_
1516 * of an escape sequence.
1523 kd_mksound(bell_pitch, bell_duration);
1530 while (x < video_num_columns - 1) {
1532 if (tab_stop[x >> 5] & (1 << (x & 31)))
1537 case 10: case 11: case 12:
1546 translate = set_translate(G1_charset,currcons);
1551 translate = set_translate(G0_charset,currcons);
1555 vc_state = ESnormal;
1564 vc_state = ESsquare;
1569 vc_state = ESnormal;
1572 vc_state = ESsquare;
1575 vc_state = ESnonstd;
1578 vc_state = ESpercent;
1591 tab_stop[x >> 5] |= (1 << (x & 31));
1600 restore_cur(currcons);
1612 reset_terminal(currcons,1);
1614 case '>': /* Numeric keypad */
1617 case '=': /* Appl. keypad */
1623 if (c=='P') { /* palette escape sequence */
1624 for (npar=0; npar<NPAR; npar++)
1627 vc_state = ESpalette;
1629 } else if (c=='R') { /* reset palette */
1630 reset_palette(currcons);
1631 vc_state = ESnormal;
1633 vc_state = ESnormal;
1636 if ( (c>='0'&&c<='9') || (c>='A'&&c<='F') || (c>='a'&&c<='f') ) {
1637 par[npar++] = (c>'9' ? (c&0xDF)-'A'+10 : c-'0') ;
1639 int i = par[0]*3, j = 1;
1640 palette[i] = 16*par[j++];
1641 palette[i++] += par[j++];
1642 palette[i] = 16*par[j++];
1643 palette[i++] += par[j++];
1644 palette[i] = 16*par[j++];
1645 palette[i] += par[j];
1646 set_palette(currcons);
1647 vc_state = ESnormal;
1650 vc_state = ESnormal;
1653 for(npar = 0 ; npar < NPAR ; npar++)
1656 vc_state = ESgetpars;
1657 if (c == '[') { /* Function key */
1665 if (c==';' && npar<NPAR-1) {
1668 } else if (c>='0' && c<='9') {
1672 } else vc_state=ESgotpars;
1674 vc_state = ESnormal;
1677 set_mode(currcons,1);
1680 set_mode(currcons,0);
1685 cursor_type = par[0] | (par[1]<<8) | (par[2]<<16);
1687 cursor_type = CUR_DEFAULT;
1695 complement_mask = par[0]<<8 | par[1];
1697 complement_mask = s_complement_mask;
1705 else if (par[0] == 6)
1706 cursor_report(currcons,tty);
1716 if (par[0]) par[0]--;
1717 gotoxy(currcons,par[0],y);
1720 if (!par[0]) par[0]++;
1721 gotoxy(currcons,x,y-par[0]);
1724 if (!par[0]) par[0]++;
1725 gotoxy(currcons,x,y+par[0]);
1728 if (!par[0]) par[0]++;
1729 gotoxy(currcons,x+par[0],y);
1732 if (!par[0]) par[0]++;
1733 gotoxy(currcons,x-par[0],y);
1736 if (!par[0]) par[0]++;
1737 gotoxy(currcons,0,y+par[0]);
1740 if (!par[0]) par[0]++;
1741 gotoxy(currcons,0,y-par[0]);
1744 if (par[0]) par[0]--;
1745 gotoxay(currcons,x,par[0]);
1748 if (par[0]) par[0]--;
1749 if (par[1]) par[1]--;
1750 gotoxay(currcons,par[1],par[0]);
1753 csi_J(currcons,par[0]);
1756 csi_K(currcons,par[0]);
1759 csi_L(currcons,par[0]);
1762 csi_M(currcons,par[0]);
1765 csi_P(currcons,par[0]);
1773 tab_stop[x >> 5] &= ~(1 << (x & 31));
1774 else if (par[0] == 3) {
1785 case 'q': /* DECLL - but only 3 leds */
1786 /* map 0,1,2,3 to 0,1,2,4 */
1788 setledstate(kbd_table + currcons,
1789 (par[0] < 3) ? par[0] : 4);
1795 par[1] = video_num_lines;
1796 /* Minimum allowed region is 2 lines */
1797 if (par[0] < par[1] &&
1798 par[1] <= video_num_lines) {
1801 gotoxay(currcons,0,0);
1808 restore_cur(currcons);
1811 csi_X(currcons, par[0]);
1814 csi_at(currcons,par[0]);
1816 case ']': /* setterm functions */
1817 setterm_command(currcons);
1822 vc_state = ESnormal;
1824 case '@': /* defined in ISO 2022 */
1827 case 'G': /* prelim official escape code */
1828 case '8': /* retained for compatibility */
1834 vc_state = ESnormal;
1837 vc_state = ESnormal;
1839 /* DEC screen alignment test. kludge :-) */
1841 (video_erase_char & 0xff00) | 'E';
1844 (video_erase_char & 0xff00) | ' ';
1845 do_update_region(currcons, origin, screenbuf_size/2);
1850 G0_charset = GRAF_MAP;
1852 G0_charset = LAT1_MAP;
1854 G0_charset = IBMPC_MAP;
1856 G0_charset = USER_MAP;
1858 translate = set_translate(G0_charset,currcons);
1859 vc_state = ESnormal;
1863 G1_charset = GRAF_MAP;
1865 G1_charset = LAT1_MAP;
1867 G1_charset = IBMPC_MAP;
1869 G1_charset = USER_MAP;
1871 translate = set_translate(G1_charset,currcons);
1872 vc_state = ESnormal;
1875 vc_state = ESnormal;
1879 /* This is a temporary buffer used to prepare a tty console write
1880 * so that we can easily avoid touching user space while holding the
1881 * console spinlock. It is allocated in con_init and is shared by
1882 * this code and the vc_screen read/write tty calls.
1884 * We have to allocate this statically in the kernel data section
1885 * since console_init (and thus con_init) are called before any
1886 * kernel memory allocation is available.
1888 char con_buf[CON_BUF_SIZE];
1889 DECLARE_MUTEX(con_buf_sem);
1891 /* acquires console_sem */
1892 static int do_con_write(struct tty_struct *tty, int from_user,
1893 const unsigned char *buf, int count)
1895 #ifdef VT_BUF_VRAM_ONLY
1896 #define FLUSH do { } while(0);
1898 #define FLUSH if (draw_x >= 0) { \
1899 sw->con_putcs(vc_cons[currcons].d, (u16 *)draw_from, (u16 *)draw_to-(u16 *)draw_from, y, draw_x); \
1904 int c, tc, ok, n = 0, draw_x = -1;
1905 unsigned int currcons;
1906 unsigned long draw_from = 0, draw_to = 0;
1907 struct vt_struct *vt;
1908 u16 himask, charmask;
1909 const unsigned char *orig_buf = NULL;
1917 acquire_console_sem();
1918 vt = tty->driver_data;
1920 printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
1921 release_console_sem();
1925 currcons = vt->vc_num;
1926 if (!vc_cons_allocated(currcons)) {
1927 /* could this happen? */
1928 static int error = 0;
1931 printk("con_write: tty %d not allocated\n", currcons+1);
1933 release_console_sem();
1936 release_console_sem();
1946 if (count > CON_BUF_SIZE)
1947 count = CON_BUF_SIZE;
1948 console_conditional_schedule();
1949 if (copy_from_user(con_buf, buf, count)) {
1950 n = 0; /* ?? are error codes legal here ?? */
1957 /* At this point 'buf' is guaranteed to be a kernel buffer
1958 * and therefore no access to userspace (and therefore sleeping)
1959 * will be needed. The con_buf_sem serializes all tty based
1960 * console rendering and vcs write/read operations. We hold
1961 * the console spinlock during the entire write.
1964 acquire_console_sem();
1966 vt = tty->driver_data;
1968 printk(KERN_ERR "vt: argh, driver_data _became_ NULL !\n");
1969 release_console_sem();
1973 himask = hi_font_mask;
1974 charmask = himask ? 0x1ff : 0xff;
1976 /* undraw cursor first */
1978 hide_cursor(currcons);
1980 while (!tty->stopped && count) {
1987 /* Do no translation at all in control states */
1988 if (vc_state != ESnormal) {
1991 /* Combine UTF-8 into Unicode */
1992 /* Incomplete characters silently ignored */
1994 if (utf_count > 0 && (c & 0xc0) == 0x80) {
1995 utf_char = (utf_char << 6) | (c & 0x3f);
2001 if ((c & 0xe0) == 0xc0) {
2003 utf_char = (c & 0x1f);
2004 } else if ((c & 0xf0) == 0xe0) {
2006 utf_char = (c & 0x0f);
2007 } else if ((c & 0xf8) == 0xf0) {
2009 utf_char = (c & 0x07);
2010 } else if ((c & 0xfc) == 0xf8) {
2012 utf_char = (c & 0x03);
2013 } else if ((c & 0xfe) == 0xfc) {
2015 utf_char = (c & 0x01);
2024 } else { /* no utf */
2025 tc = translate[toggle_meta ? (c|0x80) : c];
2028 /* If the original code was a control character we
2029 * only allow a glyph to be displayed if the code is
2030 * not normally used (such as for cursor movement) or
2031 * if the disp_ctrl mode has been explicitly enabled.
2032 * Certain characters (as given by the CTRL_ALWAYS
2033 * bitmap) are always displayed as control characters,
2034 * as the console would be pretty useless without
2035 * them; to display an arbitrary font position use the
2036 * direct-to-font zone in UTF-8 mode.
2038 ok = tc && (c >= 32 ||
2039 (!utf && !(((disp_ctrl ? CTRL_ALWAYS
2040 : CTRL_ACTION) >> c) & 1)))
2041 && (c != 127 || disp_ctrl)
2044 if (vc_state == ESnormal && ok) {
2045 /* Now try to find out how to display it */
2046 tc = conv_uni_to_pc(vc_cons[currcons].d, tc);
2048 /* If we got -4 (not found) then see if we have
2049 defined a replacement character (U+FFFD) */
2050 tc = conv_uni_to_pc(vc_cons[currcons].d, 0xfffd);
2052 /* One reason for the -4 can be that we just
2053 did a clear_unimap();
2054 try at least to show something. */
2057 } else if ( tc == -3 ) {
2058 /* Bad hash table -- hope for the best */
2062 continue; /* Conversion failed */
2064 if (need_wrap || decim)
2071 insert_char(currcons, 1);
2073 ((attr << 8) & ~himask) + ((tc & 0x100) ? himask : 0) + (tc & 0xff) :
2076 if (DO_UPDATE && draw_x < 0) {
2080 if (x == video_num_columns - 1) {
2090 do_con_trol(tty, currcons, orig);
2093 console_conditional_schedule();
2094 release_console_sem();
2098 /* If the user requested something larger than
2099 * the CON_BUF_SIZE, and the tty is not stopped,
2102 if ((orig_count > CON_BUF_SIZE) && !tty->stopped) {
2103 orig_count -= CON_BUF_SIZE;
2104 orig_buf += CON_BUF_SIZE;
2118 * This is the console switching callback.
2120 * Doing console switching in a process context allows
2121 * us to do the switches asynchronously (needed when we want
2122 * to switch due to a keyboard interrupt). Synchronization
2123 * with other console code and prevention of re-entrancy is
2124 * ensured with console_sem.
2126 static void console_callback(void *ignored)
2128 acquire_console_sem();
2130 if (want_console >= 0) {
2131 if (want_console != fg_console &&
2132 vc_cons_allocated(want_console)) {
2133 hide_cursor(fg_console);
2134 change_console(want_console);
2135 /* we only changed when the console had already
2136 been allocated - a new console is not created
2137 in an interrupt routine */
2141 if (do_poke_blanked_console) { /* do not unblank for a LED change */
2142 do_poke_blanked_console = 0;
2143 poke_blanked_console();
2145 if (scrollback_delta) {
2146 int currcons = fg_console;
2148 if (vcmode == KD_TEXT)
2149 sw->con_scrolldelta(vc_cons[currcons].d, scrollback_delta);
2150 scrollback_delta = 0;
2152 if (blank_timer_expired) {
2154 blank_timer_expired = 0;
2157 release_console_sem();
2160 void set_console(int nr)
2163 schedule_console_callback();
2166 struct tty_driver *console_driver;
2168 #ifdef CONFIG_VT_CONSOLE
2171 * Console on virtual terminal
2173 * The console must be locked when we get here.
2176 void vt_console_print(struct console *co, const char *b, unsigned count)
2178 int currcons = fg_console;
2180 static unsigned long printing;
2181 const ushort *start;
2185 /* console busy or not yet initialized */
2186 if (!printable || test_and_set_bit(0, &printing))
2191 if (kmsg_redirect && vc_cons_allocated(kmsg_redirect - 1))
2192 currcons = kmsg_redirect - 1;
2194 /* read `x' only after setting currcons properly (otherwise
2195 the `x' macro will read the x of the foreground console). */
2198 if (!vc_cons_allocated(currcons)) {
2200 /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */
2204 if (vcmode != KD_TEXT)
2207 /* undraw cursor first */
2209 hide_cursor(currcons);
2211 start = (ushort *)pos;
2213 /* Contrived structure to try to emulate original need_wrap behaviour
2214 * Problems caused when we have need_wrap set on '\n' character */
2217 if (c == 10 || c == 13 || c == 8 || need_wrap) {
2220 sw->con_putcs(vc_cons[currcons].d, start, cnt, y, x);
2226 if (c == 8) { /* backspace */
2228 start = (ushort *)pos;
2235 start = (ushort *)pos;
2237 if (c == 10 || c == 13)
2240 scr_writew((attr << 8) + c, (unsigned short *) pos);
2242 if (myx == video_num_columns - 1) {
2251 sw->con_putcs(vc_cons[currcons].d, start, cnt, y, x);
2253 if (x == video_num_columns) {
2258 set_cursor(currcons);
2260 if (!oops_in_progress)
2261 poke_blanked_console();
2264 clear_bit(0, &printing);
2267 static struct tty_driver *vt_console_device(struct console *c, int *index)
2269 *index = c->index ? c->index-1 : fg_console;
2270 return console_driver;
2273 struct console vt_console_driver = {
2275 .write = vt_console_print,
2276 .device = vt_console_device,
2277 .unblank = unblank_screen,
2278 .flags = CON_PRINTBUFFER,
2284 * Handling of Linux-specific VC ioctls
2288 * Generally a bit racy with respect to console_sem().
2290 * There are some functions which don't need it.
2292 * There are some functions which can sleep for arbitrary periods
2293 * (paste_selection) but we don't need the lock there anyway.
2295 * set_selection has locking, and definitely needs it
2298 int tioclinux(struct tty_struct *tty, unsigned long arg)
2301 char __user *p = (char __user *)arg;
2305 if (tty->driver->type != TTY_DRIVER_TYPE_CONSOLE)
2307 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN))
2309 if (get_user(type, p))
2315 acquire_console_sem();
2316 ret = set_selection((struct tiocl_selection __user *)(p+1), tty);
2317 release_console_sem();
2319 case TIOCL_PASTESEL:
2320 ret = paste_selection(tty);
2322 case TIOCL_UNBLANKSCREEN:
2325 case TIOCL_SELLOADLUT:
2326 ret = sel_loadlut(p);
2328 case TIOCL_GETSHIFTSTATE:
2331 * Make it possible to react to Shift+Mousebutton.
2332 * Note that 'shift_state' is an undocumented
2333 * kernel-internal variable; programs not closely
2334 * related to the kernel should not use this.
2337 ret = __put_user(data, p);
2339 case TIOCL_GETMOUSEREPORTING:
2340 data = mouse_reporting();
2341 ret = __put_user(data, p);
2343 case TIOCL_SETVESABLANK:
2344 set_vesa_blanking(p);
2346 case TIOCL_SETKMSGREDIRECT:
2347 if (!capable(CAP_SYS_ADMIN)) {
2350 if (get_user(data, p+1))
2353 kmsg_redirect = data;
2356 case TIOCL_GETFGCONSOLE:
2359 case TIOCL_SCROLLCONSOLE:
2360 if (get_user(lines, (s32 __user *)(p+4))) {
2367 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
2371 case TIOCL_BLANKEDSCREEN:
2372 ret = console_blanked;
2382 * /dev/ttyN handling
2385 static int con_write(struct tty_struct *tty, int from_user,
2386 const unsigned char *buf, int count)
2391 retval = do_con_write(tty, from_user, buf, count);
2392 con_flush_chars(tty);
2397 static void con_put_char(struct tty_struct *tty, unsigned char ch)
2400 return; /* n_r3964 calls put_char() from interrupt context */
2402 do_con_write(tty, 0, &ch, 1);
2405 static int con_write_room(struct tty_struct *tty)
2409 return 4096; /* No limit, really; we're not buffering */
2412 static int con_chars_in_buffer(struct tty_struct *tty)
2414 return 0; /* we're not buffering */
2418 * con_throttle and con_unthrottle are only used for
2419 * paste_selection(), which has to stuff in a large number of
2422 static void con_throttle(struct tty_struct *tty)
2426 static void con_unthrottle(struct tty_struct *tty)
2428 struct vt_struct *vt = tty->driver_data;
2430 wake_up_interruptible(&vt->paste_wait);
2434 * Turn the Scroll-Lock LED on when the tty is stopped
2436 static void con_stop(struct tty_struct *tty)
2441 console_num = tty->index;
2442 if (!vc_cons_allocated(console_num))
2444 set_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK);
2449 * Turn the Scroll-Lock LED off when the console is started
2451 static void con_start(struct tty_struct *tty)
2456 console_num = tty->index;
2457 if (!vc_cons_allocated(console_num))
2459 clr_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK);
2463 static void con_flush_chars(struct tty_struct *tty)
2465 struct vt_struct *vt;
2467 if (in_interrupt()) /* from flush_to_ldisc */
2472 /* if we race with con_close(), vt may be null */
2473 acquire_console_sem();
2474 vt = tty->driver_data;
2476 set_cursor(vt->vc_num);
2477 release_console_sem();
2481 * Allocate the console screen memory.
2483 static int con_open(struct tty_struct *tty, struct file *filp)
2485 unsigned int currcons = tty->index;
2488 acquire_console_sem();
2489 if (tty->count == 1) {
2490 ret = vc_allocate(currcons);
2492 vt_cons[currcons]->vc_num = currcons;
2493 tty->driver_data = vt_cons[currcons];
2494 vc_cons[currcons].d->vc_tty = tty;
2496 if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
2497 tty->winsize.ws_row = video_num_lines;
2498 tty->winsize.ws_col = video_num_columns;
2500 release_console_sem();
2501 vcs_make_devfs(tty);
2505 release_console_sem();
2510 * We take tty_sem in here to prevent another thread from coming in via init_dev
2511 * and taking a ref against the tty while we're in the process of forgetting
2512 * about it and cleaning things up.
2514 * This is because vcs_remove_devfs() can sleep and will drop the BKL.
2516 static void con_close(struct tty_struct *tty, struct file *filp)
2519 acquire_console_sem();
2520 if (tty && tty->count == 1) {
2521 struct vt_struct *vt;
2523 vt = tty->driver_data;
2525 vc_cons[vt->vc_num].d->vc_tty = NULL;
2526 tty->driver_data = NULL;
2527 release_console_sem();
2528 vcs_remove_devfs(tty);
2531 * tty_sem is released, but we still hold BKL, so there is
2532 * still exclusion against init_dev()
2536 release_console_sem();
2540 static void vc_init(unsigned int currcons, unsigned int rows,
2541 unsigned int cols, int do_clear)
2545 video_num_columns = cols;
2546 video_num_lines = rows;
2547 video_size_row = cols<<1;
2548 screenbuf_size = video_num_lines * video_size_row;
2550 set_origin(currcons);
2553 for (j=k=0; j<16; j++) {
2554 vc_cons[currcons].d->vc_palette[k++] = default_red[j] ;
2555 vc_cons[currcons].d->vc_palette[k++] = default_grn[j] ;
2556 vc_cons[currcons].d->vc_palette[k++] = default_blu[j] ;
2558 def_color = 0x07; /* white */
2559 ulcolor = 0x0f; /* bold white */
2560 halfcolor = 0x08; /* grey */
2561 init_waitqueue_head(&vt_cons[currcons]->paste_wait);
2562 reset_terminal(currcons, do_clear);
2566 * This routine initializes console interrupts, and does nothing
2567 * else. If you want the screen to clear, call tty_write with
2568 * the appropriate escape-sequence.
2571 static int __init con_init(void)
2573 const char *display_desc = NULL;
2574 unsigned int currcons = 0;
2576 acquire_console_sem();
2579 display_desc = conswitchp->con_startup();
2580 if (!display_desc) {
2582 release_console_sem();
2586 init_timer(&console_timer);
2587 console_timer.function = blank_screen_t;
2588 if (blankinterval) {
2589 blank_state = blank_normal_wait;
2590 mod_timer(&console_timer, jiffies + blankinterval);
2594 * kmalloc is not running yet - we use the bootmem allocator.
2596 for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
2597 vc_cons[currcons].d = (struct vc_data *)
2598 alloc_bootmem(sizeof(struct vc_data));
2599 vt_cons[currcons] = (struct vt_struct *)
2600 alloc_bootmem(sizeof(struct vt_struct));
2601 visual_init(currcons, 1);
2602 screenbuf = (unsigned short *) alloc_bootmem(screenbuf_size);
2604 vc_init(currcons, video_num_lines, video_num_columns,
2605 currcons || !sw->con_save_screen);
2607 currcons = fg_console = 0;
2608 master_display_fg = vc_cons[currcons].d;
2609 set_origin(currcons);
2610 save_screen(currcons);
2611 gotoxy(currcons,x,y);
2613 update_screen(fg_console);
2614 printk("Console: %s %s %dx%d",
2615 can_do_color ? "colour" : "mono",
2616 display_desc, video_num_columns, video_num_lines);
2620 release_console_sem();
2622 #ifdef CONFIG_VT_CONSOLE
2623 register_console(&vt_console_driver);
2627 console_initcall(con_init);
2629 static struct tty_operations con_ops = {
2633 .write_room = con_write_room,
2634 .put_char = con_put_char,
2635 .flush_chars = con_flush_chars,
2636 .chars_in_buffer = con_chars_in_buffer,
2640 .throttle = con_throttle,
2641 .unthrottle = con_unthrottle,
2644 int __init vty_init(void)
2648 console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
2649 if (!console_driver)
2650 panic("Couldn't allocate console driver\n");
2651 console_driver->owner = THIS_MODULE;
2652 console_driver->devfs_name = "vc/";
2653 console_driver->name = "tty";
2654 console_driver->name_base = 1;
2655 console_driver->major = TTY_MAJOR;
2656 console_driver->minor_start = 1;
2657 console_driver->type = TTY_DRIVER_TYPE_CONSOLE;
2658 console_driver->init_termios = tty_std_termios;
2659 console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
2660 tty_set_operations(console_driver, &con_ops);
2661 if (tty_register_driver(console_driver))
2662 panic("Couldn't register console driver\n");
2666 #ifdef CONFIG_PROM_CONSOLE
2669 #ifdef CONFIG_MDA_CONSOLE
2675 #ifndef VT_SINGLE_DRIVER
2678 * If we support more console drivers, this function is used
2679 * when a driver wants to take over some existing consoles
2680 * and become default driver for newly opened ones.
2683 int take_over_console(const struct consw *csw, int first, int last, int deflt)
2687 struct module *owner;
2690 if (!try_module_get(owner))
2693 acquire_console_sem();
2695 desc = csw->con_startup();
2697 release_console_sem();
2703 module_put(conswitchp->owner);
2704 __module_get(owner);
2708 for (i = first; i <= last; i++) {
2712 if (con_driver_map[i])
2713 module_put(con_driver_map[i]->owner);
2714 __module_get(owner);
2715 con_driver_map[i] = csw;
2717 if (!vc_cons[i].d || !vc_cons[i].d->vc_sw)
2723 old_was_color = vc_cons[i].d->vc_can_do_color;
2724 vc_cons[i].d->vc_sw->con_deinit(vc_cons[i].d);
2725 origin = (unsigned long) screenbuf;
2726 visible_origin = origin;
2727 scr_end = origin + screenbuf_size;
2728 pos = origin + video_size_row*y + 2*x;
2732 /* If the console changed between mono <-> color, then
2733 * the attributes in the screenbuf will be wrong. The
2734 * following resets all attributes to something sane.
2736 if (old_was_color != vc_cons[i].d->vc_can_do_color)
2737 clear_buffer_attributes(i);
2742 printk("Console: switching ");
2744 printk("consoles %d-%d ", first+1, last+1);
2746 printk("to %s %s %dx%d\n",
2747 vc_cons[j].d->vc_can_do_color ? "colour" : "mono",
2748 desc, vc_cons[j].d->vc_cols, vc_cons[j].d->vc_rows);
2750 printk("to %s\n", desc);
2752 release_console_sem();
2758 void give_up_console(const struct consw *csw)
2762 for(i = 0; i < MAX_NR_CONSOLES; i++)
2763 if (con_driver_map[i] == csw) {
2764 module_put(csw->owner);
2765 con_driver_map[i] = NULL;
2775 static void set_vesa_blanking(char __user *p)
2778 get_user(mode, p + 1);
2779 vesa_blank_mode = (mode < 4) ? mode : 0;
2783 * This is called by a timer handler
2785 static void vesa_powerdown(void)
2787 struct vc_data *c = vc_cons[fg_console].d;
2789 * Power down if currently suspended (1 or 2),
2790 * suspend if currently blanked (0),
2791 * else do nothing (i.e. already powered down (3)).
2792 * Called only if powerdown features are allowed.
2794 switch (vesa_blank_mode) {
2795 case VESA_NO_BLANKING:
2796 c->vc_sw->con_blank(c, VESA_VSYNC_SUSPEND+1, 0);
2798 case VESA_VSYNC_SUSPEND:
2799 case VESA_HSYNC_SUSPEND:
2800 c->vc_sw->con_blank(c, VESA_POWERDOWN+1, 0);
2805 void do_blank_screen(int entering_gfx)
2807 int currcons = fg_console;
2810 WARN_CONSOLE_UNLOCKED();
2812 if (console_blanked) {
2813 if (blank_state == blank_vesa_wait) {
2814 blank_state = blank_off;
2820 if (blank_state != blank_normal_wait)
2822 blank_state = blank_off;
2824 /* entering graphics mode? */
2826 hide_cursor(currcons);
2827 save_screen(currcons);
2828 sw->con_blank(vc_cons[currcons].d, -1, 1);
2829 console_blanked = fg_console + 1;
2830 set_origin(currcons);
2834 /* don't blank graphics */
2835 if (vcmode != KD_TEXT) {
2836 console_blanked = fg_console + 1;
2840 hide_cursor(currcons);
2841 del_timer_sync(&console_timer);
2842 blank_timer_expired = 0;
2844 save_screen(currcons);
2845 /* In case we need to reset origin, blanking hook returns 1 */
2846 i = sw->con_blank(vc_cons[currcons].d, 1, 0);
2847 console_blanked = fg_console + 1;
2849 set_origin(currcons);
2851 if (console_blank_hook && console_blank_hook(1))
2854 if (vesa_off_interval) {
2855 blank_state = blank_vesa_wait,
2856 mod_timer(&console_timer, jiffies + vesa_off_interval);
2859 if (vesa_blank_mode)
2860 sw->con_blank(vc_cons[currcons].d, vesa_blank_mode + 1, 0);
2865 * Called by timer as well as from vt_console_driver
2867 void do_unblank_screen(int leaving_gfx)
2871 WARN_CONSOLE_UNLOCKED();
2874 if (!console_blanked)
2876 if (!vc_cons_allocated(fg_console)) {
2878 printk("unblank_screen: tty %d not allocated ??\n", fg_console+1);
2881 currcons = fg_console;
2882 if (vcmode != KD_TEXT)
2883 return; /* but leave console_blanked != 0 */
2885 if (blankinterval) {
2886 mod_timer(&console_timer, jiffies + blankinterval);
2887 blank_state = blank_normal_wait;
2890 console_blanked = 0;
2891 if (sw->con_blank(vc_cons[currcons].d, 0, leaving_gfx))
2892 /* Low-level driver cannot restore -> do it ourselves */
2893 update_screen(fg_console);
2894 if (console_blank_hook)
2895 console_blank_hook(0);
2896 set_palette(currcons);
2897 set_cursor(fg_console);
2901 * This is called by the outside world to cause a forced unblank, mostly for
2902 * oopses. Currently, I just call do_unblank_screen(0), but we could eventually
2903 * call it with 1 as an argument and so force a mode restore... that may kill
2904 * X or at least garbage the screen but would also make the Oops visible...
2906 void unblank_screen(void)
2908 do_unblank_screen(0);
2912 * We defer the timer blanking to work queue so it can take the console semaphore
2913 * (console operations can still happen at irq time, but only from printk which
2914 * has the console semaphore. Not perfect yet, but better than no locking
2916 static void blank_screen_t(unsigned long dummy)
2918 blank_timer_expired = 1;
2919 schedule_work(&console_work);
2922 void poke_blanked_console(void)
2924 WARN_CONSOLE_UNLOCKED();
2926 /* This isn't perfectly race free, but a race here would be mostly harmless,
2927 * at worse, we'll do a spurrious blank and it's unlikely
2929 del_timer(&console_timer);
2930 blank_timer_expired = 0;
2932 if (ignore_poke || !vt_cons[fg_console] || vt_cons[fg_console]->vc_mode == KD_GRAPHICS)
2934 if (console_blanked)
2936 else if (blankinterval) {
2937 mod_timer(&console_timer, jiffies + blankinterval);
2938 blank_state = blank_normal_wait;
2946 void set_palette(int currcons)
2948 WARN_CONSOLE_UNLOCKED();
2950 if (vcmode != KD_GRAPHICS)
2951 sw->con_set_palette(vc_cons[currcons].d, color_table);
2954 static int set_get_cmap(unsigned char __user *arg, int set)
2958 WARN_CONSOLE_UNLOCKED();
2960 for (i = 0; i < 16; i++)
2962 get_user(default_red[i], arg++);
2963 get_user(default_grn[i], arg++);
2964 get_user(default_blu[i], arg++);
2966 put_user(default_red[i], arg++);
2967 put_user(default_grn[i], arg++);
2968 put_user(default_blu[i], arg++);
2971 for (i = 0; i < MAX_NR_CONSOLES; i++)
2972 if (vc_cons_allocated(i)) {
2973 for (j = k = 0; j < 16; j++) {
2974 vc_cons[i].d->vc_palette[k++] = default_red[j];
2975 vc_cons[i].d->vc_palette[k++] = default_grn[j];
2976 vc_cons[i].d->vc_palette[k++] = default_blu[j];
2985 * Load palette into the DAC registers. arg points to a colour
2986 * map, 3 bytes per colour, 16 colours, range from 0 to 255.
2989 int con_set_cmap(unsigned char __user *arg)
2993 acquire_console_sem();
2994 rc = set_get_cmap (arg,1);
2995 release_console_sem();
3000 int con_get_cmap(unsigned char __user *arg)
3004 acquire_console_sem();
3005 rc = set_get_cmap (arg,0);
3006 release_console_sem();
3011 void reset_palette(int currcons)
3014 for (j=k=0; j<16; j++) {
3015 palette[k++] = default_red[j];
3016 palette[k++] = default_grn[j];
3017 palette[k++] = default_blu[j];
3019 set_palette(currcons);
3025 * Currently we only support fonts up to 32 pixels wide, at a maximum height
3026 * of 32 pixels. Userspace fontdata is stored with 32 bytes (shorts/ints,
3027 * depending on width) reserved for each character which is kinda wasty, but
3028 * this is done in order to maintain compatibility with the EGA/VGA fonts. It
3029 * is upto the actual low-level console-driver convert data into its favorite
3030 * format (maybe we should add a `fontoffset' field to the `display'
3031 * structure so we won't have to convert the fontdata all the time.
3035 #define max_font_size 65536
3037 int con_font_get(int currcons, struct console_font_op *op)
3039 struct console_font font;
3043 if (vt_cons[currcons]->vc_mode != KD_TEXT)
3047 font.data = kmalloc(max_font_size, GFP_KERNEL);
3053 acquire_console_sem();
3054 if (sw->con_font_get)
3055 rc = sw->con_font_get(vc_cons[currcons].d, &font);
3058 release_console_sem();
3063 c = (font.width+7)/8 * 32 * font.charcount;
3065 if (op->data && font.charcount > op->charcount)
3067 if (!(op->flags & KD_FONT_FLAG_OLD)) {
3068 if (font.width > op->width || font.height > op->height)
3071 if (font.width != 8)
3073 else if ((op->height && font.height > op->height) ||
3080 if (op->data && copy_to_user(op->data, font.data, c))
3088 int con_font_set(int currcons, struct console_font_op *op)
3090 struct console_font font;
3094 if (vt_cons[currcons]->vc_mode != KD_TEXT)
3098 if (op->charcount > 512)
3100 if (!op->height) { /* Need to guess font height [compat] */
3102 u8 __user *charmap = op->data;
3105 /* If from KDFONTOP ioctl, don't allow things which can be done in userland,
3106 so that we can get rid of this soon */
3107 if (!(op->flags & KD_FONT_FLAG_OLD))
3109 for (h = 32; h > 0; h--)
3110 for (i = 0; i < op->charcount; i++) {
3111 if (get_user(tmp, &charmap[32*i+h-1]))
3120 if (op->width <= 0 || op->width > 32 || op->height > 32)
3122 size = (op->width+7)/8 * 32 * op->charcount;
3123 if (size > max_font_size)
3125 font.charcount = op->charcount;
3126 font.height = op->height;
3127 font.width = op->width;
3128 font.data = kmalloc(size, GFP_KERNEL);
3131 if (copy_from_user(font.data, op->data, size)) {
3135 acquire_console_sem();
3136 if (sw->con_font_set)
3137 rc = sw->con_font_set(vc_cons[currcons].d, &font, op->flags);
3140 release_console_sem();
3145 int con_font_default(int currcons, struct console_font_op *op)
3147 struct console_font font = {.width = op->width, .height = op->height};
3148 char name[MAX_FONT_NAME];
3152 if (vt_cons[currcons]->vc_mode != KD_TEXT)
3157 else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0)
3160 name[MAX_FONT_NAME - 1] = 0;
3162 acquire_console_sem();
3163 if (sw->con_font_default)
3164 rc = sw->con_font_default(vc_cons[currcons].d, &font, s);
3167 release_console_sem();
3169 op->width = font.width;
3170 op->height = font.height;
3175 int con_font_copy(int currcons, struct console_font_op *op)
3177 int con = op->height;
3181 if (vt_cons[currcons]->vc_mode != KD_TEXT)
3184 acquire_console_sem();
3185 vc = vc_cons[currcons].d;
3186 if (!sw->con_font_copy)
3188 else if (con < 0 || !vc_cons_allocated(con))
3190 else if (con == vc->vc_num) /* nothing to do */
3193 rc = sw->con_font_copy(vc, con);
3194 release_console_sem();
3198 int con_font_op(int currcons, struct console_font_op *op)
3201 case KD_FONT_OP_SET:
3202 return con_font_set(currcons, op);
3203 case KD_FONT_OP_GET:
3204 return con_font_get(currcons, op);
3205 case KD_FONT_OP_SET_DEFAULT:
3206 return con_font_default(currcons, op);
3207 case KD_FONT_OP_COPY:
3208 return con_font_copy(currcons, op);
3214 * Interface exported to selection and vcs.
3217 /* used by selection */
3218 u16 screen_glyph(int currcons, int offset)
3220 u16 w = scr_readw(screenpos(currcons, offset, 1));
3223 if (w & hi_font_mask)
3228 /* used by vcs - note the word offset */
3229 unsigned short *screen_pos(int currcons, int w_offset, int viewed)
3231 return screenpos(currcons, 2 * w_offset, viewed);
3234 void getconsxy(int currcons, unsigned char *p)
3240 void putconsxy(int currcons, unsigned char *p)
3242 gotoxy(currcons, p[0], p[1]);
3243 set_cursor(currcons);
3246 u16 vcs_scr_readw(int currcons, const u16 *org)
3248 if ((unsigned long)org == pos && softcursor_original != -1)
3249 return softcursor_original;
3250 return scr_readw(org);
3253 void vcs_scr_writew(int currcons, u16 val, u16 *org)
3255 scr_writew(val, org);
3256 if ((unsigned long)org == pos) {
3257 softcursor_original = -1;
3258 add_softcursor(currcons);
3262 static int pm_con_request(struct pm_dev *dev, pm_request_t rqst, void *data)
3267 acquire_console_sem();
3269 release_console_sem();
3272 acquire_console_sem();
3274 release_console_sem();
3281 * Visible symbols for modules
3284 EXPORT_SYMBOL(color_table);
3285 EXPORT_SYMBOL(default_red);
3286 EXPORT_SYMBOL(default_grn);
3287 EXPORT_SYMBOL(default_blu);
3288 EXPORT_SYMBOL(vc_cons_allocated);
3289 EXPORT_SYMBOL(update_region);
3290 EXPORT_SYMBOL(redraw_screen);
3291 EXPORT_SYMBOL(vc_resize);
3292 EXPORT_SYMBOL(fg_console);
3293 EXPORT_SYMBOL(console_blank_hook);
3294 EXPORT_SYMBOL(console_blanked);
3295 EXPORT_SYMBOL(vt_cons);
3296 EXPORT_SYMBOL(vc_cons);
3297 #ifndef VT_SINGLE_DRIVER
3298 EXPORT_SYMBOL(take_over_console);
3299 EXPORT_SYMBOL(give_up_console);