History

kgdboc,kdb: Allow kdb to work on a non open console port

If kdb is open on a serial port that is not actually a console make sure to call the poll routines to emit and receive characters.

Jason Wessel committed 16 years ago

Commit efe2f291 parent 1cee5e33 files · +33 −0Browse files

Unified · Split

3 files
  1. drivers/serial/kgdboc.c +14 −0
  2. include/linux/kgdb.h +3 −0
  3. kernel/debug/kdb/kdb_io.c +16 −0
drivers/serial/kgdboc.c+14−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/kgdb.h>
1717 #include <linux/kdb.h>
1818 #include <linux/tty.h>
19+#include <linux/console.h>
1920
2021 #define MAX_CONFIG_LEN 40
2122
@@ -93,12 +94,14 @@ static int configure_kgdboc(void) · 71 unmodified lines
9394 int tty_line = 0;
9495 int err;
9596 char *cptr = config;
97+ struct console *cons;
9698
9799 err = kgdboc_option_setup(config);
98100 if (err || !strlen(config) || isspace(config[0]))
99101 goto noconfig;
100102
101103 err = -ENODEV;
104+ kgdboc_io_ops.is_console = 0;
102105 kgdb_tty_driver = NULL;
103106
104107 if (kgdboc_register_kbd(&cptr))
@@ -108,6 +111,17 @@ static int configure_kgdboc(void) · 3 unmodified lines
108111 if (!p)
109112 goto noconfig;
110113
114+ cons = console_drivers;
115+ while (cons) {
116+ int idx;
117+ if (cons->device && cons->device(cons, &idx) == p &&
118+ idx == tty_line) {
119+ kgdboc_io_ops.is_console = 1;
120+ break;
121+ }
122+ cons = cons->next;
123+ }
124+
111125 kgdb_tty_driver = p;
112126 kgdb_tty_line = tty_line;
113127
include/linux/kgdb.h+3−0
@@ -247,6 +247,8 @@ struct kgdb_arch { · 246 unmodified lines
247247 * the I/O driver.
248248 * @post_exception: Pointer to a function that will do any cleanup work
249249 * for the I/O driver.
250+ * @is_console: 1 if the end device is a console 0 if the I/O device is
251+ * not a console
250252 */
251253 struct kgdb_io {
252254 const char *name;
@@ -256,6 +258,7 @@ struct kgdb_io { · 3 unmodified lines
256258 int (*init) (void);
257259 void (*pre_exception) (void);
258260 void (*post_exception) (void);
261+ int is_console;
259262 };
260263
261264 extern struct kgdb_arch arch_kgdb_ops;
kernel/debug/kdb/kdb_io.c+16−0
@@ -673,6 +673,14 @@ kdb_printit: · 672 unmodified lines
673673 if (!dbg_kdb_mode && kgdb_connected) {
674674 gdbstub_msg_write(kdb_buffer, retlen);
675675 } else {
676+ if (!dbg_io_ops->is_console) {
677+ len = strlen(kdb_buffer);
678+ cp = kdb_buffer;
679+ while (len--) {
680+ dbg_io_ops->write_char(*cp);
681+ cp++;
682+ }
683+ }
676684 while (c) {
677685 c->write(c, kdb_buffer, retlen);
678686 touch_nmi_watchdog();
@@ -719,6 +727,14 @@ kdb_printit: · 40 unmodified lines
719727 kdb_input_flush();
720728 c = console_drivers;
721729
730+ if (!dbg_io_ops->is_console) {
731+ len = strlen(moreprompt);
732+ cp = moreprompt;
733+ while (len--) {
734+ dbg_io_ops->write_char(*cp);
735+ cp++;
736+ }
737+ }
722738 while (c) {
723739 c->write(c, moreprompt, strlen(moreprompt));
724740 touch_nmi_watchdog();