aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/vt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/vt.c')
-rw-r--r--drivers/char/vt.c67
1 files changed, 53 insertions, 14 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 0c80c68cd047..bd1d1164fec5 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -161,6 +161,11 @@ static void set_palette(struct vc_data *vc);
161static int printable; /* Is console ready for printing? */ 161static int printable; /* Is console ready for printing? */
162int default_utf8 = true; 162int default_utf8 = true;
163module_param(default_utf8, int, S_IRUGO | S_IWUSR); 163module_param(default_utf8, int, S_IRUGO | S_IWUSR);
164int global_cursor_default = -1;
165module_param(global_cursor_default, int, S_IRUGO | S_IWUSR);
166
167static int cur_default = CUR_DEFAULT;
168module_param(cur_default, int, S_IRUGO | S_IWUSR);
164 169
165/* 170/*
166 * ignore_poke: don't unblank the screen when things are typed. This is 171 * ignore_poke: don't unblank the screen when things are typed. This is
@@ -182,12 +187,10 @@ static DECLARE_WORK(console_work, console_callback);
182 * fg_console is the current virtual console, 187 * fg_console is the current virtual console,
183 * last_console is the last used one, 188 * last_console is the last used one,
184 * want_console is the console we want to switch to, 189 * want_console is the console we want to switch to,
185 * kmsg_redirect is the console for kernel messages,
186 */ 190 */
187int fg_console; 191int fg_console;
188int last_console; 192int last_console;
189int want_console = -1; 193int want_console = -1;
190int kmsg_redirect;
191 194
192/* 195/*
193 * For each existing display, we have a pointer to console currently visible 196 * For each existing display, we have a pointer to console currently visible
@@ -775,6 +778,12 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
775 vc_cons[currcons].d = NULL; 778 vc_cons[currcons].d = NULL;
776 return -ENOMEM; 779 return -ENOMEM;
777 } 780 }
781
782 /* If no drivers have overridden us and the user didn't pass a
783 boot option, default to displaying the cursor */
784 if (global_cursor_default == -1)
785 global_cursor_default = 1;
786
778 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); 787 vc_init(vc, vc->vc_rows, vc->vc_cols, 1);
779 vcs_make_sysfs(currcons); 788 vcs_make_sysfs(currcons);
780 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param); 789 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param);
@@ -812,7 +821,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
812 * 821 *
813 * Resize a virtual console, clipping according to the actual constraints. 822 * Resize a virtual console, clipping according to the actual constraints.
814 * If the caller passes a tty structure then update the termios winsize 823 * If the caller passes a tty structure then update the termios winsize
815 * information and perform any neccessary signal handling. 824 * information and perform any necessary signal handling.
816 * 825 *
817 * Caller must hold the console semaphore. Takes the termios mutex and 826 * Caller must hold the console semaphore. Takes the termios mutex and
818 * ctrl_lock of the tty IFF a tty is passed. 827 * ctrl_lock of the tty IFF a tty is passed.
@@ -1616,7 +1625,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
1616 vc->vc_decscnm = 0; 1625 vc->vc_decscnm = 0;
1617 vc->vc_decom = 0; 1626 vc->vc_decom = 0;
1618 vc->vc_decawm = 1; 1627 vc->vc_decawm = 1;
1619 vc->vc_deccm = 1; 1628 vc->vc_deccm = global_cursor_default;
1620 vc->vc_decim = 0; 1629 vc->vc_decim = 0;
1621 1630
1622 set_kbd(vc, decarm); 1631 set_kbd(vc, decarm);
@@ -1630,7 +1639,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
1630 /* do not do set_leds here because this causes an endless tasklet loop 1639 /* do not do set_leds here because this causes an endless tasklet loop
1631 when the keyboard hasn't been initialized yet */ 1640 when the keyboard hasn't been initialized yet */
1632 1641
1633 vc->vc_cursor_type = CUR_DEFAULT; 1642 vc->vc_cursor_type = cur_default;
1634 vc->vc_complement_mask = vc->vc_s_complement_mask; 1643 vc->vc_complement_mask = vc->vc_s_complement_mask;
1635 1644
1636 default_attr(vc); 1645 default_attr(vc);
@@ -1832,7 +1841,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
1832 if (vc->vc_par[0]) 1841 if (vc->vc_par[0])
1833 vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16); 1842 vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16);
1834 else 1843 else
1835 vc->vc_cursor_type = CUR_DEFAULT; 1844 vc->vc_cursor_type = cur_default;
1836 return; 1845 return;
1837 } 1846 }
1838 break; 1847 break;
@@ -2110,8 +2119,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2110 uint8_t inverse; 2119 uint8_t inverse;
2111 uint8_t width; 2120 uint8_t width;
2112 u16 himask, charmask; 2121 u16 himask, charmask;
2113 const unsigned char *orig_buf = NULL;
2114 int orig_count;
2115 2122
2116 if (in_interrupt()) 2123 if (in_interrupt())
2117 return count; 2124 return count;
@@ -2133,8 +2140,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2133 release_console_sem(); 2140 release_console_sem();
2134 return 0; 2141 return 0;
2135 } 2142 }
2136 orig_buf = buf;
2137 orig_count = count;
2138 2143
2139 himask = vc->vc_hi_font_mask; 2144 himask = vc->vc_hi_font_mask;
2140 charmask = himask ? 0x1ff : 0xff; 2145 charmask = himask ? 0x1ff : 0xff;
@@ -2426,6 +2431,37 @@ struct tty_driver *console_driver;
2426 2431
2427#ifdef CONFIG_VT_CONSOLE 2432#ifdef CONFIG_VT_CONSOLE
2428 2433
2434/**
2435 * vt_kmsg_redirect() - Sets/gets the kernel message console
2436 * @new: The new virtual terminal number or -1 if the console should stay
2437 * unchanged
2438 *
2439 * By default, the kernel messages are always printed on the current virtual
2440 * console. However, the user may modify that default with the
2441 * TIOCL_SETKMSGREDIRECT ioctl call.
2442 *
2443 * This function sets the kernel message console to be @new. It returns the old
2444 * virtual console number. The virtual terminal number 0 (both as parameter and
2445 * return value) means no redirection (i.e. always printed on the currently
2446 * active console).
2447 *
2448 * The parameter -1 means that only the current console is returned, but the
2449 * value is not modified. You may use the macro vt_get_kmsg_redirect() in that
2450 * case to make the code more understandable.
2451 *
2452 * When the kernel is compiled without CONFIG_VT_CONSOLE, this function ignores
2453 * the parameter and always returns 0.
2454 */
2455int vt_kmsg_redirect(int new)
2456{
2457 static int kmsg_con;
2458
2459 if (new != -1)
2460 return xchg(&kmsg_con, new);
2461 else
2462 return kmsg_con;
2463}
2464
2429/* 2465/*
2430 * Console on virtual terminal 2466 * Console on virtual terminal
2431 * 2467 *
@@ -2440,6 +2476,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
2440 const ushort *start; 2476 const ushort *start;
2441 ushort cnt = 0; 2477 ushort cnt = 0;
2442 ushort myx; 2478 ushort myx;
2479 int kmsg_console;
2443 2480
2444 /* console busy or not yet initialized */ 2481 /* console busy or not yet initialized */
2445 if (!printable) 2482 if (!printable)
@@ -2447,8 +2484,9 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
2447 if (!spin_trylock(&printing_lock)) 2484 if (!spin_trylock(&printing_lock))
2448 return; 2485 return;
2449 2486
2450 if (kmsg_redirect && vc_cons_allocated(kmsg_redirect - 1)) 2487 kmsg_console = vt_get_kmsg_redirect();
2451 vc = vc_cons[kmsg_redirect - 1].d; 2488 if (kmsg_console && vc_cons_allocated(kmsg_console - 1))
2489 vc = vc_cons[kmsg_console - 1].d;
2452 2490
2453 /* read `x' only after setting currcons properly (otherwise 2491 /* read `x' only after setting currcons properly (otherwise
2454 the `x' macro will read the x of the foreground console). */ 2492 the `x' macro will read the x of the foreground console). */
@@ -2605,7 +2643,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2605 ret = set_vesa_blanking(p); 2643 ret = set_vesa_blanking(p);
2606 break; 2644 break;
2607 case TIOCL_GETKMSGREDIRECT: 2645 case TIOCL_GETKMSGREDIRECT:
2608 data = kmsg_redirect; 2646 data = vt_get_kmsg_redirect();
2609 ret = __put_user(data, p); 2647 ret = __put_user(data, p);
2610 break; 2648 break;
2611 case TIOCL_SETKMSGREDIRECT: 2649 case TIOCL_SETKMSGREDIRECT:
@@ -2615,7 +2653,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2615 if (get_user(data, p+1)) 2653 if (get_user(data, p+1))
2616 ret = -EFAULT; 2654 ret = -EFAULT;
2617 else 2655 else
2618 kmsg_redirect = data; 2656 vt_kmsg_redirect(data);
2619 } 2657 }
2620 break; 2658 break;
2621 case TIOCL_GETFGCONSOLE: 2659 case TIOCL_GETFGCONSOLE:
@@ -4078,6 +4116,7 @@ EXPORT_SYMBOL(fg_console);
4078EXPORT_SYMBOL(console_blank_hook); 4116EXPORT_SYMBOL(console_blank_hook);
4079EXPORT_SYMBOL(console_blanked); 4117EXPORT_SYMBOL(console_blanked);
4080EXPORT_SYMBOL(vc_cons); 4118EXPORT_SYMBOL(vc_cons);
4119EXPORT_SYMBOL(global_cursor_default);
4081#ifndef VT_SINGLE_DRIVER 4120#ifndef VT_SINGLE_DRIVER
4082EXPORT_SYMBOL(take_over_console); 4121EXPORT_SYMBOL(take_over_console);
4083EXPORT_SYMBOL(give_up_console); 4122EXPORT_SYMBOL(give_up_console);