[PATCH -queue 4/7] [loongosn] add a new serial port debug function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is an existing serial port debug function: prom_putchar(), but it
can only print one char, herein add a new prom_printf(), which works
like printk, but print to serial port, which is very important to kernel
debugging.

Signed-off-by: Wu Zhangjin <wuzhangjin@xxxxxxxxx>
---
 arch/mips/include/asm/mach-loongson/dbg.h |   17 ++++++++++++++
 arch/mips/loongson/common/Makefile        |    2 +-
 arch/mips/loongson/common/dbg.c           |   34 +++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-loongson/dbg.h
 create mode 100644 arch/mips/loongson/common/dbg.c

diff --git a/arch/mips/include/asm/mach-loongson/dbg.h b/arch/mips/include/asm/mach-loongson/dbg.h
new file mode 100644
index 0000000..c676f8e
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson/dbg.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2009 Lemote Inc.
+ *
+ * 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.
+ */
+
+#ifndef _ASM_MACH_LOONGSON_DBG_H_
+#define _ASM_MACH_LOONGSON_DBG_H_
+
+/* serial port print support */
+extern void prom_putchar(char c);
+extern void prom_printf(char *fmt, ...);
+
+#endif /* _ASM_MACH_LOONGSON_DBG_H_ */
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile
index 656b3cc..adbe85c 100644
--- a/arch/mips/loongson/common/Makefile
+++ b/arch/mips/loongson/common/Makefile
@@ -8,4 +8,4 @@ obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
 #
 # Early printk support
 #
-obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
+obj-$(CONFIG_EARLY_PRINTK) += early_printk.o dbg.o
diff --git a/arch/mips/loongson/common/dbg.c b/arch/mips/loongson/common/dbg.c
new file mode 100644
index 0000000..214f295
--- /dev/null
+++ b/arch/mips/loongson/common/dbg.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Lemote Inc.
+ *
+ * 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.
+ */
+
+#include <dbg.h>
+#include <loongson.h>
+
+#define PROM_PRINTF_BUF_LEN 1024
+
+void prom_printf(char *fmt, ...)
+{
+	static char buf[PROM_PRINTF_BUF_LEN];
+	va_list args;
+	char *ptr;
+
+
+	va_start(args, fmt);
+	vscnprintf(buf, sizeof(buf), fmt, args);
+
+	ptr = buf;
+
+	while (*ptr != 0) {
+		if (*ptr == '\n')
+			prom_putchar('\r');
+
+		prom_putchar(*ptr++);
+	}
+	va_end(args);
+}
-- 
1.6.2.1



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux