summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/files/rtkload/prom_printf.c
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2012-09-13 00:40:35 +0300
committerRoman Yeryomin <roman@advem.lv>2012-12-03 00:13:21 +0200
commit5deb3317cb51ac52de922bb55f8492624018906d (patch)
treec2fbe6346699d9bb0f2100490c3029519bb8fde8 /target/linux/realtek/files/rtkload/prom_printf.c
parent0239d37124f9184b478a42de8a7fa1bc85a6a6fe (diff)
Add realtek target files
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/files/rtkload/prom_printf.c')
-rw-r--r--target/linux/realtek/files/rtkload/prom_printf.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/target/linux/realtek/files/rtkload/prom_printf.c b/target/linux/realtek/files/rtkload/prom_printf.c
new file mode 100644
index 000000000..7bf58cdb3
--- /dev/null
+++ b/target/linux/realtek/files/rtkload/prom_printf.c
@@ -0,0 +1,87 @@
+/*
+ * Borrowed from arch/mips/r39xx/prom/init.c
+ *
+ */
+
+/*
+ * init.c: early initialisation code for R39XX Class PDAs
+ *
+ * Copyright (C) 1999 Harald Koerfgen
+ *
+ * $Id: prom_printf.c,v 1.2 2008/08/04 08:54:44 michael Exp $
+ */
+
+
+
+#define CONFIG_SERIAL
+
+#include <stdarg.h>
+
+//#include <linux/config.h>
+#include <linux/autoconf.h>
+
+#ifdef CONFIG_RTL_EB8186
+#include <asm/rtl8181.h>
+#endif
+
+#if 1
+ //#define __KERNEL__
+
+ //#include <asm/types.h>
+ //#include <asm/serial.h>
+ #include <asm/io.h>
+
+ #define UART_THR 0x2000
+ #define UART_LSR 0x2014
+
+ #define rtl_outb(port,val) outb(val,port)
+ #define rtl_inb(port) inb(port)
+#endif
+
+void serial_outc(char c)
+{
+ int i=0;
+ while (1)
+ {
+ i++;
+ if (i >=0x6000)
+ break;
+
+ if (rtl_inb(UART_LSR) & 0x20)
+ break;
+ }
+ rtl_outb(UART_THR, c);
+}
+
+
+/*
+ * Helpful for debugging :-)
+ */
+int prom_printf(const char * fmt, ...)
+{
+#ifdef CONFIG_SERIAL
+ //extern void serial_outc(char);
+ static char buf[1024];
+ va_list args;
+ char c;
+ int i = 0;
+
+ /*
+ * Printing messages via serial port
+ */
+ va_start(args, fmt);
+ vsprintf(buf, fmt, args);
+ va_end(args);
+
+ for (i = 0; buf[i] != '\0'; i++) {
+ c = buf[i];
+ if (c == '\n')
+ serial_outc('\r');
+ serial_outc(c);
+ }
+
+ return i;
+#else
+ return 0;
+#endif
+}