summaryrefslogtreecommitdiffstats
path: root/sys/alpha/isa
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-04-16 21:22:55 +0000
committerpeter <peter@FreeBSD.org>1999-04-16 21:22:55 +0000
commit087d4857e56f150a8f549600150404f273efb895 (patch)
treecf4e27432c59d956f4e5784207180115ee8fef9d /sys/alpha/isa
parentc5fe612b8411a32a8e6e426fc1a70cba0cca3d31 (diff)
downloadFreeBSD-src-087d4857e56f150a8f549600150404f273efb895.zip
FreeBSD-src-087d4857e56f150a8f549600150404f273efb895.tar.gz
Bring the 'new-bus' to the i386. This extensively changes the way the
i386 platform boots, it is no longer ISA-centric, and is fully dynamic. Most old drivers compile and run without modification via 'compatability shims' to enable a smoother transition. eisa, isapnp and pccard* are not yet using the new resource manager. Once fully converted, all drivers will be loadable, including PCI and ISA. (Some other changes appear to have snuck in, including a port of Soren's ATA driver to the Alpha. Soren, back this out if you need to.) This is a checkpoint of work-in-progress, but is quite functional. The bulk of the work was done over the last few years by Doug Rabson and Garrett Wollman. Approved by: core
Diffstat (limited to 'sys/alpha/isa')
-rw-r--r--sys/alpha/isa/isa.c89
-rw-r--r--sys/alpha/isa/isavar.h39
2 files changed, 98 insertions, 30 deletions
diff --git a/sys/alpha/isa/isa.c b/sys/alpha/isa/isa.c
index 56df551..5b6b54e 100644
--- a/sys/alpha/isa/isa.c
+++ b/sys/alpha/isa/isa.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: isa.c,v 1.8 1998/11/28 09:55:16 dfr Exp $
+ * $Id: isa.c,v 1.9 1999/01/23 16:53:27 dfr Exp $
*/
#include <sys/param.h>
@@ -31,11 +31,13 @@
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
+#include <machine/bus.h>
#include <sys/malloc.h>
#include <sys/rman.h>
#include <isa/isareg.h>
#include <isa/isavar.h>
+#include <alpha/isa/isavar.h>
#include <machine/intr.h>
#include <machine/intrcnt.h>
#include <machine/resource.h>
@@ -78,10 +80,6 @@ static struct resource *isa_alloc_resource(device_t bus, device_t child,
u_long count, u_int flags);
static int isa_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r);
-static int isa_setup_intr(device_t dev, device_t child, struct resource *irq,
- driver_intr_t *intr, void *arg, void **cookiep);
-static int isa_teardown_intr(device_t dev, device_t child,
- struct resource *irq, void *cookie);
static device_method_t isa_methods[] = {
/* Device interface */
@@ -139,7 +137,7 @@ isa_add_device(device_t dev, const char *name, int unit)
idev->id_portsize[0] = 0;
idev->id_portsize[1] = 0;
- if (resource_int_value(name, unit, "iomem", &t) == 0)
+ if (resource_int_value(name, unit, "maddr", &t) == 0)
idev->id_maddr[0] = t;
else
idev->id_maddr[0] = 0;
@@ -236,6 +234,8 @@ isa_probe(device_t dev)
{
int i;
+ device_set_desc(dev, "ISA bus");
+
/*
* Add all devices configured to be attached to isa0.
*/
@@ -256,14 +256,7 @@ isa_probe(device_t dev)
resource_query_unit(i));
}
- isa_irq_rman.rm_start = 0;
- isa_irq_rman.rm_end = 15;
- isa_irq_rman.rm_type = RMAN_ARRAY;
- isa_irq_rman.rm_descr = "ISA Interrupt request lines";
- if (rman_init(&isa_irq_rman)
- || rman_manage_region(&isa_irq_rman, 0, 1)
- || rman_manage_region(&isa_irq_rman, 3, 15))
- panic("isa_probe isa_irq_rman");
+ isa_init_intr();
return 0;
}
@@ -276,13 +269,6 @@ isa_attach(device_t dev)
if (bootverbose)
printf("isa_attach: mask=%04x\n", isa_irq_mask());
- /* mask all isa interrupts */
- outb(IO_ICU1+1, 0xff);
- outb(IO_ICU2+1, 0xff);
-
- /* make sure chaining irq is enabled */
- isa_intr_enable(2);
-
/*
* Arrange for bus_generic_attach(dev) to be called later.
*/
@@ -340,12 +326,14 @@ isa_print_child(device_t bus, device_t dev)
printf("-%#x", (u_int)(id->id_maddr[1]
+ id->id_msize[1] - 1));
}
+#if 0
if (id->id_irq[0] >= 0 && id->id_irq[1] >= 0)
printf(" irqs %d and %d", id->id_irq[0], id->id_irq[1]);
else if (id->id_irq[0] >= 0)
printf(" irq %d", id->id_irq[0]);
else if (id->id_irq[1] >= 0)
printf(" irq %d", id->id_irq[1]);
+#endif
if (id->id_drq[0] >= 0 && id->id_drq[1] >= 0)
printf(" drqs %d and %d", id->id_drq[0], id->id_drq[1]);
else if (id->id_drq[0] >= 0)
@@ -406,8 +394,10 @@ isa_read_ivar(device_t bus, device_t dev,
case ISA_IVAR_FLAGS:
*result = idev->id_flags;
break;
+ default:
+ return (ENOENT);
}
- return ENOENT;
+ return (0);
}
static int
@@ -462,6 +452,43 @@ isa_write_ivar(device_t bus, device_t dev,
return (0);
}
+void isa_init_intr(void)
+{
+ static int initted = 0;
+
+ if (initted) return;
+ initted = 1;
+
+ isa_irq_rman.rm_start = 0;
+ isa_irq_rman.rm_end = 15;
+ isa_irq_rman.rm_type = RMAN_ARRAY;
+ isa_irq_rman.rm_descr = "ISA Interrupt request lines";
+ if (rman_init(&isa_irq_rman)
+ || rman_manage_region(&isa_irq_rman, 0, 1)
+ || rman_manage_region(&isa_irq_rman, 3, 15))
+ panic("isa_probe isa_irq_rman");
+
+ /* mask all isa interrupts */
+ outb(IO_ICU1+1, 0xff);
+ outb(IO_ICU2+1, 0xff);
+
+ /* make sure chaining irq is enabled */
+ isa_intr_enable(2);
+}
+
+struct resource *
+isa_alloc_intr(device_t bus, device_t child, int irq)
+{
+ return rman_reserve_resource(&isa_irq_rman, irq, irq, 1,
+ 0, child);
+}
+
+int
+isa_release_intr(device_t bus, device_t child, struct resource *r)
+{
+ return rman_release_resource(r);
+}
+
/*
* This implementation simply passes the request up to the parent
* bus, which in our case is the pci chipset device, substituting any
@@ -502,7 +529,7 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
* The hack implementation of intr_create() passes a
* NULL child device.
*/
- if (isdefault && (id == NULL || id->id_irq[0] >= 0)) {
+ if (isdefault && id && id->id_irq[0] >= 0) {
start = id->id_irq[0];
end = id->id_irq[0];
count = 1;
@@ -576,7 +603,6 @@ isa_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
int rv;
- struct resource **rp;
struct isa_device *id = DEVTOISA(child);
if (rid > 1)
@@ -595,7 +621,7 @@ isa_release_resource(device_t bus, device_t child, int type, int rid,
rv = BUS_RELEASE_RESOURCE(device_get_parent(bus), child, type, rid, r);
- if (rv) {
+ if (rv == 0) {
switch (type) {
case SYS_RES_IRQ:
id->id_irqres[rid] = 0;
@@ -652,7 +678,7 @@ isa_handle_intr(void *arg)
outb(IO_ICU1, 0x20 | (irq > 7 ? 2 : irq));
}
-static int
+int
isa_setup_intr(device_t dev, device_t child,
struct resource *irq,
driver_intr_t *intr, void *arg, void **cookiep)
@@ -681,10 +707,15 @@ isa_setup_intr(device_t dev, device_t child,
isa_intr_enable(irq->r_start);
*cookiep = ii;
+
+ if (child)
+ device_printf(child, "interrupting at ISA irq %d\n",
+ (int)irq->r_start);
+
return 0;
}
-static int
+int
isa_teardown_intr(device_t dev, device_t child,
struct resource *irq, void *cookie)
{
@@ -696,6 +727,4 @@ isa_teardown_intr(device_t dev, device_t child,
return 0;
}
-DRIVER_MODULE(isa, cia, isa_driver, isa_devclass, 0, 0);
-DRIVER_MODULE(isa, apecs, isa_driver, isa_devclass, 0, 0);
-DRIVER_MODULE(isa, lca, isa_driver, isa_devclass, 0, 0);
+DRIVER_MODULE(isa, isab, isa_driver, isa_devclass, 0, 0);
diff --git a/sys/alpha/isa/isavar.h b/sys/alpha/isa/isavar.h
new file mode 100644
index 0000000..ce0e8ce
--- /dev/null
+++ b/sys/alpha/isa/isavar.h
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 1998 Doug Rabson
+ * 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
+ * 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.
+ *
+ * $Id$
+ */
+
+/*
+ * Export low-level interrupt handling code for chipsets which route
+ * interrupts via the ISA interrupt controller.
+ */
+void isa_init_intr(void);
+struct resource *isa_alloc_intr(device_t bus, device_t child, int irq);
+int isa_release_intr(device_t bus, device_t child, struct resource *r);
+int isa_setup_intr(device_t dev, device_t child, struct resource *irq,
+ driver_intr_t *intr, void *arg, void **cookiep);
+int isa_teardown_intr(device_t dev, device_t child, struct resource *irq,
+ void *cookie);
OpenPOWER on IntegriCloud