* [PATCH 16/19] powerpc: udbg supports for Celleb
@ 2006-12-14  2:47 Ishizaki Kou
  0 siblings, 0 replies; 4+ messages in thread
From: Ishizaki Kou @ 2006-12-14  2:47 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev
This patch adds udbg support for Celleb platform.
Signed-off-by: Kou Ishizaki <kou.ishizaki@toshiba.co.jp>
---
Index: linux-powerpc-git/arch/powerpc/kernel/udbg.c
diff -u linux-powerpc-git/arch/powerpc/kernel/udbg.c:1.1.1.1 linux-powerpc-git/arch/powerpc/kernel/udbg.c:1.2
--- linux-powerpc-git/arch/powerpc/kernel/udbg.c:1.1.1.1	Wed Dec  6 08:25:43 2006
+++ linux-powerpc-git/arch/powerpc/kernel/udbg.c	Wed Dec  6 08:43:15 2006
@@ -45,6 +45,8 @@
 #elif defined(CONFIG_PPC_EARLY_DEBUG_ISERIES)
 	/* For iSeries - hit Ctrl-x Ctrl-x to see the output */
 	udbg_init_iseries();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_BEAT)
+	udbg_init_debug_beat();
 #endif
 }
 
Index: linux-powerpc-git/arch/powerpc/platforms/celleb/udbg_beat.c
diff -u /dev/null linux-powerpc-git/arch/powerpc/platforms/celleb/udbg_beat.c:1.4
--- /dev/null	Wed Dec 13 21:32:05 2006
+++ linux-powerpc-git/arch/powerpc/platforms/celleb/udbg_beat.c	Wed Dec 13 18:19:14 2006
@@ -0,0 +1,98 @@
+/*
+ * udbg function for Beat
+ *
+ * (C) Copyright 2006 TOSHIBA CORPORATION
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/console.h>
+
+#include <asm/machdep.h>
+#include <asm/prom.h>
+#include <asm/udbg.h>
+
+#include "beat.h"
+
+int	celleb_vtermno;
+
+static void udbg_putc_beat(char c)
+{
+	unsigned long rc;
+
+	if (c == '\n')
+		udbg_putc_beat('\r');
+
+	rc = beat_put_term_char(celleb_vtermno, 1, (uint64_t)c << 56, 0);
+}
+
+/* Buffered chars getc */
+static long inbuflen;
+static long inbuf[2];	/* must be 2 longs */
+
+static int udbg_getc_poll_beat(void)
+{
+	/* The interface is tricky because it may return up to 16 chars.
+	 * We save them statically for future calls to udbg_getc().
+	 */
+	char ch, *buf = (char *)inbuf;
+	int i;
+	long rc;
+	if (inbuflen == 0) {
+		/* get some more chars. */
+		inbuflen = 0;
+		rc = beat_get_term_char(celleb_vtermno, &inbuflen, inbuf+0, inbuf+1);
+		if (rc != 0)
+			inbuflen = 0;	/* otherwise inbuflen is garbage */
+	}
+	if (inbuflen <= 0 || inbuflen > 16) {
+		/* Catch error case as well as other oddities (corruption) */
+		inbuflen = 0;
+		return -1;
+	}
+	ch = buf[0];
+	for (i = 1; i < inbuflen; i++)	/* shuffle them down. */
+		buf[i-1] = buf[i];
+	inbuflen--;
+	return ch;
+}
+
+static int udbg_getc_beat(void)
+{
+	int ch;
+	for (;;) {
+		ch = udbg_getc_poll_beat();
+		if (ch == -1) {
+			/* This shouldn't be needed...but... */
+			volatile unsigned long delay;
+			for (delay=0; delay < 2000000; delay++)
+				;
+		} else {
+			return ch;
+		}
+	}
+}
+
+/* call this from early_init() for a working debug console on
+ * vterm capable LPAR machines
+ */
+void __init udbg_init_debug_beat(void)
+{
+	celleb_vtermno = 0;
+	udbg_putc = udbg_putc_beat;
+	udbg_getc = udbg_getc_beat;
+	udbg_getc_poll = udbg_getc_poll_beat;
+}
Index: linux-powerpc-git/include/asm-powerpc/udbg.h
diff -u linux-powerpc-git/include/asm-powerpc/udbg.h:1.1.1.1 linux-powerpc-git/include/asm-powerpc/udbg.h:1.2
--- linux-powerpc-git/include/asm-powerpc/udbg.h:1.1.1.1	Wed Dec  6 08:24:04 2006
+++ linux-powerpc-git/include/asm-powerpc/udbg.h	Wed Dec  6 08:43:16 2006
@@ -44,6 +44,7 @@
 extern void __init udbg_init_iseries(void);
 extern void __init udbg_init_rtas_panel(void);
 extern void __init udbg_init_rtas_console(void);
+extern void __init udbg_init_debug_beat(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 16/19] powerpc: udbg supports for Celleb
@ 2007-01-12  1:16 Ishizaki Kou
  2007-01-18  0:38 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Ishizaki Kou @ 2007-01-12  1:16 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev
This patch adds udbg support for Celleb platform.
Signed-off-by: Kou Ishizaki <kou.ishizaki@toshiba.co.jp>
---
Index: linux-powerpc-git/arch/powerpc/kernel/udbg.c
diff -u linux-powerpc-git/arch/powerpc/kernel/udbg.c:1.1.1.1 linux-powerpc-git/arch/powerpc/kernel/udbg.c:1.2
--- linux-powerpc-git/arch/powerpc/kernel/udbg.c:1.1.1.1	Wed Dec  6 08:25:43 2006
+++ linux-powerpc-git/arch/powerpc/kernel/udbg.c	Wed Dec  6 08:43:15 2006
@@ -45,6 +45,8 @@
 #elif defined(CONFIG_PPC_EARLY_DEBUG_ISERIES)
 	/* For iSeries - hit Ctrl-x Ctrl-x to see the output */
 	udbg_init_iseries();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_BEAT)
+	udbg_init_debug_beat();
 #endif
 }
 
Index: linux-powerpc-git/arch/powerpc/platforms/celleb/udbg_beat.c
diff -u /dev/null linux-powerpc-git/arch/powerpc/platforms/celleb/udbg_beat.c:1.4
--- /dev/null	Thu Jan 11 22:03:29 2007
+++ linux-powerpc-git/arch/powerpc/platforms/celleb/udbg_beat.c	Wed Dec 13 18:19:14 2006
@@ -0,0 +1,98 @@
+/*
+ * udbg function for Beat
+ *
+ * (C) Copyright 2006 TOSHIBA CORPORATION
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/console.h>
+
+#include <asm/machdep.h>
+#include <asm/prom.h>
+#include <asm/udbg.h>
+
+#include "beat.h"
+
+int	celleb_vtermno;
+
+static void udbg_putc_beat(char c)
+{
+	unsigned long rc;
+
+	if (c == '\n')
+		udbg_putc_beat('\r');
+
+	rc = beat_put_term_char(celleb_vtermno, 1, (uint64_t)c << 56, 0);
+}
+
+/* Buffered chars getc */
+static long inbuflen;
+static long inbuf[2];	/* must be 2 longs */
+
+static int udbg_getc_poll_beat(void)
+{
+	/* The interface is tricky because it may return up to 16 chars.
+	 * We save them statically for future calls to udbg_getc().
+	 */
+	char ch, *buf = (char *)inbuf;
+	int i;
+	long rc;
+	if (inbuflen == 0) {
+		/* get some more chars. */
+		inbuflen = 0;
+		rc = beat_get_term_char(celleb_vtermno, &inbuflen, inbuf+0, inbuf+1);
+		if (rc != 0)
+			inbuflen = 0;	/* otherwise inbuflen is garbage */
+	}
+	if (inbuflen <= 0 || inbuflen > 16) {
+		/* Catch error case as well as other oddities (corruption) */
+		inbuflen = 0;
+		return -1;
+	}
+	ch = buf[0];
+	for (i = 1; i < inbuflen; i++)	/* shuffle them down. */
+		buf[i-1] = buf[i];
+	inbuflen--;
+	return ch;
+}
+
+static int udbg_getc_beat(void)
+{
+	int ch;
+	for (;;) {
+		ch = udbg_getc_poll_beat();
+		if (ch == -1) {
+			/* This shouldn't be needed...but... */
+			volatile unsigned long delay;
+			for (delay=0; delay < 2000000; delay++)
+				;
+		} else {
+			return ch;
+		}
+	}
+}
+
+/* call this from early_init() for a working debug console on
+ * vterm capable LPAR machines
+ */
+void __init udbg_init_debug_beat(void)
+{
+	celleb_vtermno = 0;
+	udbg_putc = udbg_putc_beat;
+	udbg_getc = udbg_getc_beat;
+	udbg_getc_poll = udbg_getc_poll_beat;
+}
Index: linux-powerpc-git/include/asm-powerpc/udbg.h
diff -u linux-powerpc-git/include/asm-powerpc/udbg.h:1.1.1.1 linux-powerpc-git/include/asm-powerpc/udbg.h:1.2
--- linux-powerpc-git/include/asm-powerpc/udbg.h:1.1.1.1	Wed Dec  6 08:24:04 2006
+++ linux-powerpc-git/include/asm-powerpc/udbg.h	Wed Dec  6 08:43:16 2006
@@ -44,6 +44,7 @@
 extern void __init udbg_init_iseries(void);
 extern void __init udbg_init_rtas_panel(void);
 extern void __init udbg_init_rtas_console(void);
+extern void __init udbg_init_debug_beat(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [PATCH 16/19] powerpc: udbg supports for Celleb
  2007-01-12  1:16 [PATCH 16/19] powerpc: udbg supports for Celleb Ishizaki Kou
@ 2007-01-18  0:38 ` Benjamin Herrenschmidt
  2007-01-18  7:58   ` Ishizaki Kou
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2007-01-18  0:38 UTC (permalink / raw)
  To: Ishizaki Kou; +Cc: linuxppc-dev, paulus
> +void __init udbg_init_debug_beat(void)
> +{
> +	celleb_vtermno = 0;
> +	udbg_putc = udbg_putc_beat;
> +	udbg_getc = udbg_getc_beat;
> +	udbg_getc_poll = udbg_getc_poll_beat;
> +}
Is celleb_vtermno ever != 0 ? I don't see that happening in your
patch...
If not, I would just remove it and just pass 0 directly :-) Or make it a
constant instead of a variable. Note that early debug is really just
that: optional early debugging which, when enabled, is likely to prevent
booting on any other platform, so only for use with debug builds. If you
ever need another value in here, thus, it's perfectly fine to make it a
Kconfig option that can be set at build time.
Ben.
^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [PATCH 16/19] powerpc: udbg supports for Celleb
  2007-01-18  0:38 ` Benjamin Herrenschmidt
@ 2007-01-18  7:58   ` Ishizaki Kou
  0 siblings, 0 replies; 4+ messages in thread
From: Ishizaki Kou @ 2007-01-18  7:58 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, paulus
Ben-san,
Thank you for your comment.
> > +void __init udbg_init_debug_beat(void)
> > +{
> > +	celleb_vtermno = 0;
> > +	udbg_putc = udbg_putc_beat;
> > +	udbg_getc = udbg_getc_beat;
> > +	udbg_getc_poll = udbg_getc_poll_beat;
> > +}
> Is celleb_vtermno ever != 0 ? I don't see that happening in your
> patch...
No. celleb_vtermno is currently fixed to 0. I had a plan to change
it at runtime, but I forgot to implement such behavior.
> If not, I would just remove it and just pass 0 directly :-) Or make it a
> constant instead of a variable. Note that early debug is really just
> that: optional early debugging which, when enabled, is likely to prevent
> booting on any other platform, so only for use with debug builds. If you
> ever need another value in here, thus, it's perfectly fine to make it a
> Kconfig option that can be set at build time.
Or finding vterm number on the commandline (like pSeries).
I don't stick to use other than 0 for celleb_vtermno, so I'll
#define it to 0. That's the simplest way.
Best regards,
Kou Ishizaki
^ permalink raw reply	[flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-18  7:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-12  1:16 [PATCH 16/19] powerpc: udbg supports for Celleb Ishizaki Kou
2007-01-18  0:38 ` Benjamin Herrenschmidt
2007-01-18  7:58   ` Ishizaki Kou
  -- strict thread matches above, loose matches on Subject: below --
2006-12-14  2:47 Ishizaki Kou
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).