summaryrefslogtreecommitdiff
path: root/sys/dev/isa/isa.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /sys/dev/isa/isa.c
initial import of NetBSD tree
Diffstat (limited to 'sys/dev/isa/isa.c')
-rw-r--r--sys/dev/isa/isa.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/sys/dev/isa/isa.c b/sys/dev/isa/isa.c
new file mode 100644
index 00000000000..799bf2fb2f9
--- /dev/null
+++ b/sys/dev/isa/isa.c
@@ -0,0 +1,106 @@
+/* $NetBSD: isa.c,v 1.74 1995/06/07 06:46:04 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1993, 1994 Charles Hannum. 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 Charles Hannum.
+ * 4. 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.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+
+int
+isaprint(aux, isa)
+ void *aux;
+ char *isa;
+{
+ struct isa_attach_args *ia = aux;
+
+ if (ia->ia_iosize)
+ printf(" port 0x%x", ia->ia_iobase);
+ if (ia->ia_iosize > 1)
+ printf("-0x%x", ia->ia_iobase + ia->ia_iosize - 1);
+ if (ia->ia_msize)
+ printf(" iomem 0x%x", ia->ia_maddr);
+ if (ia->ia_msize > 1)
+ printf("-0x%x", ia->ia_maddr + ia->ia_msize - 1);
+ if (ia->ia_irq != IRQUNK)
+ printf(" irq %d", ia->ia_irq);
+ if (ia->ia_drq != DRQUNK)
+ printf(" drq %d", ia->ia_drq);
+ return (UNCONF);
+}
+
+void
+isascan(parent, match)
+ struct device *parent;
+ void *match;
+{
+ struct device *dev = match;
+ struct cfdata *cf = dev->dv_cfdata;
+ struct isa_attach_args ia;
+
+ if (cf->cf_fstate == FSTATE_STAR)
+ panic("not bloody likely");
+
+ ia.ia_iobase = cf->cf_loc[0];
+ ia.ia_iosize = 0x666;
+ ia.ia_maddr = cf->cf_loc[2];
+ ia.ia_msize = cf->cf_loc[3];
+ ia.ia_irq = cf->cf_loc[4] == 2 ? 9 : cf->cf_loc[4];
+ ia.ia_drq = cf->cf_loc[5];
+
+ if ((*cf->cf_driver->cd_match)(parent, dev, &ia) > 0)
+ config_attach(parent, dev, &ia, isaprint);
+ else
+ free(dev, M_DEVBUF);
+}
+
+char *
+isa_intr_typename(type)
+ isa_intrtype type;
+{
+
+ switch (type) {
+ case ISA_IST_NONE :
+ return ("none");
+ case ISA_IST_PULSE:
+ return ("pulsed");
+ case ISA_IST_EDGE:
+ return ("edge-triggered");
+ case ISA_IST_LEVEL:
+ return ("level-triggered");
+ default:
+ panic("isa_intr_typename: invalid type %d", type);
+ }
+}