Skip to contentSkip to conversation

tty: bfin_jtag_comm: emulate a TTY over the Blackfin EMUDAT/JTAG interface

PATCH Superseded Mike Frysinger 4 participants 5 messages Jun 2, 2009 – Jun 3, 2009 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: bfin_jtag_comm: emulate a TTY over the Blackfin EMUDAT/JTAG interface

The Blackfin JTAG interface has a 4 byte generic data field (EMUDAT). With a little creative thinking, we can turn this into a TTY device.

---
 drivers/char/Kconfig          |   13 ++
 drivers/char/Makefile         |    1 +
 drivers/char/bfin_jtag_comm.c |  365 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 379 insertions(+), 0 deletions(-)
 create mode 100644 drivers/char/bfin_jtag_comm.c
drivers/char/Kconfig +13 -0
index 735bbe2..02ecfd5 100644
@@ -97,6 +97,19 @@ config DEVKMEM
 	  kind of kernel debugging operations.
 	  When in doubt, say "N".
 
+config BFIN_JTAG_COMM
+	tristate "Blackfin JTAG Communication"
+	depends on BLACKFIN
+	help
+	  Add support for emulating a TTY device over the Blackfin JTAG.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called bfin_jtag_comm.
+
+config BFIN_JTAG_COMM_CONSOLE
+	bool "Console on Blackfin JTAG"
+	depends on BFIN_JTAG_COMM=y
+
 config SERIAL_NONSTANDARD
 	bool "Non-standard serial port support"
 	depends on HAS_IOMEM
drivers/char/Makefile +1 -0
index 9caf5b5..189efcf 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_LEGACY_PTYS)	+= pty.o
 obj-$(CONFIG_UNIX98_PTYS)	+= pty.o
 obj-y				+= misc.o
 obj-$(CONFIG_VT)		+= vt_ioctl.o vc_screen.o selection.o keyboard.o
+obj-$(CONFIG_BFIN_JTAG_COMM)	+= bfin_jtag_comm.o
 obj-$(CONFIG_CONSOLE_TRANSLATIONS) += consolemap.o consolemap_deftbl.o
 obj-$(CONFIG_HW_CONSOLE)	+= vt.o defkeymap.o
 obj-$(CONFIG_AUDIT)		+= tty_audit.o
drivers/char/bfin_jtag_comm.c new file +365 -0

365 lines not on this page · raw message

Signature · 1 line
1.6.3.1
#1 lore raw

drivers/char/bfin_jtag_comm.c line 1

Quoted 7 lines · Mike Frysinger
drivers/char/bfin_jtag_comm.c new file +1 -0
new file mode 100644
index 0000000..854f265
@@ -0,0 +1,365 @@
+#define pr_init(fmt, args...) ({ static const __initdata char __fmt[] = fmt; printk(__fmt, ## args); })

This should be __initconst.

drivers/char/bfin_jtag_comm.c line 35

Quoted 1 line
drivers/char/bfin_jtag_comm.c new file +1 -0
+#define debug(fmt, args...) pr_debug(DRV_NAME ": " fmt, ## args)

Just define pr_fmt, instead of yet another debug macro.

drivers/char/bfin_jtag_comm.c line 225

Quoted 9 lines
drivers/char/bfin_jtag_comm.c new file +9 -0
+static void
+bfin_jc_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+	unsigned long expire = jiffies + timeout;
+	while (!circ_empty(&bfin_jc_write_buf)) {
+		if (signal_pending(current))
+			break;
+		if (time_after(jiffies, expire))
+			break;

Maybe some sort of sleep here?

drivers/char/bfin_jtag_comm.c line 13

Quoted 2 lines
drivers/char/bfin_jtag_comm.c new file +2 -0
+	}
+}

The tty handling is weird. You should take a reference before accessing the structure.

#2 lore raw

2009/6/2 Jiri Slaby <[email protected]>:

Quoted 10 lines · Mike Frysinger

drivers/char/bfin_jtag_comm.c line 1

Quoted 7 lines
drivers/char/bfin_jtag_comm.c new file +1 -0
new file mode 100644
index 0000000..854f265
@@ -0,0 +1,365 @@
+#define pr_init(fmt, args...) ({ static const __initdata char __fmt[] = fmt; printk(__fmt, ## args); })

This should be __initconst.

looks like my earlier scan missed this driver, thanks

Quoted 3 lines

drivers/char/bfin_jtag_comm.c line 35

Quoted 1 line
drivers/char/bfin_jtag_comm.c new file +1 -0
+#define debug(fmt, args...) pr_debug(DRV_NAME ": " fmt, ## args)

Just define pr_fmt, instead of yet another debug macro.

i missed the new pr_fmt() macro addition

Quoted 11 lines

drivers/char/bfin_jtag_comm.c line 225

Quoted 9 lines
drivers/char/bfin_jtag_comm.c new file +9 -0
+static void
+bfin_jc_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+     unsigned long expire = jiffies + timeout;
+     while (!circ_empty(&bfin_jc_write_buf)) {
+             if (signal_pending(current))
+                     break;
+             if (time_after(jiffies, expire))
+                     break;

Maybe some sort of sleep here?

i could add a schedule() call. the process has to stay running though because there is no async notification in the hardware that would be able to wake this guy up.

Quoted 5 lines

drivers/char/bfin_jtag_comm.c line 13

Quoted 2 lines
drivers/char/bfin_jtag_comm.c new file +2 -0
+     }
+}

The tty handling is weird. You should take a reference before accessing the structure.

tty documentation is non-existent. what reference exactly do you mean ? tty_driver_kref_get() and tty_driver_kref_put() ? no other tty driver uses that.

the tty handling is weird because of the hardware. we have to create a dedicated thread that constantly polls the hardware and this is all async to userspace accessing the tty.
-mike

#3 lore raw
In reply to Mike Frysinger
Quoted 2 lines · On Tue, 2 Jun 2009 15:25:34 -0400 Mike Frysinger <[email protected]> wrote:

The Blackfin JTAG interface has a 4 byte generic data field (EMUDAT). With a little creative thinking, we can turn this into a TTY device.

Nifty - queued

#4 lore raw

PATCH v2 1/1 tty: bfin_jtag_comm: emulate a TTY over the Blackfin EMUDAT/JTAG interface

The Blackfin JTAG interface has a 4 byte generic data field (EMUDAT). With a little creative thinking, we can turn this into a TTY device.

---
v2
- tweak printk helpers based on Jiri's feedback

 drivers/char/Kconfig          |   13 ++
 drivers/char/Makefile         |    1 +
 drivers/char/bfin_jtag_comm.c |  365 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 379 insertions(+), 0 deletions(-)
 create mode 100644 drivers/char/bfin_jtag_comm.c
drivers/char/Kconfig +13 -0
index 735bbe2..02ecfd5 100644
@@ -97,6 +97,19 @@ config DEVKMEM
 	  kind of kernel debugging operations.
 	  When in doubt, say "N".
 
+config BFIN_JTAG_COMM
+	tristate "Blackfin JTAG Communication"
+	depends on BLACKFIN
+	help
+	  Add support for emulating a TTY device over the Blackfin JTAG.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called bfin_jtag_comm.
+
+config BFIN_JTAG_COMM_CONSOLE
+	bool "Console on Blackfin JTAG"
+	depends on BFIN_JTAG_COMM=y
+
 config SERIAL_NONSTANDARD
 	bool "Non-standard serial port support"
 	depends on HAS_IOMEM
drivers/char/Makefile +1 -0
index 9caf5b5..189efcf 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_LEGACY_PTYS)	+= pty.o
 obj-$(CONFIG_UNIX98_PTYS)	+= pty.o
 obj-y				+= misc.o
 obj-$(CONFIG_VT)		+= vt_ioctl.o vc_screen.o selection.o keyboard.o
+obj-$(CONFIG_BFIN_JTAG_COMM)	+= bfin_jtag_comm.o
 obj-$(CONFIG_CONSOLE_TRANSLATIONS) += consolemap.o consolemap_deftbl.o
 obj-$(CONFIG_HW_CONSOLE)	+= vt.o defkeymap.o
 obj-$(CONFIG_AUDIT)		+= tty_audit.o
drivers/char/bfin_jtag_comm.c new file +365 -0

365 lines not on this page · raw message

Signature · 1 line
1.6.3.1