summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2010-03-03 15:35:57 -0600
committerJason Wessel <jason.wessel@windriver.com>2010-03-03 15:35:57 -0600
commitf037983f9f7e50cc4ef13a1c565cbfa48c311a65 (patch)
treef18006a704431e75bc0d227e31c1b9c7f1757f2d /kernel
parenta628366fc0c1faea44aba267e8ea63ff2bc74b93 (diff)
kms,kdb: Force unblank a console device
The kgdboc pre exception handler must atomically save the state of the existing VT console and activate it, if it is blanked. Before restoring the kernel to a running state, the kgdboc post exception handler will restore the state of the VT variables that got changed while atomic. CC: David Airlie <airlied@linux.ie> Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/debug/Makefile1
-rw-r--r--kernel/debug/kms_hooks.c62
2 files changed, 63 insertions, 0 deletions
diff --git a/kernel/debug/Makefile b/kernel/debug/Makefile
index c72de0039fdc..fe342c07b154 100644
--- a/kernel/debug/Makefile
+++ b/kernel/debug/Makefile
@@ -3,5 +3,6 @@
#
obj-$(CONFIG_KGDB) += debug_core.o gdbstub.o
+obj-$(CONFIG_VT) += kms_hooks.o
obj-$(CONFIG_KGDB_KDB) += kdb/
diff --git a/kernel/debug/kms_hooks.c b/kernel/debug/kms_hooks.c
new file mode 100644
index 000000000000..c56b7ce28989
--- /dev/null
+++ b/kernel/debug/kms_hooks.c
@@ -0,0 +1,62 @@
+/*
+ * Created by: Jason Wessel <jason.wessel@windriver.com>
+ *
+ * Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifdef CONFIG_VT
+#include <linux/kgdb.h>
+#include <linux/console.h>
+#include <linux/vt_kern.h>
+#include <linux/selection.h>
+#include <linux/kdb.h>
+#include "kdb/kdb_private.h"
+
+static int dbg_orig_vc_mode;
+static int saved_fg_con;
+static int saved_last_con;
+static int saved_want_con;
+
+void dbg_pre_vt_hook(void)
+{
+ struct vc_data *vc = vc_cons[fg_console].d;
+ saved_fg_con = fg_console;
+ saved_last_con = last_console;
+ saved_want_con = want_console;
+ dbg_orig_vc_mode = vc->vc_mode;
+ vc->vc_mode = KD_TEXT;
+ console_blanked = 0;
+ vc->vc_sw->con_blank(vc, 0, 1);
+ vc->vc_sw->con_set_palette(vc, color_table);
+#ifdef CONFIG_KGDB_KDB
+ /* Set the initial LINES variable if it is not already set */
+ if (vc->vc_rows < 999) {
+ int linecount;
+ char lns[4];
+ const char *setargs[3] = {
+ "set",
+ "LINES",
+ lns,
+ };
+ if (kdbgetintenv(setargs[0], &linecount)) {
+ snprintf(lns, 4, "%i", vc->vc_rows);
+ kdb_set(2, setargs);
+ }
+ }
+#endif /* CONFIG_KGDB_KDB */
+}
+EXPORT_SYMBOL_GPL(dbg_pre_vt_hook);
+
+void dbg_post_vt_hook(void)
+{
+ fg_console = saved_fg_con;
+ last_console = saved_last_con;
+ want_console = saved_want_con;
+ vc_cons[fg_console].d->vc_mode = dbg_orig_vc_mode;
+}
+EXPORT_SYMBOL_GPL(dbg_post_vt_hook);
+#endif /* CONFIG_VT */