14 #include <linux/kernel.h>
15 #include <linux/ctype.h>
18 #include <linux/tty.h>
21 #include <linux/input.h>
22 #include <linux/module.h>
24 #define MAX_CONFIG_LEN 40
26 static struct kgdb_io kgdboc_io_ops;
37 static int kgdboc_use_kms;
39 static int kgdb_tty_line;
41 #ifdef CONFIG_KDB_KEYBOARD
42 static int kgdboc_reset_connect(
struct input_handler *handler,
43 struct input_dev *
dev,
46 input_reset_device(dev);
52 static void kgdboc_reset_disconnect(
struct input_handle *
handle)
66 static struct input_handler kgdboc_reset_handler = {
67 .connect = kgdboc_reset_connect,
68 .disconnect = kgdboc_reset_disconnect,
69 .name =
"kgdboc_reset",
70 .id_table = kgdboc_reset_ids,
84 if (input_register_handler(&kgdboc_reset_handler) == 0)
85 input_unregister_handler(&kgdboc_reset_handler);
90 static DECLARE_WORK(kgdboc_restore_input_work, kgdboc_restore_input_helper);
100 if (
strncmp(*cptr,
"kbd", 3) == 0 ||
101 strncmp(*cptr,
"kdb", 3) == 0) {
105 if (cptr[0][3] ==
',')
129 #define kgdboc_register_kbd(x) 0
130 #define kgdboc_unregister_kbd()
131 #define kgdboc_restore_input()
134 static int kgdboc_option_setup(
char *
opt)
145 __setup(
"kgdboc=", kgdboc_option_setup);
147 static void cleanup_kgdboc(
void)
156 static int configure_kgdboc(
void)
164 err = kgdboc_option_setup(
config);
169 kgdboc_io_ops.is_console = 0;
170 kgdb_tty_driver =
NULL;
173 if (
strncmp(cptr,
"kms,", 4) == 0) {
190 kgdboc_io_ops.is_console = 1;
197 kgdb_tty_line = tty_line;
223 static int __init init_kgdboc(
void)
229 return configure_kgdboc();
232 static int kgdboc_get_char(
void)
234 if (!kgdb_tty_driver)
236 return kgdb_tty_driver->
ops->poll_get_char(kgdb_tty_driver,
240 static void kgdboc_put_char(
u8 chr)
242 if (!kgdb_tty_driver)
244 kgdb_tty_driver->
ops->poll_put_char(kgdb_tty_driver,
248 static int param_set_kgdboc_var(
const char *kmessage,
struct kernel_param *kp)
265 "kgdboc: Cannot reconfigure while KGDB is connected.\n");
272 if (
config[len - 1] ==
'\n')
279 return configure_kgdboc();
282 static int dbg_restore_graphics;
284 static void kgdboc_pre_exp_handler(
void)
286 if (!dbg_restore_graphics && kgdboc_use_kms) {
287 dbg_restore_graphics = 1;
295 static void kgdboc_post_exp_handler(
void)
300 if (kgdboc_use_kms && dbg_restore_graphics) {
301 dbg_restore_graphics = 0;
307 static struct kgdb_io kgdboc_io_ops = {
309 .read_char = kgdboc_get_char,
310 .write_char = kgdboc_put_char,
311 .pre_exception = kgdboc_pre_exp_handler,
312 .post_exception = kgdboc_post_exp_handler,
315 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
317 static int __init kgdboc_early_init(
char *
opt)
324 kgdboc_option_setup(opt);