diff options
author | peter <peter@FreeBSD.org> | 1999-04-16 21:22:55 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-04-16 21:22:55 +0000 |
commit | 087d4857e56f150a8f549600150404f273efb895 (patch) | |
tree | cf4e27432c59d956f4e5784207180115ee8fef9d /sys/alpha | |
parent | c5fe612b8411a32a8e6e426fc1a70cba0cca3d31 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/alpha/alpha/autoconf.c | 4 | ||||
-rw-r--r-- | sys/alpha/conf/files.alpha | 12 | ||||
-rw-r--r-- | sys/alpha/include/chipset.h | 9 | ||||
-rw-r--r-- | sys/alpha/include/cpuconf.h | 1 | ||||
-rw-r--r-- | sys/alpha/include/cpufunc.h | 36 | ||||
-rw-r--r-- | sys/alpha/isa/isa.c | 89 | ||||
-rw-r--r-- | sys/alpha/isa/isavar.h | 39 | ||||
-rw-r--r-- | sys/alpha/pci/apecs.c | 66 | ||||
-rw-r--r-- | sys/alpha/pci/apecs_pci.c | 73 | ||||
-rw-r--r-- | sys/alpha/pci/cia.c | 15 | ||||
-rw-r--r-- | sys/alpha/pci/cia_pci.c | 73 | ||||
-rw-r--r-- | sys/alpha/pci/lca.c | 50 | ||||
-rw-r--r-- | sys/alpha/pci/lca_pci.c | 73 | ||||
-rw-r--r-- | sys/alpha/pci/pcibus.c | 78 | ||||
-rw-r--r-- | sys/alpha/tc/tc.c | 4 | ||||
-rw-r--r-- | sys/alpha/tc/tcasic.c | 3 | ||||
-rw-r--r-- | sys/alpha/tlsb/dwlpx.c | 4 |
17 files changed, 538 insertions, 91 deletions
diff --git a/sys/alpha/alpha/autoconf.c b/sys/alpha/alpha/autoconf.c index da47473..e5489c6 100644 --- a/sys/alpha/alpha/autoconf.c +++ b/sys/alpha/alpha/autoconf.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: autoconf.c,v 1.14 1999/03/12 14:44:46 gallatin Exp $ + * $Id: autoconf.c,v 1.15 1999/03/28 17:33:38 dfr Exp $ */ #include "opt_bootp.h" @@ -190,7 +190,7 @@ configure(void *dummy) if((hwrpb->rpb_type != ST_DEC_3000_300) && (hwrpb->rpb_type != ST_DEC_3000_500)){ - pci_configure(); + /* pci_configure(); */ /* * Probe ISA devices after everything. diff --git a/sys/alpha/conf/files.alpha b/sys/alpha/conf/files.alpha index 6f747e3..d0f4003 100644 --- a/sys/alpha/conf/files.alpha +++ b/sys/alpha/conf/files.alpha @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $Id: files.alpha,v 1.16 1999/01/23 16:53:26 dfr Exp $ +# $Id: files.alpha,v 1.17 1999/03/10 10:36:50 yokota Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -112,10 +112,13 @@ mcclock_if.h standard \ no-obj no-implicit-rule before-depend \ clean "mcclock_if.h" alpha/pci/cia.c optional cia +alpha/pci/cia_pci.c optional cia alpha/pci/pci_eb164_intr.s optional cia alpha/pci/apecs.c optional apecs +alpha/pci/apecs_pci.c optional apecs alpha/pci/pci_eb64plus_intr.s optional apecs alpha/pci/lca.c optional lca +alpha/pci/lca_pci.c optional lca alpha/pci/pcibus.c optional pci alpha/isa/isa.c optional isa alpha/isa/mcclock_isa.c optional isa @@ -157,3 +160,10 @@ dev/syscons/syscons.c optional sc device-driver dev/syscons/scvidctl.c optional sc device-driver isa/syscons_isa.c optional sc device-driver isa/psm.c optional psm device-driver +dev/ata/ata-all.c optional ata device-driver +dev/ata/ata-dma.c optional ata device-driver +dev/ata/atapi-all.c optional ata device-driver +dev/ata/ata-disk.c optional atadisk device-driver +dev/ata/atapi-cd.c optional atapicd device-driver +dev/ata/atapi-fd.c optional atapifd device-driver +dev/ata/atapi-tape.c optional atapist device-driver diff --git a/sys/alpha/include/chipset.h b/sys/alpha/include/chipset.h index f7a61be..66f59bb 100644 --- a/sys/alpha/include/chipset.h +++ b/sys/alpha/include/chipset.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chipset.h,v 1.5 1998/10/06 14:18:39 dfr Exp $ + * $Id: chipset.h,v 1.6 1998/11/15 18:25:16 dfr Exp $ */ #ifndef _MACHINE_CHIPSET_H_ @@ -100,13 +100,6 @@ typedef struct alpha_chipset { */ alpha_chipset_read_hae_t* read_hae; alpha_chipset_write_hae_t* write_hae; - - /* - * PCI interrupt device. - * (XXX hack until I change pci code to use new - * device framework.) - */ - void* intrdev; } alpha_chipset_t; extern alpha_chipset_t chipset; diff --git a/sys/alpha/include/cpuconf.h b/sys/alpha/include/cpuconf.h index 6bddc82..1965a5a 100644 --- a/sys/alpha/include/cpuconf.h +++ b/sys/alpha/include/cpuconf.h @@ -73,6 +73,7 @@ extern struct platform { void (*pci_intr_map) __P((void *)); void (*pci_intr_disable) __P((int)); void (*pci_intr_enable) __P((int)); + int (*pci_setup_ide_intr) __P((int chan, void (*fn)(void*), void *arg)); } platform; /* diff --git a/sys/alpha/include/cpufunc.h b/sys/alpha/include/cpufunc.h index bc4ffe3..8326970 100644 --- a/sys/alpha/include/cpufunc.h +++ b/sys/alpha/include/cpufunc.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cpufunc.h,v 1.2 1998/07/22 08:25:39 dfr Exp $ + * $Id: cpufunc.h,v 1.3 1998/08/17 08:21:31 dfr Exp $ */ #ifndef _MACHINE_CPUFUNC_H_ @@ -59,11 +59,45 @@ breakpoint(void) #define writel(pa,v) chipset.writel(pa,v) /* + * Bulk i/o (for IDE driver). + */ +static __inline void insw(u_int32_t port, void *buffer, size_t count) +{ + u_int16_t *p = (u_int16_t *) buffer; + while (count--) + *p++ = inw(port); +} + +static __inline void insl(u_int32_t port, void *buffer, size_t count) +{ + u_int32_t *p = (u_int32_t *) buffer; + while (count--) + *p++ = inl(port); +} + +static __inline void outsw(u_int32_t port, const void *buffer, size_t count) +{ + const u_int16_t *p = (const u_int16_t *) buffer; + while (count--) + outw(port, *p++); +} + +static __inline void outsl(u_int32_t port, const void *buffer, size_t count) +{ + const u_int32_t *p = (const u_int32_t *) buffer; + while (count--) + outl(port, *p++); +} + +/* * String version of IO memory access ops: */ extern void memcpy_fromio(void *, u_int32_t, size_t); extern void memcpy_toio(u_int32_t, void *, size_t); +extern void memcpy_io(u_int32_t, u_int32_t, size_t); extern void memset_io(u_int32_t, int, size_t); +extern void memsetw(void *, int, size_t); +extern void memsetw_io(u_int32_t, int, size_t); #endif /* KERNEL */ 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); diff --git a/sys/alpha/pci/apecs.c b/sys/alpha/pci/apecs.c index 66bedcf..fb86dc9 100644 --- a/sys/alpha/pci/apecs.c +++ b/sys/alpha/pci/apecs.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: apecs.c,v 1.4 1998/12/04 22:54:42 archie Exp $ + * $Id: apecs.c,v 1.5 1999/01/18 20:15:07 gallatin Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -60,12 +60,15 @@ #include <sys/kernel.h> #include <sys/module.h> #include <sys/bus.h> +#include <machine/bus.h> #include <sys/rman.h> #include <alpha/pci/apecsreg.h> #include <alpha/pci/apecsvar.h> #include <alpha/pci/pcibus.h> +#include <alpha/isa/isavar.h> #include <machine/intr.h> +#include <machine/resource.h> #include <machine/intrcnt.h> #include <machine/cpuconf.h> #include <machine/swiz.h> @@ -75,7 +78,6 @@ static devclass_t apecs_devclass; static device_t apecs0; /* XXX only one for now */ -static device_t isa0; struct apecs_softc { vm_offset_t dmem_base; /* dense memory */ @@ -442,18 +444,25 @@ apecs_write_hae(u_int64_t hae) static int apecs_probe(device_t dev); static int apecs_attach(device_t dev); +static struct resource *apecs_alloc_resource(device_t bus, device_t child, + int type, int *rid, u_long start, + u_long end, u_long count, + u_int flags); +static int apecs_release_resource(device_t bus, device_t child, + int type, int rid, struct resource *r); static int apecs_setup_intr(device_t dev, device_t child, struct resource *irq, driver_intr_t *intr, void *arg, void **cookiep); static int apecs_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie); + static device_method_t apecs_methods[] = { /* Device interface */ DEVMETHOD(device_probe, apecs_probe), DEVMETHOD(device_attach, apecs_attach), /* Bus interface */ - DEVMETHOD(bus_alloc_resource, pci_alloc_resource), - DEVMETHOD(bus_release_resource, pci_release_resource), + DEVMETHOD(bus_alloc_resource, apecs_alloc_resource), + DEVMETHOD(bus_release_resource, apecs_release_resource), DEVMETHOD(bus_activate_resource, pci_activate_resource), DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource), DEVMETHOD(bus_setup_intr, apecs_setup_intr), @@ -499,29 +508,19 @@ apecs_probe(device_t dev) apecs_hae_mem = REGVAL(EPIC_HAXR1); pci_init_resources(); + isa_init_intr(); - isa0 = device_add_child(dev, "isa", 0, 0); + device_add_child(dev, "pcib", 0, 0); return 0; } -extern void isa_intr(void* frame, u_long vector); - static int apecs_attach(device_t dev) { struct apecs_softc* sc = APECS_SOFTC(dev); apecs_init(); - /* - * the avanti routes interrupts through the isa interrupt - * controller, so we need to special case it - */ - if(hwrpb->rpb_type == ST_DEC_2100_A50) - chipset.intrdev = isa0; - else - chipset.intrdev = apecs0; - sc->dmem_base = APECS_PCI_DENSE; sc->smem_base = APECS_PCI_SPARSE; sc->io_base = APECS_PCI_SIO; @@ -541,6 +540,27 @@ apecs_attach(device_t dev) return 0; } +static struct resource * +apecs_alloc_resource(device_t bus, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + if (type == SYS_RES_IRQ) + return isa_alloc_intr(bus, child, start); + else + return pci_alloc_resource(bus, child, type, rid, + start, end, count, flags); +} + +static int +apecs_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + if (type == SYS_RES_IRQ) + return isa_release_intr(bus, child, r); + else + return pci_release_resource(bus, child, type, rid, r); +} + static int apecs_setup_intr(device_t dev, device_t child, struct resource *irq, @@ -548,6 +568,13 @@ apecs_setup_intr(device_t dev, device_t child, { int error; + /* + * the avanti routes interrupts through the isa interrupt + * controller, so we need to special case it + */ + if(hwrpb->rpb_type == ST_DEC_2100_A50) + return isa_setup_intr(dev, child, irq, intr, arg, cookiep); + error = rman_activate_resource(irq); if (error) return error; @@ -567,6 +594,13 @@ static int apecs_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie) { + /* + * the avanti routes interrupts through the isa interrupt + * controller, so we need to special case it + */ + if(hwrpb->rpb_type == ST_DEC_2100_A50) + return isa_teardown_intr(dev, child, irq, cookie); + alpha_teardown_intr(cookie); return rman_deactivate_resource(irq); } diff --git a/sys/alpha/pci/apecs_pci.c b/sys/alpha/pci/apecs_pci.c new file mode 100644 index 0000000..fb0b339 --- /dev/null +++ b/sys/alpha/pci/apecs_pci.c @@ -0,0 +1,73 @@ +/*- + * 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, SPEAPECSL, 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$ + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/bus.h> +#include <machine/bus.h> +#include <sys/rman.h> + +static devclass_t pcib_devclass; + +static int +apecs_pcib_probe(device_t dev) +{ + device_set_desc(dev, "2107x PCI host bus adapter"); + + device_add_child(dev, "pci", 0, 0); + + return 0; +} + +static device_method_t apecs_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, apecs_pcib_probe), + DEVMETHOD(device_attach, bus_generic_attach), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t apecs_pcib_driver = { + "pcib", + apecs_pcib_methods, + DRIVER_TYPE_MISC, + 1, +}; + +DRIVER_MODULE(pcib, apecs, apecs_pcib_driver, pcib_devclass, 0, 0); diff --git a/sys/alpha/pci/cia.c b/sys/alpha/pci/cia.c index 350df00..e967493 100644 --- a/sys/alpha/pci/cia.c +++ b/sys/alpha/pci/cia.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cia.c,v 1.14 1998/12/04 22:54:42 archie Exp $ + * $Id: cia.c,v 1.15 1999/03/28 17:52:17 dfr Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -96,6 +96,7 @@ #include <sys/kernel.h> #include <sys/module.h> #include <sys/bus.h> +#include <machine/bus.h> #include <sys/rman.h> #include <alpha/pci/ciareg.h> @@ -654,6 +655,7 @@ static device_method_t cia_methods[] = { DEVMETHOD(device_attach, cia_attach), /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_alloc_resource, pci_alloc_resource), DEVMETHOD(bus_release_resource, pci_release_resource), DEVMETHOD(bus_activate_resource, pci_activate_resource), @@ -724,11 +726,12 @@ cia_probe(device_t dev) if (cia0) return ENXIO; cia0 = dev; - device_set_desc(dev, "2117x PCI adapter"); /* XXX */ + device_set_desc(dev, "2117x Core Logic chipset"); /* XXX */ pci_init_resources(); + isa_init_intr(); - device_add_child(dev, "isa", 0, 0); + device_add_child(dev, "pcib", 0, 0); return 0; } @@ -736,12 +739,10 @@ cia_probe(device_t dev) static int cia_attach(device_t dev) { - struct cia_softc* sc = CIA_SOFTC(dev); char* name; int pass; cia_init(); - chipset.intrdev = dev; name = cia_ispyxis ? "Pyxis" : "ALCOR/ALCOR2"; if (cia_ispyxis) { @@ -832,6 +833,9 @@ cia_setup_intr(device_t dev, device_t child, /* Enable PCI interrupt */ platform.pci_intr_enable(irq->r_start); + device_printf(child, "interrupting at CIA irq %d\n", + (int) irq->r_start); + return 0; } @@ -844,4 +848,3 @@ cia_teardown_intr(device_t dev, device_t child, } DRIVER_MODULE(cia, root, cia_driver, cia_devclass, 0, 0); - diff --git a/sys/alpha/pci/cia_pci.c b/sys/alpha/pci/cia_pci.c new file mode 100644 index 0000000..e77c3b4 --- /dev/null +++ b/sys/alpha/pci/cia_pci.c @@ -0,0 +1,73 @@ +/*- + * 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$ + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/bus.h> +#include <machine/bus.h> +#include <sys/rman.h> + +static devclass_t pcib_devclass; + +static int +cia_pcib_probe(device_t dev) +{ + device_set_desc(dev, "2117x PCI host bus adapter"); + + device_add_child(dev, "pci", 0, 0); + + return 0; +} + +static device_method_t cia_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, cia_pcib_probe), + DEVMETHOD(device_attach, bus_generic_attach), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cia_pcib_driver = { + "pcib", + cia_pcib_methods, + DRIVER_TYPE_MISC, + 1, +}; + +DRIVER_MODULE(pcib, cia, cia_pcib_driver, pcib_devclass, 0, 0); diff --git a/sys/alpha/pci/lca.c b/sys/alpha/pci/lca.c index f3b194d..b60fb3e 100644 --- a/sys/alpha/pci/lca.c +++ b/sys/alpha/pci/lca.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: lca.c,v 1.4 1998/11/15 18:25:16 dfr Exp $ + * $Id: lca.c,v 1.5 1998/12/04 22:54:42 archie Exp $ */ #include <sys/param.h> @@ -35,15 +35,16 @@ #include <alpha/pci/lcareg.h> #include <alpha/pci/lcavar.h> #include <alpha/pci/pcibus.h> -#include <machine/swiz.h> +#include <alpha/isa/isavar.h> #include <machine/intr.h> +#include <machine/resource.h> #include <machine/cpuconf.h> +#include <machine/swiz.h> #define KV(pa) ALPHA_PHYS_TO_K0SEG(pa) static devclass_t lca_devclass; static device_t lca0; /* XXX only one for now */ -static device_t isa0; struct lca_softc { int junk; @@ -333,8 +334,12 @@ lca_write_hae(u_int64_t hae) static int lca_probe(device_t dev); static int lca_attach(device_t dev); -static void *lca_create_intr(device_t dev, device_t child, int irq, driver_intr_t *intr, void *arg); -static int lca_connect_intr(device_t dev, void* ih); +static struct resource *lca_alloc_resource(device_t bus, device_t child, + int type, int *rid, u_long start, + u_long end, u_long count, + u_int flags); +static int lca_release_resource(device_t bus, device_t child, + int type, int rid, struct resource *r); static device_method_t lca_methods[] = { /* Device interface */ @@ -342,10 +347,12 @@ static device_method_t lca_methods[] = { DEVMETHOD(device_attach, lca_attach), /* Bus interface */ - DEVMETHOD(bus_alloc_resource, pci_alloc_resource), - DEVMETHOD(bus_release_resource, pci_release_resource), + DEVMETHOD(bus_alloc_resource, lca_alloc_resource), + DEVMETHOD(bus_release_resource, lca_release_resource), DEVMETHOD(bus_activate_resource, pci_activate_resource), DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource), + DEVMETHOD(bus_setup_intr, isa_setup_intr), + DEVMETHOD(bus_teardown_intr, isa_teardown_intr), { 0, 0 } }; @@ -380,9 +387,12 @@ lca_probe(device_t dev) if (lca0) return ENXIO; lca0 = dev; - device_set_desc(dev, "21066 PCI adapter"); /* XXX */ + device_set_desc(dev, "21066 Core Logic chipset"); /* XXX */ + + pci_init_resources(); + isa_init_intr(); - isa0 = device_add_child(dev, "isa", 0, 0); + device_add_child(dev, "pcib", 0, 0); return 0; } @@ -393,7 +403,6 @@ lca_attach(device_t dev) struct lca_softc* sc = LCA_SOFTC(dev); lca_init(); - chipset.intrdev = isa0; set_iointr(alpha_dispatch_intr); @@ -408,5 +417,26 @@ lca_attach(device_t dev) return 0; } +static struct resource * +lca_alloc_resource(device_t bus, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + if (type == SYS_RES_IRQ) + return isa_alloc_intr(bus, child, start); + else + return pci_alloc_resource(bus, child, type, rid, + start, end, count, flags); +} + +static int +lca_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + if (type == SYS_RES_IRQ) + return isa_release_intr(bus, child, r); + else + return pci_release_resource(bus, child, type, rid, r); +} + DRIVER_MODULE(lca, root, lca_driver, lca_devclass, 0, 0); diff --git a/sys/alpha/pci/lca_pci.c b/sys/alpha/pci/lca_pci.c new file mode 100644 index 0000000..61e3525 --- /dev/null +++ b/sys/alpha/pci/lca_pci.c @@ -0,0 +1,73 @@ +/*- + * 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, SPELCAL, 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$ + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/bus.h> +#include <machine/bus.h> +#include <sys/rman.h> + +static devclass_t pcib_devclass; + +static int +lca_pcib_probe(device_t dev) +{ + device_set_desc(dev, "21066 PCI host bus adapter"); + + device_add_child(dev, "pci", 0, 0); + + return 0; +} + +static device_method_t lca_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, lca_pcib_probe), + DEVMETHOD(device_attach, bus_generic_attach), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t lca_pcib_driver = { + "pcib", + lca_pcib_methods, + DRIVER_TYPE_MISC, + 1, +}; + +DRIVER_MODULE(pcib, lca, lca_pcib_driver, pcib_devclass, 0, 0); diff --git a/sys/alpha/pci/pcibus.c b/sys/alpha/pci/pcibus.c index 697373c..ffb726a 100644 --- a/sys/alpha/pci/pcibus.c +++ b/sys/alpha/pci/pcibus.c @@ -23,7 +23,7 @@ * (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: pcibus.c,v 1.7 1998/11/18 23:53:12 dfr Exp $ + * $Id: pcibus.c,v 1.8 1998/12/27 18:03:29 dfr Exp $ * */ @@ -32,6 +32,7 @@ #include <sys/kernel.h> #include <sys/module.h> #include <sys/bus.h> +#include <machine/bus.h> #include <sys/interrupt.h> #include <sys/sysctl.h> #include <sys/rman.h> @@ -40,6 +41,7 @@ #include <machine/chipset.h> #include <machine/cpuconf.h> #include <machine/resource.h> +#include <alpha/pci/pcibus.h> char chipset_type[10]; int chipset_bwx = 0; @@ -129,6 +131,8 @@ pci_cvt_to_bwx(vm_offset_t sparse) return NULL; } +#if 0 + /* * These can disappear when I update the pci code to use the new * device framework. @@ -160,6 +164,8 @@ intr_connect(struct intrec *idesc) return 0; } +#endif + void alpha_platform_assign_pciintr(pcicfgregs *cfg) { @@ -167,6 +173,20 @@ alpha_platform_assign_pciintr(pcicfgregs *cfg) platform.pci_intr_map((void *)cfg); } +int +alpha_platform_setup_ide_intr(int chan, driver_intr_t *fn, void *arg) +{ + if (platform.pci_setup_ide_intr) + return platform.pci_setup_ide_intr(chan, fn, arg); + else { + int irqs[2] = { 14, 15 }; + void *junk; + struct resource *res; + res = isa_alloc_intr(0, 0, irqs[chan]); + return isa_setup_intr(0, 0, res, fn, arg, &junk); + } +} + static struct rman irq_rman, port_rman, mem_rman; void pci_init_resources() @@ -177,23 +197,23 @@ void pci_init_resources() irq_rman.rm_descr = "PCI Interrupt request lines"; if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, 31)) - panic("cia_probe irq_rman"); + panic("pci_init_resources irq_rman"); port_rman.rm_start = 0; - port_rman.rm_end = 0xffff; + port_rman.rm_end = ~0u; port_rman.rm_type = RMAN_ARRAY; port_rman.rm_descr = "I/O ports"; if (rman_init(&port_rman) - || rman_manage_region(&port_rman, 0, 0xffff)) - panic("cia_probe port_rman"); + || rman_manage_region(&port_rman, 0x0, (1L << 32))) + panic("pci_init_resources port_rman"); mem_rman.rm_start = 0; mem_rman.rm_end = ~0u; mem_rman.rm_type = RMAN_ARRAY; - mem_rman.rm_descr = "I/O memory addresses"; + mem_rman.rm_descr = "I/O memory"; if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0x0, (1L << 32))) - panic("cia_probe mem_rman"); + panic("pci_init_resources mem_rman"); } /* @@ -205,6 +225,7 @@ pci_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { struct rman *rm; + struct resource *rv; switch (type) { case SYS_RES_IRQ: @@ -223,7 +244,20 @@ pci_alloc_resource(device_t bus, device_t child, int type, int *rid, return 0; } - return rman_reserve_resource(rm, start, end, count, flags, child); + rv = rman_reserve_resource(rm, start, end, count, flags, child); + if (rv == 0) + return 0; + + if (type == SYS_RES_MEMORY) { + rman_set_bustag(rv, ALPHA_BUS_SPACE_MEM); + rman_set_bushandle(rv, rv->r_start); + rman_set_virtual(rv, (void *) rv->r_start); /* XXX */ + } else if (type == SYS_RES_IOPORT) { + rman_set_bustag(rv, ALPHA_BUS_SPACE_IO); + rman_set_bushandle(rv, rv->r_start); + } + + return rv; } int @@ -266,12 +300,37 @@ memcpy_toio(u_int32_t d, void *s, size_t size) } void +memcpy_io(u_int32_t d, u_int32_t s, size_t size) +{ + while (size--) + writeb(d++, readb(s++)); +} + +void memset_io(u_int32_t d, int val, size_t size) { while (size--) writeb(d++, val); } +void +memsetw(void *d, int val, size_t size) +{ + u_int16_t *sp = d; + + while (size--) + *sp++ = val; +} + +void +memsetw_io(u_int32_t d, int val, size_t size) +{ + while (size--) { + writew(d, val); + d += sizeof(u_int16_t); + } +} + #include "opt_ddb.h" #ifdef DDB #include <ddb/ddb.h> @@ -280,7 +339,6 @@ DB_COMMAND(in, db_in) { int c; int size; - u_int32_t val; if (!have_addr) return; @@ -307,7 +365,7 @@ DB_COMMAND(in, db_in) if (count <= 0) count = 1; while (--count >= 0) { - db_printf("%08x:\t", addr); + db_printf("%08lx:\t", addr); switch (size) { case 1: db_printf("%02x\n", inb(addr)); diff --git a/sys/alpha/tc/tc.c b/sys/alpha/tc/tc.c index 0c88726..dd99f14 100644 --- a/sys/alpha/tc/tc.c +++ b/sys/alpha/tc/tc.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: tc.c,v 1.1 1998/08/20 08:27:10 dfr Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. * All rights reserved. @@ -568,8 +568,6 @@ tc_attach(device_t dev) tc0 = dev; - chipset.intrdev = dev; - switch(hwrpb->rpb_type){ #ifdef DEC_3000_300 case ST_DEC_3000_300: diff --git a/sys/alpha/tc/tcasic.c b/sys/alpha/tc/tcasic.c index 1dd4fee..eeb6953 100644 --- a/sys/alpha/tc/tcasic.c +++ b/sys/alpha/tc/tcasic.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: tcasic.c,v 1.1 1998/08/20 08:27:11 dfr Exp $ */ /* from $NetBSD: tcasic.c,v 1.23 1998/05/14 00:01:31 thorpej Exp $ */ /* @@ -97,7 +97,6 @@ tcasic_attach(device_t dev) tcasic0 = dev; /* chipset = tcasic_chipset;*/ - chipset.intrdev = dev; device_probe_and_attach(tc0); return 0; } diff --git a/sys/alpha/tlsb/dwlpx.c b/sys/alpha/tlsb/dwlpx.c index bb80abf..5a2a5cd 100644 --- a/sys/alpha/tlsb/dwlpx.c +++ b/sys/alpha/tlsb/dwlpx.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: dwlpx.c,v 1.6 1998/09/04 08:01:26 dfr Exp $ + * $Id: dwlpx.c,v 1.7 1998/11/15 18:25:16 dfr Exp $ */ #include "opt_simos.h" @@ -293,7 +293,7 @@ dwlpx_attach(device_t dev) dwlpx0 = dev; chipset = dwlpx_chipset; - chipset.intrdev = dev; + /* chipset.intrdev = dev; */ regs = KV(DWLPX_BASE(kft_get_node(dev), kft_get_hosenum(dev))); sc->dmem_base = regs + (0L << 32); |