Source-Changes-HG archive

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

[src/trunk]: src/sys Fix the sparc64 console.



details:   https://anonhg.NetBSD.org/src/rev/465e9c5e103f
branches:  trunk
changeset: 486331:465e9c5e103f
user:      eeh <eeh%NetBSD.org@localhost>
date:      Fri May 19 05:26:16 2000 +0000

description:
Fix the sparc64 console.

Unlike the other Sun machines, UltraSPARCs can have consoles run on different
chips than zs, so we need to support them.  So, here we go:

        Add a new PROM console driver with a major number and everything.
        This is the default driver if nothing else attaches.  It does not
        use the keyboard driver since the PROM translates keystrokes itself.
        (Unfortunately it also swallows L1-A).

        Have the keyboard driver take over the console when it attaches on a
        serial port.  When a serial port detects a keyboard and attaches the
        keyboard driver, it needs to provide a set of consdev vectors.  They
        keyboard driver will use those to send I/O to the keyboard and mouse.

diffstat:

 sys/arch/sparc/dev/kd.c                |    5 +-
 sys/arch/sparc64/conf/files.sparc64    |    6 +-
 sys/arch/sparc64/dev/cons.h            |   51 ++++-
 sys/arch/sparc64/dev/consinit.c        |  108 +++++----
 sys/arch/sparc64/dev/kd.c              |   65 ++++-
 sys/arch/sparc64/dev/zs.c              |  373 +++++++++++---------------------
 sys/arch/sparc64/include/conf.h        |    4 +-
 sys/arch/sparc64/include/z8530var.h    |    4 +-
 sys/arch/sparc64/sparc64/autoconf.c    |    8 +-
 sys/arch/sparc64/sparc64/conf.c        |    4 +-
 sys/arch/sparc64/sparc64/ofw_machdep.c |   22 +-
 sys/arch/sun3/dev/kd.c                 |    5 +-
 sys/dev/sun/kbd_zs.c                   |    4 +-
 sys/dev/sun/kbdvar.h                   |    4 +-
 14 files changed, 334 insertions(+), 329 deletions(-)

diffs (truncated from 1203 to 300 lines):

diff -r c7e54decd123 -r 465e9c5e103f sys/arch/sparc/dev/kd.c
--- a/sys/arch/sparc/dev/kd.c   Fri May 19 05:04:32 2000 +0000
+++ b/sys/arch/sparc/dev/kd.c   Fri May 19 05:26:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kd.c,v 1.10 2000/03/24 11:46:46 hannken Exp $  */
+/*     $NetBSD: kd.c,v 1.11 2000/05/19 05:26:16 eeh Exp $      */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -450,8 +450,9 @@
 }
 
 void
-cons_attach_input(cc)
+cons_attach_input(cc, cn)
        struct cons_channel *cc;
+       struct consdev *cn;
 {
        struct kd_softc *kd = &kd_softc;
 
diff -r c7e54decd123 -r 465e9c5e103f sys/arch/sparc64/conf/files.sparc64
--- a/sys/arch/sparc64/conf/files.sparc64       Fri May 19 05:04:32 2000 +0000
+++ b/sys/arch/sparc64/conf/files.sparc64       Fri May 19 05:26:16 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sparc64,v 1.28 2000/04/22 17:05:59 mrg Exp $
+#      $NetBSD: files.sparc64,v 1.29 2000/05/19 05:26:17 eeh Exp $
 
 # @(#)files.sparc64    8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -12,6 +12,10 @@
 device mainbus: pcibus, mainbus
 attach mainbus at root
 
+device pcons
+attach pcons at mainbus
+file   arch/sparc64/dev/pcons.c                pcons needs-flag
+
 include "dev/sbus/files.sbus"
 attach sbus at mainbus
 file   arch/sparc64/dev/sbus.c                 sbus
diff -r c7e54decd123 -r 465e9c5e103f sys/arch/sparc64/dev/cons.h
--- a/sys/arch/sparc64/dev/cons.h       Fri May 19 05:04:32 2000 +0000
+++ b/sys/arch/sparc64/dev/cons.h       Fri May 19 05:26:16 2000 +0000
@@ -1,4 +1,53 @@
-/*     $NetBSD: cons.h,v 1.2 1999/02/15 04:54:34 hubertf Exp $ */
+/*     $NetBSD: cons.h,v 1.3 2000/05/19 05:26:17 eeh Exp $     */
+
+/*-
+ * Copyright (c) 2000 Eduardo E. Horvath
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * PROM console driver.
+ *
+ * This is the default fallback console driver if nothing else attaches.
+ */
+
+struct pconssoftc {
+       struct device of_dev;
+       struct tty *of_tty;
+       struct callout sc_poll_ch;
+       int of_flags;
+};
+/* flags: */
+#define        OFPOLL          1
+
+#define        OFBURSTLEN      128     /* max number of bytes to write in one chunk */
+
+/* These are shared with the consinit OBP console */
+extern int stdin, stdout;
+void pcons_cnpollc __P((dev_t dev, int on));
 
 struct consdev;
 struct zs_chanstate;
diff -r c7e54decd123 -r 465e9c5e103f sys/arch/sparc64/dev/consinit.c
--- a/sys/arch/sparc64/dev/consinit.c   Fri May 19 05:04:32 2000 +0000
+++ b/sys/arch/sparc64/dev/consinit.c   Fri May 19 05:26:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: consinit.c,v 1.4 2000/04/19 08:15:06 pk Exp $  */
+/*     $NetBSD: consinit.c,v 1.5 2000/05/19 05:26:17 eeh Exp $ */
 
 /*-
  * Copyright (c) 1999 Eduardo E. Horvath
@@ -28,12 +28,8 @@
  * SUCH DAMAGE.
  */
 
-/*
- * Default console driver.  Uses the PROM or whatever
- * driver(s) are appropriate.
- */
-
 #include "opt_ddb.h"
+#include "pcons.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -61,10 +57,11 @@
 #include <sparc64/sparc64/vaddrs.h>
 #include <sparc64/dev/cons.h>
 
-
-
+static void prom_cnprobe __P((struct consdev *));
 static void prom_cninit __P((struct consdev *));
-static int  prom_cngetc __P((dev_t));
+int  prom_cngetc __P((dev_t));
+static void prom_cnputc __P((dev_t, int));
+static void prom_cnpollc __P((dev_t, int));
 static void prom_cnputc __P((dev_t, int));
 
 int stdin = NULL, stdout = NULL;
@@ -75,11 +72,11 @@
  * is called to select a real console.
  */
 struct consdev consdev_prom = {
-       nullcnprobe,
+       prom_cnprobe,
        prom_cninit,
        prom_cngetc,
        prom_cnputc,
-       nullcnpollc,
+       prom_cnpollc,
        NULL,
 };
 
@@ -91,45 +88,40 @@
 struct consdev *cn_tab = &consdev_prom;
 
 void
-nullcnprobe(cn)
-       struct consdev *cn;
+prom_cnprobe(cd)
+       struct consdev *cd;
 {
+#if NPCONS > 0
+       int maj;
+
+       for (maj = 0; maj < nchrdev; maj++)
+               if (cdevsw[maj].d_open == pconsopen)
+                       break;
+       cd->cn_dev = makedev(maj, 0);
+       cd->cn_pri = CN_INTERNAL;
+#endif
+}
+
+int
+prom_cngetc(dev)
+       dev_t dev;
+{
+       unsigned char ch = '\0';
+       int l;
+       
+       while ((l = OF_read(stdin, &ch, 1)) != 1)
+               /* void */;
+       if (ch == '\r')
+               ch = '\n';
+       return ch;
 }
 
 static void
 prom_cninit(cn)
        struct consdev *cn;
 {
-       if (!stdin) {
-               int node = OF_finddevice("/chosen");
-               OF_getprop(node, "stdin",  &stdin, sizeof(stdin));
-       }
-       if (!stdout) {
-               int node = OF_finddevice("/chosen");
-               OF_getprop(node, "stdout",  &stdout, sizeof(stdout));
-       }
-}
-
-/*
- * PROM console input putchar.
- * (dummy - this is output only)
- */
-static int
-prom_cngetc(dev)
-       dev_t dev;
-{
-       char c;
-
-       if (!stdin) {
-               int node = OF_finddevice("/chosen");
-               OF_getprop(node, "stdin",  &stdin, sizeof(stdin));
-       }
-       while (OF_read(stdin, &c, 1) != 1)
-               /*void*/;
-
-       if (c == '\r')
-               c = '\n';
-       return (c);
+       if (!stdin) stdin = OF_stdin();
+       if (!stdout) stdout = OF_stdout();
 }
 
 /*
@@ -143,16 +135,32 @@
        int s;
        char c0 = (c & 0x7f);
 
-       if (!stdout) {
-               int node = OF_finddevice("/chosen");
-               OF_getprop(node, "stdout",  &stdout, sizeof(stdout));
-       }
-
+#if 0
+       if (!stdout) stdout = OF_stdout();
+#endif
        s = splhigh();
        OF_write(stdout, &c0, 1);
        splx(s);
 }
 
+void
+prom_cnpollc(dev, on)
+       dev_t dev;
+       int on;
+{
+       if (on) {
+                /* Entering debugger. */
+#if NFB > 0
+                fb_unblank();
+#endif  
+       } else {
+                /* Resuming kernel. */
+       }
+#if NPCONS > 0
+       pcons_cnpollc(dev, on);
+#endif  
+}
+
 /*****************************************************************/
 
 #ifdef DEBUG
@@ -207,6 +215,8 @@
        }
        printf("console is %s\n", consname);
  
-       /* Defer the rest to the device attach */
+       /* Initialize PROM console */
+       (*cn_tab->cn_probe)(cn_tab);
+       (*cn_tab->cn_init)(cn_tab);
 }
 
diff -r c7e54decd123 -r 465e9c5e103f sys/arch/sparc64/dev/kd.c
--- a/sys/arch/sparc64/dev/kd.c Fri May 19 05:04:32 2000 +0000
+++ b/sys/arch/sparc64/dev/kd.c Fri May 19 05:26:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kd.c,v 1.11 2000/03/23 06:45:37 thorpej Exp $  */
+/*     $NetBSD: kd.c,v 1.12 2000/05/19 05:26:17 eeh Exp $      */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -99,6 +99,7 @@
 static void kdstart(struct tty *);
 static void kd_init __P((struct kd_softc *));
 static void kd_cons_input __P((int));
+static int  kdcngetc __P((dev_t));
 
 int    cons_ocount;            /* output byte count */
 
@@ -426,16 +427,6 @@
        }
 }
 
-void
-cons_attach_input(cc)
-       struct cons_channel *cc;
-{
-       struct kd_softc *kd = &kd_softc;
-
-       kd->kd_in = cc;
-       cc->cc_upstream = kd_cons_input;



Home | Main Index | Thread Index | Old Index