Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/cobalt Change console code to use cninit() and null...



details:   https://anonhg.NetBSD.org/src/rev/ddb94b59ea6a
branches:  trunk
changeset: 553479:ddb94b59ea6a
user:      cdi <cdi%NetBSD.org@localhost>
date:      Fri Oct 17 18:20:10 2003 +0000

description:
Change console code to use cninit() and null console. Add serial console
check.

diffstat:

 sys/arch/cobalt/cobalt/console.c  |  55 ++++++++++++++++++++++++++++++++++----
 sys/arch/cobalt/conf/GENERIC      |   5 ++-
 sys/arch/cobalt/conf/files.cobalt |   3 +-
 sys/arch/cobalt/dev/com_mainbus.c |  10 ++++--
 4 files changed, 59 insertions(+), 14 deletions(-)

diffs (173 lines):

diff -r aad8de0cb4b2 -r ddb94b59ea6a sys/arch/cobalt/cobalt/console.c
--- a/sys/arch/cobalt/cobalt/console.c  Fri Oct 17 18:16:42 2003 +0000
+++ b/sys/arch/cobalt/cobalt/console.c  Fri Oct 17 18:20:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: console.c,v 1.5 2003/09/12 14:59:11 tsutsui Exp $      */
+/*     $NetBSD: console.c,v 1.6 2003/10/17 18:20:10 cdi Exp $  */
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: console.c,v 1.5 2003/09/12 14:59:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: console.c,v 1.6 2003/10/17 18:20:10 cdi Exp $");
 
 #include <sys/param.h>
 #include <sys/user.h>
@@ -40,21 +40,62 @@
 #include <sys/termios.h>
 
 #include <machine/bus.h>
+#include <machine/nvram.h>
 
 #include <dev/cons.h>
 
 #include <dev/ic/comreg.h>
 #include <dev/ic/comvar.h>
 
+#include "com.h"
+#include "nullcons.h"
+
+dev_type_cnprobe(comcnprobe);
+dev_type_cninit(comcninit);
+
+int    console_present = 0;    /* Do we have a console? */
+
+struct consdev constab[] = {
+#if NCOM > 0
+       { comcnprobe, comcninit, },
+#endif
+#if NNULLCONS > 0
+       { nullcnprobe, nullcninit },
+#endif
+       { 0 }
+};
+
+#if NCOM > 0
 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
 
 void
+comcnprobe(cn)
+       struct consdev *cn;
+{
+
+       /*
+        * Linux code has a comment that serial console must be probed
+        * early, otherwise the value which allows to detect serial port
+        * could be overwritten. Okay, probe here and record the result
+        * for the future use.
+        */
+       console_present = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x0020001c);
+       cn->cn_pri = (console_present != 0) ? CN_NORMAL : CN_DEAD;
+}
+
+void
+comcninit(cn)
+       struct consdev *cn;
+{
+
+       comcnattach(0, 0x1c800000, 115200, COM_FREQ * 10, COM_TYPE_NORMAL,
+           CONMODE);
+}
+#endif
+
+void
 consinit()
 {
-       /* XXX Check NVRAM to see if we should enable the console at all. */
 
-       comcnattach(0, 0x1c800000, 115200, COM_FREQ * 10, COM_TYPE_NORMAL,
-           CONMODE);
-
-       return;
+       cninit();
 }
diff -r aad8de0cb4b2 -r ddb94b59ea6a sys/arch/cobalt/conf/GENERIC
--- a/sys/arch/cobalt/conf/GENERIC      Fri Oct 17 18:16:42 2003 +0000
+++ b/sys/arch/cobalt/conf/GENERIC      Fri Oct 17 18:20:10 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.48 2003/10/14 16:16:04 tsutsui Exp $
+# $NetBSD: GENERIC,v 1.49 2003/10/17 18:20:10 cdi Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.48 $"
+#ident                 "GENERIC-$Revision: 1.49 $"
 
 maxusers       32
 
@@ -312,6 +312,7 @@
 pseudo-device  rnd                             # /dev/random & kernel generator
 #options       RND_COM                         # use "com" randomness (BROKEN)
 pseudo-device  clockctl                # user control of clock subsystem
+pseudo-device  nullcons                        # no-op console
 
 # A pseudo device needed for Coda              # also needs CODA (above)
 #pseudo-device vcoda           4               # coda minicache <-> venus comm.
diff -r aad8de0cb4b2 -r ddb94b59ea6a sys/arch/cobalt/conf/files.cobalt
--- a/sys/arch/cobalt/conf/files.cobalt Fri Oct 17 18:16:42 2003 +0000
+++ b/sys/arch/cobalt/conf/files.cobalt Fri Oct 17 18:20:10 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.cobalt,v 1.18 2003/10/08 17:29:59 bouyer Exp $
+#      $NetBSD: files.cobalt,v 1.19 2003/10/17 18:20:10 cdi Exp $
 
 maxpartitions 16
 
@@ -35,6 +35,7 @@
 file dev/md_root.c                     memory_disk_hooks
 
 file dev/cons.c
+file dev/cninit.c
 
 include "dev/i2o/files.i2o"
 
diff -r aad8de0cb4b2 -r ddb94b59ea6a sys/arch/cobalt/dev/com_mainbus.c
--- a/sys/arch/cobalt/dev/com_mainbus.c Fri Oct 17 18:16:42 2003 +0000
+++ b/sys/arch/cobalt/dev/com_mainbus.c Fri Oct 17 18:20:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: com_mainbus.c,v 1.7 2003/09/12 17:55:50 tsutsui Exp $  */
+/*     $NetBSD: com_mainbus.c,v 1.8 2003/10/17 18:20:10 cdi Exp $      */
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.7 2003/09/12 17:55:50 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.8 2003/10/17 18:20:10 cdi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -46,11 +46,14 @@
 #include <machine/autoconf.h>
 #include <machine/intr.h>
 #include <machine/bus.h>
+#include <machine/nvram.h>
 
 #include <dev/ic/comreg.h>
 #include <dev/ic/comvar.h>
 
 
+extern int console_present;
+
 struct com_mainbus_softc {
        struct com_softc sc_com;
        void *sc_ih;
@@ -68,9 +71,8 @@
        struct cfdata *match;
        void *aux;
 {
-       /* XXX probe */
 
-       return 1;
+       return (console_present != 0);
 }
 
 struct com_softc *com0; /* XXX */



Home | Main Index | Thread Index | Old Index