Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/dev Use the promlib I/O routines.



details:   https://anonhg.NetBSD.org/src/rev/8a715f85580a
branches:  trunk
changeset: 559654:8a715f85580a
user:      pk <pk%NetBSD.org@localhost>
date:      Sun Mar 21 15:08:24 2004 +0000

description:
Use the promlib I/O routines.

diffstat:

 sys/arch/sparc64/dev/com_ebus.c |  28 ++++++++++++----------------
 sys/arch/sparc64/dev/consinit.c |  36 +++++++++---------------------------
 sys/arch/sparc64/dev/kd.c       |   8 ++++----
 sys/arch/sparc64/dev/pcons.c    |  12 +++++-------
 sys/arch/sparc64/dev/sab.c      |  23 ++++++++---------------
 sys/arch/sparc64/dev/zs.c       |   8 ++++----
 6 files changed, 42 insertions(+), 73 deletions(-)

diffs (truncated from 361 to 300 lines):

diff -r c3a395dc37a4 -r 8a715f85580a sys/arch/sparc64/dev/com_ebus.c
--- a/sys/arch/sparc64/dev/com_ebus.c   Sun Mar 21 15:07:00 2004 +0000
+++ b/sys/arch/sparc64/dev/com_ebus.c   Sun Mar 21 15:08:24 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: com_ebus.c,v 1.20 2003/07/15 03:36:04 lukem Exp $      */
+/*     $NetBSD: com_ebus.c,v 1.21 2004/03/21 15:08:24 pk Exp $ */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com_ebus.c,v 1.20 2003/07/15 03:36:04 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_ebus.c,v 1.21 2004/03/21 15:08:24 pk Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -77,21 +77,18 @@
        struct ebus_attach_args *ea = aux;
        int i;
 
-       for (i=0; com_names[i]; i++)
+       for (i = 0; com_names[i]; i++)
                if (strcmp(ea->ea_name, com_names[i]) == 0)
                        return (1);
 
        if (strcmp(ea->ea_name, "serial") == 0) {
-               char compat[80];
+               char *compat;
 
                /* Could be anything. */
-               if ((i = OF_getproplen(ea->ea_node, "compatible")) &&
-                       OF_getprop(ea->ea_node, "compatible", compat,
-                               sizeof(compat)) == i) {
-                       if (strcmp(compat, "su16550") == 0 || 
-                               strcmp(compat, "su") == 0) {
-                               return (1);
-                       }
+               compat = prom_getpropstring(ea->ea_node, "compatible");
+               if (strcmp(compat, "su16550") == 0 ||
+                   strcmp(compat, "su") == 0) {
+                       return (1);
                }
        }
        return (0);
@@ -147,8 +144,8 @@
        kma.kmta_consdev = NULL;
 
        /* Figure out if we're the console. */
-       com_is_input = (ea->ea_node == OF_instance_to_package(OF_stdin()));
-       com_is_output = (ea->ea_node == OF_instance_to_package(OF_stdout()));
+       com_is_input = (ea->ea_node == prom_instance_to_package(prom_stdin()));
+       com_is_output = (ea->ea_node == prom_instance_to_package(prom_stdout()));
 
        if (com_is_input || com_is_output) {
                extern struct consdev comcons;
@@ -192,13 +189,13 @@
 /* Attach 'em if we got 'em. */
 #if (NKBD > 0)
        kma.kmta_name = "keyboard";
-       if (OF_getproplen(ea->ea_node, kma.kmta_name) == 0) {
+       if (prom_getproplen(ea->ea_node, kma.kmta_name) == 0) {
                config_found(self, (void *)&kma, NULL);
        }
 #endif
 #if (NMS > 0)
        kma.kmta_name = "mouse";
-       if (OF_getproplen(ea->ea_node, kma.kmta_name) == 0) {
+       if (prom_getproplen(ea->ea_node, kma.kmta_name) == 0) {
                config_found(self, (void *)&kma, NULL);
        }
 #endif
@@ -213,4 +210,3 @@
                cn_tab = kma.kmta_consdev;
        }
 }
-
diff -r c3a395dc37a4 -r 8a715f85580a sys/arch/sparc64/dev/consinit.c
--- a/sys/arch/sparc64/dev/consinit.c   Sun Mar 21 15:07:00 2004 +0000
+++ b/sys/arch/sparc64/dev/consinit.c   Sun Mar 21 15:08:24 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: consinit.c,v 1.16 2004/03/19 21:10:31 petrov Exp $     */
+/*     $NetBSD: consinit.c,v 1.17 2004/03/21 15:08:24 pk Exp $ */
 
 /*-
  * Copyright (c) 1999 Eduardo E. Horvath
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.16 2004/03/19 21:10:31 petrov Exp $");
+__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.17 2004/03/21 15:08:24 pk Exp $");
 
 #include "opt_ddb.h"
 #include "pcons.h"
@@ -66,8 +66,6 @@
 static void prom_cnpollc __P((dev_t, int));
 static void prom_cnputc __P((dev_t, int));
 
-int stdin = 0, stdout = 0;
-
 /*
  * The console is set to this one initially,
  * which lets us use the PROM until consinit()
@@ -113,7 +111,7 @@
        static int nplus = 0;
 #endif
 
-       while ((l = OF_read(stdin, &ch, 1)) != 1)
+       while ((l = prom_read(prom_stdin(), &ch, 1)) != 1)
                /* void */;
 #ifdef DDB
        if (ch == '+') {
@@ -129,8 +127,6 @@
 prom_cninit(cn)
        struct consdev *cn;
 {
-       if (!stdin) stdin = OF_stdin();
-       if (!stdout) stdout = OF_stdout();
 }
 
 /*
@@ -144,11 +140,8 @@
        int s;
        char c0 = (c & 0x7f);
 
-#if 0
-       if (!stdout) stdout = OF_stdout();
-#endif
        s = splhigh();
-       OF_write(stdout, &c0, 1);
+       prom_write(prom_stdout(), &c0, 1);
        splx(s);
 }
 
@@ -198,38 +191,27 @@
        if (cn_tab != &consdev_prom)
                return;
 
-       chosen = OF_finddevice("/chosen");
+       chosen = prom_finddevice("/chosen");
 
-       DBPRINT(("setting up stdin\r\n"));
-       DBPRINT(("chosen = %x, stdin @ %p\r\n", chosen, &stdin));
-       OF_getprop(chosen, "stdin",  &stdin, sizeof(stdin));
-       DBPRINT(("stdin instance = %x\r\n", stdin));
-
-       if ((prom_stdin_node = OF_instance_to_package(stdin)) == 0) {
+       if ((prom_stdin_node = prom_instance_to_package(prom_stdin())) == 0) {
                printf("WARNING: no PROM stdin\n");
        }
-
        DBPRINT(("stdin node = %x\r\n", prom_stdin_node));
 
-       DBPRINT(("setting up stdout\r\n"));
-       OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
-       DBPRINT(("stdout instance = %x\r\n", stdout));
-
-       if ((prom_stdout_node = OF_instance_to_package(stdout)) == 0)
+       if ((prom_stdout_node = prom_instance_to_package(prom_stdout())) == 0)
                printf("WARNING: no PROM stdout\n");
-
        DBPRINT(("stdout package = %x\r\n", prom_stdout_node));
 
        DBPRINT(("buffer @ %p\r\n", buffer));
 
        if (prom_stdin_node != 0 &&
-           (OF_getproplen(prom_stdin_node, "keyboard") >= 0)) {
+           (prom_getproplen(prom_stdin_node, "keyboard") >= 0)) {
 #if NKBD > 0
                printf("cninit: kdb/display not configured\n");
 #endif
                consname = "keyboard/display";
        } else if (prom_stdout_node != 0 &&
-                  (OF_instance_to_path(stdin, buffer, sizeof(buffer)) >= 0)) {
+                  (OF_instance_to_path(prom_stdin(), buffer, sizeof(buffer)) >= 0)) {
                consname = buffer;
        }
        printf("console is %s\n", consname);
diff -r c3a395dc37a4 -r 8a715f85580a sys/arch/sparc64/dev/kd.c
--- a/sys/arch/sparc64/dev/kd.c Sun Mar 21 15:07:00 2004 +0000
+++ b/sys/arch/sparc64/dev/kd.c Sun Mar 21 15:08:24 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kd.c,v 1.31 2004/03/17 14:03:22 pk Exp $       */
+/*     $NetBSD: kd.c,v 1.32 2004/03/21 15:08:24 pk Exp $       */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kd.c,v 1.31 2004/03/17 14:03:22 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kd.c,v 1.32 2004/03/21 15:08:24 pk Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -436,7 +436,7 @@
                while (p < end)
                        *p++ &= 0x7f;
                /* Now let the PROM print it. */
-               OF_write(OF_stdout(), buf, len);
+               prom_write(prom_stdout(), buf, len);
        }
 }
 
@@ -644,7 +644,7 @@
        char c0 = (c & 0x7f);
 
        s = splhigh();
-       OF_write(OF_stdout(), &c0, 1);
+       prom_write(prom_stdout(), &c0, 1);
        splx(s);
 }
 
diff -r c3a395dc37a4 -r 8a715f85580a sys/arch/sparc64/dev/pcons.c
--- a/sys/arch/sparc64/dev/pcons.c      Sun Mar 21 15:07:00 2004 +0000
+++ b/sys/arch/sparc64/dev/pcons.c      Sun Mar 21 15:08:24 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcons.c,v 1.17 2003/07/15 03:36:06 lukem Exp $ */
+/*     $NetBSD: pcons.c,v 1.18 2004/03/21 15:08:24 pk Exp $    */
 
 /*-
  * Copyright (c) 2000 Eduardo E. Horvath
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcons.c,v 1.17 2003/07/15 03:36:06 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcons.c,v 1.18 2004/03/21 15:08:24 pk Exp $");
 
 #include "opt_ddb.h"
 
@@ -258,7 +258,7 @@
        splx(s);
        cl = &tp->t_outq;
        len = q_to_b(cl, buf, OFBURSTLEN);
-       OF_write(stdout, buf, len);
+       prom_write(prom_stdout(), buf, len);
        s = spltty();
        tp->t_state &= ~TS_BUSY;
        if (cl->c_cc) {
@@ -294,7 +294,7 @@
        struct tty *tp = sc->of_tty;
        char ch;
        
-       while (OF_read(stdin, &ch, 1) > 0) {
+       while (prom_read(prom_stdin(), &ch, 1) > 0) {
                cn_check_magic(tp->t_dev, ch, pcons_cnm_state);
                if (tp && (tp->t_state & TS_ISOPEN))
                        (*tp->t_linesw->l_rint)(ch, tp);
@@ -305,10 +305,8 @@
 int
 pconsprobe()
 {
-       if (!stdin) stdin = OF_stdin();
-       if (!stdout) stdout = OF_stdout();
 
-       return (stdin && stdout);
+       return (prom_stdin() && prom_stdout());
 }
 
 void
diff -r c3a395dc37a4 -r 8a715f85580a sys/arch/sparc64/dev/sab.c
--- a/sys/arch/sparc64/dev/sab.c        Sun Mar 21 15:07:00 2004 +0000
+++ b/sys/arch/sparc64/dev/sab.c        Sun Mar 21 15:08:24 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sab.c,v 1.15 2004/03/17 17:04:59 pk Exp $      */
+/*     $NetBSD: sab.c,v 1.16 2004/03/21 15:08:24 pk Exp $      */
 /*     $OpenBSD: sab.c,v 1.7 2002/04/08 17:49:42 jason Exp $   */
 
 /*
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sab.c,v 1.15 2004/03/17 17:04:59 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sab.c,v 1.16 2004/03/21 15:08:24 pk Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1301,23 +1301,18 @@
        struct sabtty_softc *sc;
 {
        int node, channel, cookie;
-       u_int options;
        char buf[255];
 
        node = sc->sc_parent->sc_node;
        channel = sc->sc_portno;
 
-       options = OF_finddevice("/options");
-
        /* Default to channel 0 if there are no explicit prom args */
        cookie = 0;
 
-       if (node == OF_instance_to_package(OF_stdin())) {
-               if (OF_getprop(options, "input-device", buf,
-                   sizeof(buf)) != -1) {



Home | Main Index | Thread Index | Old Index