Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Fix early console support.



details:   https://anonhg.NetBSD.org/src/rev/10c77d307529
branches:  trunk
changeset: 773368:10c77d307529
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Feb 01 02:05:14 2012 +0000

description:
Fix early console support.

diffstat:

 sys/arch/evbmips/rasoc/machdep.c  |   8 +++---
 sys/arch/mips/ralink/ralink_com.c |  43 +++++++++++++++++++++++++++++++++++++-
 sys/arch/mips/ralink/ralink_var.h |   6 ++--
 3 files changed, 48 insertions(+), 9 deletions(-)

diffs (118 lines):

diff -r 69885489b90e -r 10c77d307529 sys/arch/evbmips/rasoc/machdep.c
--- a/sys/arch/evbmips/rasoc/machdep.c  Wed Feb 01 02:02:07 2012 +0000
+++ b/sys/arch/evbmips/rasoc/machdep.c  Wed Feb 01 02:05:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.5 2011/08/16 06:59:19 matt Exp $ */
+/*     $NetBSD: machdep.c,v 1.6 2012/02/01 02:05:14 matt Exp $ */
 /*-
  * Copyright (c) 2011 CradlePoint Technology, Inc.
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 2011/08/16 06:59:19 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6 2012/02/01 02:05:14 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/boot_flag.h>
@@ -107,13 +107,13 @@
 
        memset(edata, 0, kernend - (vaddr_t)edata);
 
-#ifdef RA_CONSOLE_EARLY
+#ifdef RALINK_CONSOLE_EARLY
        /*
         * set up early console
         *  cannot printf until sometime (?) in mips_vector_init
         *  meanwhile can use the ra_console_putc primitive if necessary
         */
-       ra_console_early();
+       ralink_console_early();
 #endif
 
        /* set CPU model info for sysctl_hw */
diff -r 69885489b90e -r 10c77d307529 sys/arch/mips/ralink/ralink_com.c
--- a/sys/arch/mips/ralink/ralink_com.c Wed Feb 01 02:02:07 2012 +0000
+++ b/sys/arch/mips/ralink/ralink_com.c Wed Feb 01 02:05:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ralink_com.c,v 1.2 2011/07/28 15:38:49 matt Exp $      */
+/*     $NetBSD: ralink_com.c,v 1.3 2012/02/01 02:05:14 matt Exp $      */
 /*-
  * Copyright (c) 2011 CradlePoint Technology, Inc.
  * All rights reserved.
@@ -130,7 +130,7 @@
 /* ralink_com.c -- Ralink 3052 uart console driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ralink_com.c,v 1.2 2011/07/28 15:38:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ralink_com.c,v 1.3 2012/02/01 02:05:14 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -195,6 +195,45 @@
        *RA_IOREG_VADDR(RA_UART_LITE_BASE, offset) = val;
 }
 
+#ifdef RALINK_CONSOLE_EARLY
+static int
+ralink_cngetc(dev_t dv)
+{
+        if ((uart_read(RA_UART_LSR) & LSR_RXRDY) == 0)
+               return -1;
+
+       return uart_read(RA_UART_RBR) & 0xff;
+}
+
+static void
+ralink_cnputc(dev_t dv, int c)
+{
+       int timo = 150000;
+
+        while ((uart_read(RA_UART_LSR) & LSR_TXRDY) == 0 && --timo > 0)
+               ;
+
+       uart_write(RA_UART_TBR, c);
+       __asm __volatile("sync");
+
+       timo = 150000;
+        while ((uart_read(RA_UART_LSR) & LSR_TSRE) == 0 && --timo > 0)
+               ;
+}
+
+static struct consdev ralink_earlycons = {
+       .cn_putc = ralink_cnputc,
+       .cn_getc = ralink_cngetc,
+       .cn_pollc = nullcnpollc,
+};
+
+void
+ralink_console_early(void)
+{
+       cn_tab = &ralink_earlycons;
+}
+#endif
+
 
 int
 ralink_com_match(device_t parent, cfdata_t cf, void *aux)
diff -r 69885489b90e -r 10c77d307529 sys/arch/mips/ralink/ralink_var.h
--- a/sys/arch/mips/ralink/ralink_var.h Wed Feb 01 02:02:07 2012 +0000
+++ b/sys/arch/mips/ralink/ralink_var.h Wed Feb 01 02:05:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ralink_var.h,v 1.4 2011/08/03 16:26:53 matt Exp $      */
+/*     $NetBSD: ralink_var.h,v 1.5 2012/02/01 02:05:14 matt Exp $      */
 /*-
  * Copyright (c) 2011 CradlePoint Technology, Inc.
  * All rights reserved.
@@ -57,8 +57,8 @@
 /* helper defines */
 #define MS_TO_HZ(ms) ((ms) * hz / 1000)
 
-#ifdef RA_CONSOLE_EARLY
-extern void ra_console_early(void);
+#ifdef RALINK_CONSOLE_EARLY
+extern void ralink_console_early(void);
 #endif
 
 #endif /* _RALINK_VAR_H_ */



Home | Main Index | Thread Index | Old Index