summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-09-30 00:11:58 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-09-30 00:11:58 +0000
commit185b17d417957f47ead744896282f7b6ac12f65f (patch)
tree08b0d0bd5e86547bcf2bfc97c3323546f22a7697 /sys
parentbfa6766484a4d0964712c90859f90507798e9e48 (diff)
Move out com at isapnp attachment into an own file.
Not tested because the only system with isapnp is i386 and i386 uses pccom.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/com.c99
-rw-r--r--sys/dev/isa/com_isapnp.c162
2 files changed, 169 insertions, 92 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 683371fb5d6..87ca6082a42 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com.c,v 1.68 2001/09/29 23:26:07 art Exp $ */
+/* $OpenBSD: com.c,v 1.69 2001/09/30 00:11:57 art Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*
@@ -103,10 +103,6 @@
#include "com.h"
-#if NCOM_ISAPNP
-#include <dev/isa/isavar.h> /* XXX */
-#endif
-
/* XXX: These belong elsewhere */
cdev_decl(com);
bdev_decl(com);
@@ -122,12 +118,6 @@ void comattach __P((struct device *, struct device *, void *));
void compwroff __P((struct com_softc *));
void com_raisedtr __P((void *));
-#if NCOM_ISAPNP
-struct cfattach com_isapnp_ca = {
- sizeof(struct com_softc), comprobe, comattach
-};
-#endif
-
#if NCOM_COMMULTI
struct cfattach com_commulti_ca = {
sizeof(struct com_softc), comprobe, comattach
@@ -173,14 +163,6 @@ void com_kgdb_putc __P((void *, int));
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
-/* Macros for determining bus type. */
-#if NCOM_ISAPNP
-#define IS_ISAPNP(parent) \
- (strcmp((parent)->dv_cfdata->cf_driver->cd_name, "isapnp") == 0)
-#else
-#define IS_ISAPNP(parent) 0
-#endif
-
int
comspeed(freq, speed)
long freq;
@@ -305,20 +287,6 @@ comprobe(parent, match, aux)
int iobase;
int rv = 1;
- /*
- * XXX should be broken out into functions for isa probe and
- * XXX for commulti probe, with a helper function that contains
- * XXX most of the interesting stuff.
- */
-#if NCOM_ISAPNP
- if (IS_ISAPNP(parent)) {
- struct isa_attach_args *ia = aux;
-
- iot = ia->ia_iot;
- iobase = ia->ia_iobase;
- ioh = ia->ia_ioh;
- } else
-#endif
#if NCOM_COMMULTI
if (1) {
struct cfdata *cf = match;
@@ -354,11 +322,9 @@ comattach(parent, self, aux)
{
struct com_softc *sc = (void *)self;
int iobase;
-#if NCOM_ISAPNP || NCOM_COMMULTI
- int irq;
-#endif
bus_space_tag_t iot;
bus_space_handle_t ioh;
+ struct commulti_attach_args *ca = aux;
#ifdef COM_HAYESP
int hayesp_ports[] = { 0x140, 0x180, 0x280, 0x300, 0 };
int *hayespp;
@@ -371,63 +337,12 @@ comattach(parent, self, aux)
*/
sc->sc_hwflags = 0;
sc->sc_swflags = 0;
-#if NCOM_ISAPNP
- if (IS_ISAPNP(parent)) {
- struct isa_attach_args *ia = aux;
-
- /*
- * We're living on an isa.
- */
- iobase = ia->ia_iobase;
- iot = ia->ia_iot;
- /* No console support! */
- ioh = ia->ia_ioh;
- irq = ia->ia_irq;
- } else
-#endif
-#if NCOM_COMMULTI
- if (1) {
- struct commulti_attach_args *ca = aux;
-
- /*
- * We're living on a commulti.
- */
- iobase = ca->ca_iobase;
- iot = ca->ca_iot;
- ioh = ca->ca_ioh;
- irq = IRQUNK;
+ iobase = ca->ca_iobase;
+ iot = ca->ca_iot;
+ ioh = ca->ca_ioh;
- if (ca->ca_noien)
- SET(sc->sc_hwflags, COM_HW_NOIEN);
- } else
-#endif
- panic("comattach: impossible");
-#if NCOM_ISAPNP || NCOM_COMMULTI
- if (irq != IRQUNK) {
-#if NCOM_ISAPNP
- if (IS_ISAPNP(parent)) {
- struct isa_attach_args *ia = aux;
-
-#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 */
- } else
-#endif
- panic("comattach: IRQ but can't have one");
- }
-#endif
+ if (ca->ca_noien)
+ SET(sc->sc_hwflags, COM_HW_NOIEN);
sc->sc_iot = iot;
sc->sc_ioh = ioh;
diff --git a/sys/dev/isa/com_isapnp.c b/sys/dev/isa/com_isapnp.c
new file mode 100644
index 00000000000..06be144017d
--- /dev/null
+++ b/sys/dev/isa/com_isapnp.c
@@ -0,0 +1,162 @@
+/* $OpenBSD: com_isapnp.c,v 1.1 2001/09/30 00:11:57 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>
+
+#if NCOM_ISAPNP
+struct cfattach com_isapnp_ca = {
+ sizeof(struct com_softc), comprobe, comattach
+};
+#endif
+
+int com_isapnp_probe(struct device *, void *, void *);
+int com_isapnp_attach(struct device *, struct device *, void *);
+
+int
+com_isapnp_probe(struct device *parent, void *match, void *aux)
+{
+ struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+ int iobase;
+
+ iot = ia->ia_iot;
+ iobase = ia->ia_iobase;
+ ioh = ia->ia_ioh;
+
+#ifdef KGDB
+ if (iobase == com_kgdb_addr)
+ return (1);
+#endif
+ /* if it's in use as console, it's there. */
+ if (iobase == comconsaddr && !comconsattached)
+ return (1);
+
+ return comprobe1(iot, ioh);
+}
+
+int
+com_isapnp_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct com_softc *sc = (void *)self;
+ int iobase;
+ int irq;
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+ struct isa_attach_args *ia = aux;
+
+ /*
+ * XXX should be broken out into functions for isa attach and
+ * XXX for commulti attach, with a helper function that contains
+ * XXX most of the interesting stuff.
+ */
+ sc->sc_hwflags = 0;
+ sc->sc_swflags = 0;
+
+ /*
+ * We're living on an isa.
+ */
+ iobase = ia->ia_iobase;
+ iot = ia->ia_iot;
+ /* No console support! */
+ ioh = ia->ia_ioh;
+
+ 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 */
+ }
+}