Start kgdboc uart port to answer gdb break signal Ctrl+C without openning ttys.
PATCH 1/1 Start kgdboc uart port to answer gdb break signal Ctrl+C without openning ttys.
Current kgdboc only configures the uart port in poll mode, which block any gdb break signal Ctrl+C from taking effect till a tty on the port is opened by an application. This patch introduces 2 hook functions in struct tty_operations and uart_operations. The kgdboc port can be start up without openning ttys after gdb is connected.
--- drivers/serial/kgdboc.c | 8 +++++++- drivers/serial/serial_core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 9 +++++++++ include/linux/tty_driver.h | 5 +++++ 4 files changed, 59 insertions(+), 1 deletions(-)
drivers/serial/kgdboc.c +7 -1
@@ -70,6 +70,9 @@ static int configure_kgdboc(void) configured =1 ; + kgdb_tty_driver->ops->kgdboc_port_startup (kgdb_tty_driver, + kgdb_tty_line); +return 0 ; noconfig:
@@ -90,8 +93,11 @@ static int __init init_kgdboc(void)static void cleanup_kgdboc (void ) { -if (configured ==1 ) +if (configured ==1 ) { + kgdb_tty_driver->ops->kgdboc_port_shutdown (kgdb_tty_driver, + kgdb_tty_line);kgdb_unregister_io_module (&kgdboc_io_ops); + } }static int kgdboc_get_char (void )
drivers/serial/serial_core.c +38 -0
@@ -2244,6 +2244,39 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, } } +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) +static int uart_kgdboc_port_startup (struct tty_driver *driver,int line) +{ +struct uart_driver *drv = driver->driver_state; +struct uart_state *state = drv->state + line; +struct uart_port *port; + +if (!state || !state->port) +return -1 ; + + port = state->port; +if (port->ops->kgdboc_port_startup) +return port->ops->kgdboc_port_startup (port); +else +return -1 ; +} + +static void uart_kgdboc_port_shutdown (struct tty_driver *driver,int line) +{ +struct uart_driver *drv = driver->driver_state; +struct uart_state *state = drv->state + line; +struct uart_port *port; + +if (!state || !state->port) +return ; + + port = state->port; +if (port->ops->kgdboc_port_shutdown) + port->ops->kgdboc_port_shutdown (port); +} +#endif +#ifdef CONFIG_CONSOLE_POLL static int uart_poll_init (struct tty_driver *driver,int line,char *options)
@@ -2323,6 +2356,11 @@ static const struct tty_operations uart_ops = {#endif .tiocmget = uart_tiocmget, .tiocmset = uart_tiocmset, +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) + .kgdboc_port_startup = uart_kgdboc_port_startup, + .kgdboc_port_shutdown = uart_kgdboc_port_shutdown, +#endif #ifdef CONFIG_CONSOLE_POLL .poll_init = uart_poll_init, .poll_get_char = uart_poll_get_char,
include/linux/serial_core.h +9 -0
@@ -214,6 +214,15 @@ struct uart_ops {void (*config_port)(struct uart_port *,int );int (*verify_port)(struct uart_port *,struct serial_struct *);int (*ioctl)(struct uart_port *,unsigned int ,unsigned long ); +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) +/* +* Start up serial port earlier in kgdboc to support gdb break +* signal Ctrl+C. +*/ +int (*kgdboc_port_startup)(struct uart_port *); +void (*kgdboc_port_shutdown)(struct uart_port *); +#endif #ifdef CONFIG_CONSOLE_POLL void (*poll_put_char)(struct uart_port *,unsigned char );int (*poll_get_char)(struct uart_port *);
include/linux/tty_driver.h +5 -0
@@ -220,6 +220,11 @@ struct tty_operations { unsigned int set, unsigned int clear);int (*resize)(struct tty_struct *tty,struct tty_struct *real_tty,struct winsize *ws); +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) +int (*kgdboc_port_startup)(struct tty_driver *driver,int line); +int (*kgdboc_port_shutdown)(struct tty_driver *driver,int line); +#endif #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver,int line,char *options);int (*poll_get_char)(struct tty_driver *driver,int line);
Signature · 1 line
1.6.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Yes, I am doing the same thing to deal with Ctrl+C as you expected. If you have already got a solution, that's great. Please send out your patch and I can implement UART specific code in bf5xx_serial driver accordingly.
Sonic
Quoted 177 lines · Jason Wessel
I had been out for part of this week, and I started to look at your patches yesterday and will complete it some time today :-)
The "control-c" without opening a tty is one I have a direct conflict with in that I have a completely different implementation of this that does the same thing. In this other implementation (which I'll probably post publicly in response to this patch) there is a
rx_pollhook for kgdboc to allow it to intercept and correctly process the control-c.How were you dealing with the control-c? I assume it had to be in a similar sort of manner, because there two issues.
1) hook up the irq with the low level uart start
2) Issue a break on the control-cCertainly I would like to consolidate the implementations, which is why the review of the patch was not trivial.
Thanks,
Jason.Quoted 153 lines · Sonic Zhang
Hi Jason,
Any comments?
Sonic Zhang
Quoted 144 lines · sonic zhang
Current kgdboc only configures the uart port in poll mode, which block any gdb break signal Ctrl+C from taking effect till a tty on the port is opened by an application. This patch introduces 2 hook functions in struct
tty_operationsanduart_operations. The kgdboc port can be start up without openning ttys after gdb is connected.Signed-off-by Sonic Zhang <[email protected]>--- drivers/serial/kgdboc.c | 8 +++++++- drivers/serial/serial_core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 9 +++++++++ include/linux/tty_driver.h | 5 +++++ 4 files changed, 59 insertions(+), 1 deletions(-)drivers/serial/kgdboc.c +7
-1@@ -70,6 +70,9 @@ static int configure_kgdboc(void) configured =1 ; + kgdb_tty_driver->ops->kgdboc_port_startup (kgdb_tty_driver, + kgdb_tty_line); +return 0 ; noconfig:@@ -90,8 +93,11 @@ static int __init init_kgdboc(void)static void cleanup_kgdboc (void ) { -if (configured ==1 ) +if (configured ==1 ) { + kgdb_tty_driver->ops->kgdboc_port_shutdown (kgdb_tty_driver, + kgdb_tty_line);kgdb_unregister_io_module (&kgdboc_io_ops); + } }static int kgdboc_get_char (void )drivers/serial/serial_core.c +38
-0@@ -2244,6 +2244,39 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, } } +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) +static int uart_kgdboc_port_startup (struct tty_driver *driver,int line) +{ +struct uart_driver *drv = driver->driver_state; +struct uart_state *state = drv->state + line; +struct uart_port *port; + +if (!state || !state->port) +return -1 ; + + port = state->port; +if (port->ops->kgdboc_port_startup) +return port->ops->kgdboc_port_startup (port); +else +return -1 ; +} + +static void uart_kgdboc_port_shutdown (struct tty_driver *driver,int line) +{ +struct uart_driver *drv = driver->driver_state; +struct uart_state *state = drv->state + line; +struct uart_port *port; + +if (!state || !state->port) +return ; + + port = state->port; +if (port->ops->kgdboc_port_shutdown) + port->ops->kgdboc_port_shutdown (port); +} +#endif +#ifdef CONFIG_CONSOLE_POLL static int uart_poll_init (struct tty_driver *driver,int line,char *options)@@ -2323,6 +2356,11 @@ static const struct tty_operations uart_ops = {#endif .tiocmget = uart_tiocmget, .tiocmset = uart_tiocmset, +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) + .kgdboc_port_startup = uart_kgdboc_port_startup, + .kgdboc_port_shutdown = uart_kgdboc_port_shutdown, +#endif #ifdef CONFIG_CONSOLE_POLL .poll_init = uart_poll_init, .poll_get_char = uart_poll_get_char,include/linux/serial_core.h +9
-0@@ -214,6 +214,15 @@ struct uart_ops {void (*config_port)(struct uart_port *,int );int (*verify_port)(struct uart_port *,struct serial_struct *);int (*ioctl)(struct uart_port *,unsigned int ,unsigned long ); +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) +/* +* Start up serial port earlier in kgdboc to support gdb break +* signal Ctrl+C. +*/ +int (*kgdboc_port_startup)(struct uart_port *); +void (*kgdboc_port_shutdown)(struct uart_port *); +#endif #ifdef CONFIG_CONSOLE_POLL void (*poll_put_char)(struct uart_port *,unsigned char );int (*poll_get_char)(struct uart_port *);include/linux/tty_driver.h +5
-1@@ -220,6 +220,11 @@ struct tty_operations { unsigned int set, unsigned int clear);int (*resize)(struct tty_struct *tty,struct tty_struct *real_tty,struct winsize *ws); +#if defined(CONFIG_KGDB_SERIAL_CONSOLE ) || \ + defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE ) +int (*kgdboc_port_startup)(struct tty_driver *driver,int line); +int (*kgdboc_port_shutdown)(struct tty_driver *driver,int line); +#endif #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver,int line,char *options);int (*poll_get_char)(struct tty_driver *driver,int line); --1.6.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/