hvc_console: Add kdb support
PATCH 1/1 hvc_console: Add kdb support
Add poll_get_char and poll_put_char for kdb. Enable kdb at boot with:
kgdboc=hvc0
or at runtime with:
echo hvc0 > /sys/module/kgdboc/parameters/kgdboc
---
A couple of things:
- I needed to enable CONFIG_KGDB_SERIAL_CONSOLE in order to enable CONFIG_CONSOLE_POLL. It's somewhat confusing and I wonder if we should always enable CONFIG_CONSOLE_POLL when CONFIG_KGDB is enabled.
- I had to pull in linux/serial_core.h to get NO_POLL_CHAR, we might want to move it somewhere more generic.
- Things are a little bit awkward because poll_get_char and poll_put_char take a struct tty_driver instead of a struct tty, I just grab the first entry in the ttys[] list.
FYI: This patch also needs "powerpc/pseries: Fix hvterm_raw_get_chars to accept < 16 chars, fixing xmon" to be applied:
http://patchwork.ozlabs.org/patch/104475/
drivers/tty/hvc/hvc_console.c +39 -0
@@ -39,6 +39,7 @@#include <linux/delay.h> #include <linux/freezer.h> #include <linux/slab.h> +#include <linux/serial_core.h> #include <asm/uaccess.h>
@@ -766,6 +767,39 @@ static int hvc_tiocmset(struct tty_strucreturn hp->ops->tiocmset (hp, set, clear); } +#ifdef CONFIG_CONSOLE_POLL +int hvc_poll_init (struct tty_driver *driver,int line,char *options) +{ +return 0 ; +} + +static int hvc_poll_get_char (struct tty_driver *driver,int line) +{ +struct tty_struct *tty = driver->ttys[0 ]; +struct hvc_struct *hp = tty->driver_data; +int n; +char ch; + + n = hp->ops->get_chars (hp->vtermno, &ch,1 ); + +if (n ==0 ) +return NO_POLL_CHAR ; + +return ch; +} + +static void hvc_poll_put_char (struct tty_driver *driver,int line,char ch) +{ +struct tty_struct *tty = driver->ttys[0 ]; +struct hvc_struct *hp = tty->driver_data; +int n; + +do { + n = hp->ops->put_chars (hp->vtermno, &ch,1 ); + }while (n <=0 ); +} +#endif +static const struct tty_operations hvc_ops = { .open = hvc_open, .close = hvc_close,
@@ -776,6 +810,11 @@ static const struct tty_operations hvc_o .chars_in_buffer = hvc_chars_in_buffer, .tiocmget = hvc_tiocmget, .tiocmset = hvc_tiocmset, +#ifdef CONFIG_CONSOLE_POLL + .poll_init = hvc_poll_init, + .poll_get_char = hvc_poll_get_char, + .poll_put_char = hvc_poll_put_char, +#endif }; struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
Quoted 2 lines · Anton Blanchard
Add
poll_get_charandpoll_put_charfor kdb. Enable kdb at boot with:
Did you mean "...for kgdb. Enable kgdb at boot.." ?
I thought kdb and kgdb shared some infrastructure now, but your patch and comments seem to be all about kgdb.
josh
Hi,
Quoted 7 lines
Quoted 2 lines
Add
poll_get_charandpoll_put_charfor kdb. Enable kdb at boot with:Did you mean "...for kgdb. Enable kgdb at boot.." ?
I thought kdb and kgdb shared some infrastructure now, but your patch and comments seem to be all about kgdb.
No I do mean kdb :) From the Documentation:
<para>The kgdboc driver was originally an abbreviation meant to stand for "kgdb over console". Today it is the primary mechanism to configure how to communicate from gdb to kgdb as well as the devices you want to use to interact with the kdb shell. </para>
I've only tested kdb so far.
Anton