Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/cobalt - rename comcnprobe() and comcninit() to com...



details:   https://anonhg.NetBSD.org/src/rev/23489a9e67df
branches:  trunk
changeset: 569681:23489a9e67df
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Aug 29 16:14:15 2004 +0000

description:
- rename comcnprobe() and comcninit() to com_mainbus_cnprobe() and
  com_mainbus_cninit() and move these cn functions from cobalt/console.c
  to dev/com_mainbus.c
- call cninit() only once
- remove unneeded includes
- use ANSI function decls

diffstat:

 sys/arch/cobalt/cobalt/console.c     |  74 ++++++------------------------
 sys/arch/cobalt/conf/files.cobalt    |   4 +-
 sys/arch/cobalt/dev/com_mainbus.c    |  86 ++++++++++++++++++++++++-----------
 sys/arch/cobalt/dev/com_mainbusvar.h |  31 ++++++++++++
 4 files changed, 106 insertions(+), 89 deletions(-)

diffs (truncated from 312 to 300 lines):

diff -r 81107f925508 -r 23489a9e67df sys/arch/cobalt/cobalt/console.c
--- a/sys/arch/cobalt/cobalt/console.c  Sun Aug 29 14:08:06 2004 +0000
+++ b/sys/arch/cobalt/cobalt/console.c  Sun Aug 29 16:14:15 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: console.c,v 1.7 2004/01/07 12:43:43 cdi Exp $  */
+/*     $NetBSD: console.c,v 1.8 2004/08/29 16:14:15 tsutsui Exp $      */
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
@@ -26,18 +26,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: console.c,v 1.7 2004/01/07 12:43:43 cdi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: console.c,v 1.8 2004/08/29 16:14:15 tsutsui Exp $");
 
 #include <sys/param.h>
-#include <sys/user.h>
-#include <sys/uio.h>
 #include <sys/systm.h>
-#include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/conf.h>
-#include <sys/proc.h>
-#include <sys/tty.h>
-#include <sys/termios.h>
 
 #include <machine/bus.h>
 #include <machine/nvram.h>
@@ -45,71 +39,33 @@
 
 #include <dev/cons.h>
 
-#include <dev/ic/comreg.h>
-#include <dev/ic/comvar.h>
+#include <cobalt/dev/com_mainbusvar.h>
 
-#include "com.h"
+#include "com_mainbus.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, },
+#if NCOM_MAINBUS > 0
+       { com_mainbus_cnprobe, com_mainbus_cninit,
+           NULL, NULL, NULL, NULL, NULL, NULL, 0, CN_DEAD },
 #endif
 #if NNULLCONS > 0
-       { nullcnprobe, nullcninit },
+       { nullcnprobe, nullcninit,
+           NULL, NULL, NULL, NULL, NULL, NULL, 0, CN_DEAD },
 #endif
-       { 0 }
+       { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, CN_DEAD }
 };
 
-#if NCOM > 0
-#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
-
-void
-comcnprobe(cn)
-       struct consdev *cn;
-{
-       struct btinfo_flags *bi_flags;
-
-       /*
-        * 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.
-        *
-        * Note that if the kernel was booted with a boot loader,
-        * the latter *has* to provide a flag indicating whether console
-        * is present or not due to the reasons outlined above.
-        */
-       if ( (bi_flags = lookup_bootinfo(BTINFO_FLAGS)) == NULL) {
-               /* No boot information, probe console now */
-               console_present = *(volatile u_int32_t *)
-                                       MIPS_PHYS_TO_KSEG1(0x0020001c);
-       } else {
-               /* Get the value determined by the boot loader. */
-               console_present = bi_flags->bi_flags & BI_SERIAL_CONSOLE;
-       }
-
-       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()
 {
+       static int initted;
+
+       if (initted)
+               return;
+       initted = 1;
 
        cninit();
 }
diff -r 81107f925508 -r 23489a9e67df sys/arch/cobalt/conf/files.cobalt
--- a/sys/arch/cobalt/conf/files.cobalt Sun Aug 29 14:08:06 2004 +0000
+++ b/sys/arch/cobalt/conf/files.cobalt Sun Aug 29 16:14:15 2004 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.cobalt,v 1.19 2003/10/17 18:20:10 cdi Exp $
+#      $NetBSD: files.cobalt,v 1.20 2004/08/29 16:14:15 tsutsui Exp $
 
 maxpartitions 16
 
@@ -13,7 +13,7 @@
 file arch/cobalt/cobalt/cpu.c          cpu
 
 attach com at mainbus with com_mainbus
-file arch/cobalt/dev/com_mainbus.c     com_mainbus
+file arch/cobalt/dev/com_mainbus.c     com_mainbus     needs-flag
 
 device panel: hd44780
 attach panel at mainbus
diff -r 81107f925508 -r 23489a9e67df sys/arch/cobalt/dev/com_mainbus.c
--- a/sys/arch/cobalt/dev/com_mainbus.c Sun Aug 29 14:08:06 2004 +0000
+++ b/sys/arch/cobalt/dev/com_mainbus.c Sun Aug 29 16:14:15 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: com_mainbus.c,v 1.8 2003/10/17 18:20:10 cdi Exp $      */
+/*     $NetBSD: com_mainbus.c,v 1.9 2004/08/29 16:14:15 tsutsui Exp $  */
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
@@ -26,31 +26,23 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.8 2003/10/17 18:20:10 cdi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.9 2004/08/29 16:14:15 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/ioctl.h>
-#include <sys/select.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/conf.h>
-#include <sys/file.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/syslog.h>
-#include <sys/types.h>
 #include <sys/device.h>
+#include <sys/termios.h>
 
 #include <machine/autoconf.h>
 #include <machine/intr.h>
 #include <machine/bus.h>
 #include <machine/nvram.h>
+#include <machine/bootinfo.h>
 
 #include <dev/ic/comreg.h>
 #include <dev/ic/comvar.h>
 
+#include <cobalt/dev/com_mainbusvar.h>
 
 extern int console_present;
 
@@ -59,6 +51,9 @@
        void *sc_ih;
 };
 
+#define COM_MAINBUS_FREQ       (COM_FREQ * 10)
+#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
+
 static int     com_mainbus_probe(struct device *, struct cfdata *, void *);
 static void    com_mainbus_attach(struct device *, struct device *, void *);
 
@@ -66,35 +61,34 @@
     com_mainbus_probe, com_mainbus_attach, NULL, NULL);
 
 int
-com_mainbus_probe(parent, match, aux)
-       struct device *parent;
-       struct cfdata *match;
-       void *aux;
+com_mainbus_probe(struct device *parent, struct cfdata *match, void *aux)
 {
 
-       return (console_present != 0);
+       return console_present != 0;
 }
 
-struct com_softc *com0; /* XXX */
-
 void
-com_mainbus_attach(parent, self, aux)
-       struct device *parent;
-       struct device *self;
-       void *aux;
+com_mainbus_attach(struct device *parent, struct device *self, void *aux)
 {
        struct com_mainbus_softc *msc = (void *)self;
        struct com_softc *sc = &msc->sc_com;
        struct mainbus_attach_args *maa = aux;
 
-       sc->sc_ioh = maa->ma_ioh;
        sc->sc_iot = maa->ma_iot;
        sc->sc_iobase = maa->ma_addr;
 
-       sc->sc_frequency = COM_FREQ * 10;
+#if 0  /* XXX */
+       if (!com_is_console(sc->sc_iot, sc->sc_iobase, &sc->sc_ioh) &&
+           bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS, 0,
+           &sc->sc_ioh)) {
+               printf(": can't map i/o space\n");
+               return;
+       }
+#else
+       sc->sc_ioh = maa->ma_ioh;
+#endif
 
-       /* XXX console check */
-       /* XXX map */
+       sc->sc_frequency = COM_MAINBUS_FREQ;
 
        com_attach_subr(sc);
 
@@ -102,3 +96,39 @@
 
        return;
 }
+
+void
+com_mainbus_cnprobe(struct consdev *cn)
+{
+       struct btinfo_flags *bi_flags;
+
+       /*
+        * 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.
+        *
+        * Note that if the kernel was booted with a boot loader,
+        * the latter *has* to provide a flag indicating whether console
+        * is present or not because the value might be overwritten by
+        * the loaded kernel.
+        */
+       if ((bi_flags = lookup_bootinfo(BTINFO_FLAGS)) == NULL) {
+               /* No boot information, probe console now */
+               console_present = *(volatile u_int32_t *)
+                                       MIPS_PHYS_TO_KSEG1(0x0020001c);
+       } else {
+               /* Get the value determined by the boot loader. */
+               console_present = bi_flags->bi_flags & BI_SERIAL_CONSOLE;
+       }
+
+       cn->cn_pri = (console_present != 0) ? CN_NORMAL : CN_DEAD;
+}
+
+void
+com_mainbus_cninit(struct consdev *cn)
+{
+
+       comcnattach(0, 0x1c800000, 115200, COM_MAINBUS_FREQ, COM_TYPE_NORMAL,
+           CONMODE);
+}
diff -r 81107f925508 -r 23489a9e67df sys/arch/cobalt/dev/com_mainbusvar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/cobalt/dev/com_mainbusvar.h      Sun Aug 29 16:14:15 2004 +0000
@@ -0,0 +1,31 @@
+/*     $NetBSD: com_mainbusvar.h,v 1.1 2004/08/29 16:14:15 tsutsui Exp $       */
+
+/*
+ * Copyright (c) 2000 Soren S. Jorvang.  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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL



Home | Main Index | Thread Index | Old Index