From: sonic zhang <sonic.adi@gmail.com>
To: Jason Wessel <jason.wessel@windriver.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
Linux Kernel <linux-kernel@vger.kernel.org>,
kgdb mailing list <kgdb-bugreport@lists.sourceforge.net>
Subject: [PATCH] [kgdb] Start kgdboc uart port to answer gdb break signal Ctrl+C without openning ttys.
Date: Wed, 17 Sep 2008 16:28:39 +0800 [thread overview]
Message-ID: <1221640119.15380.22.camel@eight.analog.com> (raw)
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.
Signed-off-by: Sonic Zhang <sonic.adi@gmail.com>
---
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(-)
diff --git a/drivers/serial/kgdboc.c b/drivers/serial/kgdboc.c
index eadc1ab..5d91f3d 100644
--- a/drivers/serial/kgdboc.c
+++ b/drivers/serial/kgdboc.c
@@ -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)
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 73e9b8f..07f1b04 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -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,
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 3b2f6c0..4a15311 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -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 *);
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 16d2794..efd26cf 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -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
next reply other threads:[~2008-09-17 8:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-17 8:28 sonic zhang [this message]
[not found] ` <4e5ebad50809190251p53b9e586x7f78dbc8f1c1b867@mail.gmail.com>
[not found] ` <48D38C63.4010608@windriver.com>
2008-09-22 3:39 ` Sonic Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1221640119.15380.22.camel@eight.analog.com \
--to=sonic.adi@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®