From: Mark Salter <msalter@redhat.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 04/16] add support for C64x+ debugger based console
Date: Wed, 11 May 2011 16:13:51 -0400 [thread overview]
Message-ID: <1305144843-5058-5-git-send-email-msalter@redhat.com> (raw)
In-Reply-To: <1305144843-5058-4-git-send-email-msalter@redhat.com>
Texas Instruments debugger support for the C64X+ family of DSPs includes a
console for the unit under test. This patch adds write-only console support
to send kernel output to the debugger. It is safe to have this driver in
place even if the system is not being run under the debugger.
Signed-off-by: Mark Salter <msalter@redhat.com>
---
drivers/tty/hvc/Makefile | 1 +
drivers/tty/hvc/hvc_c6x.c | 125 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 126 insertions(+), 0 deletions(-)
create mode 100644 drivers/tty/hvc/hvc_c6x.c
diff --git a/drivers/tty/hvc/Makefile b/drivers/tty/hvc/Makefile
index 40a25d9..02e08cb 100644
--- a/drivers/tty/hvc/Makefile
+++ b/drivers/tty/hvc/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o
obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o
obj-$(CONFIG_HVC_BFIN_JTAG) += hvc_bfin_jtag.o
obj-$(CONFIG_HVCS) += hvcs.o
+obj-$(CONFIG_HVC_C6X) += hvc_c6x.o
diff --git a/drivers/tty/hvc/hvc_c6x.c b/drivers/tty/hvc/hvc_c6x.c
new file mode 100644
index 0000000..54ea20b
--- /dev/null
+++ b/drivers/tty/hvc/hvc_c6x.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2011 Texas Instruments Incorporated
+ * Author: Mark Salter <msalter@redhat.com>
+ *
+ * Based on hvc_tile.c
+ * Copyright 2010 Tilera Corporation. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+/*
+ * TI C6X Host Port hypervisor console
+ */
+
+#include <linux/console.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/moduleparam.h>
+#include <linux/types.h>
+
+#include "hvc_console.h"
+
+#define PARAMSIZE 8
+#define MSGSIZE 256
+
+#define CIO_READ 0xF2
+#define CIO_WRITE 0xF3
+
+#define CIO_STDIN 0
+#define CIO_STDOUT 1
+#define CIO_STDERR 2
+
+struct c6x_msg {
+ unsigned int length;
+ unsigned char command;
+ unsigned char params[PARAMSIZE];
+ unsigned char msg[MSGSIZE];
+};
+
+union c6x_msgparam {
+ unsigned char params[PARAMSIZE];
+ struct {
+ unsigned short fd;
+ unsigned short count;
+ } host_write;
+};
+
+/*
+ * __CIOBUF__ and C$$IO$$ are special symbols for debugger.
+ *
+ * If debugger is running kernel, it will set a breakpoint
+ * at C$$IO$$ which is hit when the kernel wants attention
+ * from the debugger. __CIOBUF__ is used to pass messages
+ * between debugger and kernel when the breakpoint is hit.
+ */
+struct c6x_msg _CIOBUF_;
+
+static noinline void notify_debugger(void)
+{
+ asm volatile (".global C$$IO$$\n"
+ "nop\n"
+ "C$$IO$$: nop\n");
+}
+
+static int hvc_c6x_put_chars(uint32_t vt, const char *buf, int count)
+{
+ union c6x_msgparam params;
+ int to_write, remaining;
+
+ remaining = count;
+ while (remaining > 0) {
+ to_write = (remaining > MSGSIZE) ? MSGSIZE : remaining;
+
+ _CIOBUF_.length = to_write;
+ _CIOBUF_.command = CIO_WRITE;
+
+ params.host_write.fd = cpu_to_le16(CIO_STDOUT);
+ params.host_write.count = cpu_to_le16(to_write);
+ memcpy(_CIOBUF_.params, ¶ms, PARAMSIZE);
+
+ memcpy(_CIOBUF_.msg, buf, to_write);
+
+ notify_debugger();
+
+ remaining -= to_write;
+ }
+ return count;
+}
+
+#ifdef CONFIG_EARLY_PRINTK
+void hvc_c6x_early_puts(const char *buf, unsigned count)
+{
+ hvc_c6x_put_chars(0, buf, count);
+}
+#endif
+
+static int hvc_c6x_get_chars(uint32_t vt, char *buf, int count)
+{
+ return 0;
+}
+
+static const struct hv_ops hvc_c6x_get_put_ops = {
+ .get_chars = hvc_c6x_get_chars,
+ .put_chars = hvc_c6x_put_chars,
+};
+
+static int __init hvc_c6x_console_init(void)
+{
+ hvc_instantiate(0, 0, &hvc_c6x_get_put_ops);
+ add_preferred_console("hvc", 0, NULL);
+ return 0;
+}
+console_initcall(hvc_c6x_console_init);
+
+static int __init hvc_c6x_init(void)
+{
+ struct hvc_struct *s;
+ s = hvc_alloc(0, 0, &hvc_c6x_get_put_ops, 128);
+ return IS_ERR(s) ? PTR_ERR(s) : 0;
+}
+device_initcall(hvc_c6x_init);
--
1.6.2.5
next prev parent reply other threads:[~2011-05-11 21:10 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-11 20:13 [PATCH] arch/c6x: new architecture port for linux Mark Salter
2011-05-11 20:13 ` [PATCH 01/16] fix default __strnlen_user macro Mark Salter
2011-05-11 20:13 ` [PATCH 02/16] fixed generic page.h for non-zero PAGE_OFFSET Mark Salter
2011-05-11 20:13 ` [PATCH 03/16] add driver for C64x+ ethernet driver Mark Salter
2011-05-11 20:13 ` Mark Salter [this message]
2011-05-11 20:13 ` [PATCH 05/16] add ELF machine define for TI C6X DSPs Mark Salter
2011-05-11 20:13 ` [PATCH 06/16] add maintainers entry for C6X arch Mark Salter
2011-05-11 20:13 ` [PATCH 07/16] C6X: add toplevel configury and makefile Mark Salter
2011-05-11 20:13 ` [PATCH 08/16] C6X: add include files Mark Salter
2011-05-11 20:13 ` [PATCH 09/16] C6X: add kernel files Mark Salter
2011-05-11 20:13 ` [PATCH 10/16] C6X: add mm files Mark Salter
2011-05-11 20:13 ` [PATCH 11/16] C6X: add lib files Mark Salter
2011-05-11 20:13 ` [PATCH 12/16] C6X: add platform files Mark Salter
2011-05-11 20:14 ` [PATCH 13/16] C6X: add drivers/platform/c6x files Mark Salter
2011-05-11 20:14 ` [PATCH 14/16] C6X: add default configs Mark Salter
2011-05-11 20:14 ` [PATCH 15/16] Add new elf binfmt support for DSBT Mark Salter
2011-05-11 20:14 ` [PATCH 16/16] C6X: add support for DSBT binary format Mark Salter
2011-05-12 2:41 ` [04/16] add support for C64x+ debugger based console Milton Miller
2011-05-12 12:55 ` Mark Salter
2011-05-12 0:49 ` [PATCH 03/16] add driver for C64x+ ethernet driver Joe Perches
2011-05-13 15:30 ` Ben Hutchings
2011-05-13 13:55 ` [PATCH 01/16] fix default __strnlen_user macro Pavel Machek
2011-05-13 14:40 ` Mark Salter
2011-05-11 20:13 ` [PATCH] arch/c6x: new architecture port for linux Milton Miller
2011-05-12 12:34 ` Mark Salter
2011-05-11 21:34 ` Randy Dunlap
2011-05-12 0:57 ` Mark Salter
2011-05-12 1:07 ` Randy Dunlap
2011-05-12 1:16 ` Mark Salter
2011-05-21 17:10 ` Arnd Bergmann
2011-05-21 17:46 ` Geert Uytterhoeven
2011-06-16 12:54 ` Mark Salter
2011-06-16 14:02 ` Arnd Bergmann
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=1305144843-5058-5-git-send-email-msalter@redhat.com \
--to=msalter@redhat.com \
--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