linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: benh@kernel.crashing.org, jason.wessel@windriver.com
Cc: kgdb-bugreport@lists.sourceforge.net, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] hvc_console: Add kdb support
Date: Wed, 13 Jul 2011 15:44:05 +1000	[thread overview]
Message-ID: <20110713154405.297f828d@kryten> (raw)


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

Signed-off-by: Anton Blanchard <anton@samba.org>
---

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/

Index: linux-powerpc/drivers/tty/hvc/hvc_console.c
===================================================================
--- linux-powerpc.orig/drivers/tty/hvc/hvc_console.c	2011-07-13 15:08:15.853817380 +1000
+++ linux-powerpc/drivers/tty/hvc/hvc_console.c	2011-07-13 15:10:16.555874550 +1000
@@ -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_struc
 	return 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,

             reply	other threads:[~2011-07-13  5:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13  5:44 Anton Blanchard [this message]
2011-07-13 11:24 ` [PATCH] hvc_console: Add kdb support Josh Boyer
2011-07-13 13:05   ` Anton Blanchard

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=20110713154405.297f828d@kryten \
    --to=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).