diff options
author | 2001-09-29 23:26:07 +0000 | |
---|---|---|
committer | 2001-09-29 23:26:07 +0000 | |
commit | a1d124a6f8e543fd940e574c36a8d39d170cce59 (patch) | |
tree | 73ed4e75a8c7ab568792faceba0a92315bc7f35d | |
parent | alright, do not print quality and noise for cache; pr#2063 (diff) | |
download | wireguard-openbsd-a1d124a6f8e543fd940e574c36a8d39d170cce59.tar.xz wireguard-openbsd-a1d124a6f8e543fd940e574c36a8d39d170cce59.zip |
Next step in making the com driver improvable.
Split out the com at isa attachment into its own file.
-rw-r--r-- | sys/dev/ic/com.c | 95 | ||||
-rw-r--r-- | sys/dev/isa/com_isa.c | 181 | ||||
-rw-r--r-- | sys/dev/isa/files.isa | 3 |
3 files changed, 199 insertions, 80 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 57c04f0b8ae..683371fb5d6 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.67 2001/09/29 03:07:57 art Exp $ */ +/* $OpenBSD: com.c,v 1.68 2001/09/29 23:26:07 art Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -103,7 +103,7 @@ #include "com.h" -#if NCOM_ISA || NCOM_ISAPNP +#if NCOM_ISAPNP #include <dev/isa/isavar.h> /* XXX */ #endif @@ -122,12 +122,6 @@ void comattach __P((struct device *, struct device *, void *)); void compwroff __P((struct com_softc *)); void com_raisedtr __P((void *)); -#if NCOM_ISA -struct cfattach com_isa_ca = { - sizeof(struct com_softc), comprobe, comattach -}; -#endif - #if NCOM_ISAPNP struct cfattach com_isapnp_ca = { sizeof(struct com_softc), comprobe, comattach @@ -148,11 +142,7 @@ struct cfdriver com_cd = { #define CONSPEED B9600 #endif -#ifdef COMCONSOLE -int comdefaultrate = CONSPEED; /* XXX why set default? */ -#else int comdefaultrate = TTYDEF_SPEED; -#endif int comconsaddr; int comconsinit; int comconsattached; @@ -184,13 +174,6 @@ void com_kgdb_putc __P((void *, int)); #define ISSET(t, f) ((t) & (f)) /* Macros for determining bus type. */ -#if NCOM_ISA -#define IS_ISA(parent) \ - (strcmp((parent)->dv_cfdata->cf_driver->cd_name, "isa") == 0) -#else -#define IS_ISA(parent) 0 -#endif - #if NCOM_ISAPNP #define IS_ISAPNP(parent) \ (strcmp((parent)->dv_cfdata->cf_driver->cd_name, "isapnp") == 0) @@ -319,7 +302,7 @@ comprobe(parent, match, aux) { bus_space_tag_t iot; bus_space_handle_t ioh; - int iobase, needioh; + int iobase; int rv = 1; /* @@ -327,17 +310,13 @@ comprobe(parent, match, aux) * XXX for commulti probe, with a helper function that contains * XXX most of the interesting stuff. */ -#if NCOM_ISA || NCOM_ISAPNP - if (IS_ISA(parent) || IS_ISAPNP(parent)) { +#if NCOM_ISAPNP + if (IS_ISAPNP(parent)) { struct isa_attach_args *ia = aux; iot = ia->ia_iot; iobase = ia->ia_iobase; - if (IS_ISAPNP(parent)) { - ioh = ia->ia_ioh; - needioh = 0; - } else - needioh = 1; + ioh = ia->ia_ioh; } else #endif #if NCOM_COMMULTI @@ -351,7 +330,6 @@ comprobe(parent, match, aux) iot = ca->ca_iot; iobase = ca->ca_iobase; ioh = ca->ca_ioh; - needioh = 0; } else #endif return(0); /* This cannot happen */ @@ -364,23 +342,8 @@ comprobe(parent, match, aux) if (iobase == comconsaddr && !comconsattached) goto out; - if (needioh && bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) { - rv = 0; - goto out; - } rv = comprobe1(iot, ioh); - if (needioh) - bus_space_unmap(iot, ioh, COM_NPORTS); - out: -#if NCOM_ISA - if (rv && IS_ISA(parent)) { - struct isa_attach_args *ia = aux; - - ia->ia_iosize = COM_NPORTS; - ia->ia_msize = 0; - } -#endif return (rv); } @@ -391,7 +354,7 @@ comattach(parent, self, aux) { struct com_softc *sc = (void *)self; int iobase; -#if NCOM_ISA || NCOM_ISAPNP || NCOM_COMMULTI +#if NCOM_ISAPNP || NCOM_COMMULTI int irq; #endif bus_space_tag_t iot; @@ -408,8 +371,8 @@ comattach(parent, self, aux) */ sc->sc_hwflags = 0; sc->sc_swflags = 0; -#if NCOM_ISA || NCOM_ISAPNP - if (IS_ISA(parent) || IS_ISAPNP(parent)) { +#if NCOM_ISAPNP + if (IS_ISAPNP(parent)) { struct isa_attach_args *ia = aux; /* @@ -417,30 +380,8 @@ comattach(parent, self, aux) */ iobase = ia->ia_iobase; iot = ia->ia_iot; - if (IS_ISAPNP(parent)) { - /* No console support! */ - ioh = ia->ia_ioh; - } else { -#ifdef KGDB - if ((iobase != comconsaddr) && - (iobase != com_kgdb_addr)) { -#else - if (iobase != comconsaddr) { -#endif - if (bus_space_map(iot, iobase, COM_NPORTS, 0, - &ioh)) - panic("comattach: io mapping failed"); - } else -#ifdef KGDB - if (iobase == comconsaddr) { - ioh = comconsioh; - } else { - ioh = com_kgdb_ioh; - } -#else - ioh = comconsioh; -#endif - } + /* No console support! */ + ioh = ia->ia_ioh; irq = ia->ia_irq; } else #endif @@ -461,10 +402,10 @@ comattach(parent, self, aux) } else #endif panic("comattach: impossible"); -#if NCOM_ISA || NCOM_ISAPNP || NCOM_COMMULTI +#if NCOM_ISAPNP || NCOM_COMMULTI if (irq != IRQUNK) { -#if NCOM_ISA || NCOM_ISAPNP - if (IS_ISA(parent) || IS_ISAPNP(parent)) { +#if NCOM_ISAPNP + if (IS_ISAPNP(parent)) { struct isa_attach_args *ia = aux; #ifdef KGDB @@ -670,7 +611,6 @@ com_attach_subr(sc) } #endif /* KGDB */ - /* XXX maybe move up some? */ if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) { int maj; @@ -701,6 +641,7 @@ com_attach_subr(sc) */ if (!sc->enable) sc->enabled = 1; + } #ifdef KGDB @@ -1869,11 +1810,7 @@ comcnprobe(cp) /* initialize required fields */ cp->cn_dev = makedev(commajor, CONUNIT); -#ifdef COMCONSOLE - cp->cn_pri = CN_REMOTE; /* Force a serial port console */ -#else cp->cn_pri = CN_NORMAL; -#endif } /* @@ -2014,8 +1951,8 @@ comcnputc(dev, c) cominit(iot, ioh, comdefaultrate); comconsinit = 1; } - com_common_putc(comconsiot, comconsioh, c); + com_common_putc(comconsiot, comconsioh, c); } void diff --git a/sys/dev/isa/com_isa.c b/sys/dev/isa/com_isa.c new file mode 100644 index 00000000000..bc98941daa1 --- /dev/null +++ b/sys/dev/isa/com_isa.c @@ -0,0 +1,181 @@ +/* $OpenBSD: com_isa.c,v 1.1 2001/09/29 23:26:07 art Exp $ */ +/* + * Copyright (c) 1997 - 1999, Jason Downs. 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. Neither the name(s) of the author(s) nor the name OpenBSD + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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. + */ +/*- + * Copyright (c) 1993, 1994, 1995, 1996 + * Charles M. Hannum. All rights reserved. + * Copyright (c) 1991 The Regents of the University of California. + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)com.c 7.5 (Berkeley) 5/16/91 + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/tty.h> +#include <sys/device.h> + +#include <machine/intr.h> +#include <machine/bus.h> + +#include <dev/ic/comreg.h> +#include <dev/ic/comvar.h> + +#include <dev/isa/isavar.h> + +int com_isa_probe(struct device *, void *, void *); +void com_isa_attach(struct device *, struct device *, void *); + +struct cfattach com_isa_ca = { + sizeof(struct com_softc), com_isa_probe, com_isa_attach +}; + +int +com_isa_probe(struct device *parent, void *match, void *aux) +{ + struct isa_attach_args *ia = aux; + bus_space_handle_t ioh; + bus_space_tag_t iot; + int iobase; + int rv; + + iot = ia->ia_iot; + iobase = ia->ia_iobase; + +#ifdef KGDB + if (iobase == com_kgdb_addr) + goto out; +#endif + if (iobase == comconsaddr && !comconsattached) + goto out; + + if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) + return (0); + + rv = comprobe1(iot, ioh); + + bus_space_unmap(iot, ioh, COM_NPORTS); + + if (rv == 0) + return (0); + +out: + ia->ia_iosize = COM_NPORTS; + ia->ia_msize = 0; + return (1); +} + +void +com_isa_attach(struct device *parent, struct device *self, void *aux) +{ + struct com_softc *sc = (struct com_softc *)self; + struct isa_attach_args *ia = aux; + bus_space_handle_t ioh; + bus_space_tag_t iot; + int iobase, irq; + + sc->sc_hwflags = 0; + sc->sc_swflags = 0; + + iobase = ia->ia_iobase; + iot = ia->ia_iot; + +#ifdef KGBD + if ((iobase != comconsaddr) && + (iobase != com_kgdb_addr)) { +#else + if (iobase != comconsaddr) { +#endif + if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) + panic("com_isa_attach: mapping failed"); + } else { +#ifdef KGDB + if (iobase == comconsaddr) + ioh = comconsioh; + else + ioh = com_kgdb_ioh; +#else + ioh = comconsioh; +#endif + } + + sc->sc_iot = iot; + sc->sc_ioh = ioh; + sc->sc_iobase = iobase; + sc->sc_frequency = COM_FREQ; + + com_attach_subr(sc); + + irq = ia->ia_irq; + if (irq != IRQUNK) { +#ifdef KGDB + if (iobase == com_kgdb_addr) { + sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, + IST_EDGE, IPL_HIGH, kgdbintr, sc, + sc->sc_dev.dv_xname); + } else { + sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, + IST_EDGE, IPL_TTY, comintr, sc, + sc->sc_dev.dv_xname); + } +#else + sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, + IST_EDGE, IPL_TTY, comintr, sc, + sc->sc_dev.dv_xname); +#endif /* KGDB */ + } +} + diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index be99af75704..8927183bdb3 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $OpenBSD: files.isa,v 1.68 2001/08/03 15:15:09 mickey Exp $ +# $OpenBSD: files.isa,v 1.69 2001/09/29 23:26:07 art Exp $ # $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $ # # Config file and device description for machine-independent ISA code. @@ -60,6 +60,7 @@ file dev/isa/hsq.c hsq # 8250/16[45]50-based "com" ports attach com at isa with com_isa +file dev/isa/com_isa.c com_isa attach com at commulti with com_commulti # Cyclades Cyclom multiport serial cards |