diff --git a/sys/conf/files b/sys/conf/files index 1a75a37731ca..e23dc7128052 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -107,12 +107,12 @@ dev/dpt/dpt_scsi.c optional dpt dev/dpt/dpt_eisa.c optional dpt eisa dev/dpt/dpt_pci.c optional dpt pci dev/ed/if_ed_pci.c optional ed pci -dev/en/midway.c optional en dev/ep/if_ep.c optional ep dev/ep/if_ep_isa.c optional ep isa dev/ep/if_ep_eisa.c optional ep eisa dev/ep/if_ep_mca.c optional ep mca dev/ep/if_ep_pccard.c optional ep card +dev/en/midway.c optional en dev/hea/eni.c optional hea dev/hea/eni_buffer.c optional hea dev/hea/eni_globals.c optional hea @@ -641,6 +641,7 @@ nwfs/nwfs_vnops.c optional nwfs pccard/pccard.c optional card pccard/pccard_beep.c optional card pccard/pccard_nbk.c optional card +pccard/pccard_compat.c optional card pccard/pcic.c optional pcic pci/amd.c optional amd pci/pcic_p.c optional pcic pci diff --git a/sys/pccard/pccard_compat.c b/sys/pccard/pccard_compat.c new file mode 100644 index 000000000000..9bc435af441c --- /dev/null +++ b/sys/pccard/pccard_compat.c @@ -0,0 +1,218 @@ +/* + * Copyright (c) 1999, M. Warner Losh. + * 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. + * + * $FreeBSD$ + */ + +#include "opt_bus.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +/* ============================================================ */ + +static int +pccnbk_probe(device_t dev) +{ + char devnam[128]; + const char *name; + struct pccard_devinfo *devi = device_get_ivars(dev); + + if (devi) { + name = device_get_name(dev); + snprintf(devnam, sizeof(devnam), "pccard-%s", + devi->drv->name); + if (!name || strcmp(name, devnam) != 0) + return ENXIO; + device_set_desc(dev, devi->drv->name); + return 0; + } + return ENXIO; +} + +static int +pccnbk_attach(device_t dev) +{ + struct pccard_devinfo *devi = device_get_ivars(dev); + struct pccard_device *drv; + struct slot *slt; + int err; + int s; + + slt = devi->slt; + drv = devi->drv; + devi->next = slt->devices; + slt->devices = devi; + s = splhigh(); + err = drv->enable(devi); + splx(s); + /* + * If the enable functions returns no error, then the + * device has been successfully installed. If so, then + * attach it to the slot, otherwise free it and return + * the error. We assume that when we free the device, + * it will also set 'running' to off. + */ + if (err) { + printf("pccard: %s%d Enable failed %d\n", devi->drv->name, + devi->isahd.id_unit, err); + pccard_remove_device(devi); + } + return(err); +} + +/* + * Allocate resources for this device in the rman system. + */ +int +pccnbk_alloc_resources(device_t dev) +{ + struct pccard_devinfo *devi = device_get_ivars(dev); + int rid; + u_long start; + u_long end; + u_long count; + + start = devi->isahd.id_iobase; + count = devi->isahd.id_iosize; + end = start + count - 1; + + rid = 0; + devi->iorv = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, + SYS_RES_IOPORT, &rid, start, end, count, RF_ACTIVE); + if (!devi->iorv) { + printf("Cannot allocate ports 0x%lx-0x%lx\n", start, end); + return (ENOMEM); + } + rid = 0; + start = end = ffs(devi->isahd.id_irq) - 1; + count = 1; + devi->irqrv = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, + SYS_RES_IRQ, &rid, start, end, count, RF_ACTIVE); + if (!devi->irqrv) { + return (ENOMEM); + } + return(0); +} + +void +pccnbk_release_resources(device_t dev) +{ + struct pccard_devinfo *devi = device_get_ivars(dev); + u_long start; + u_long end; + u_long count; + + start = devi->isahd.id_iobase; + count = devi->isahd.id_iosize; + end = start + count - 1; + + if (devi->iorv) { + BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, + SYS_RES_IOPORT, 0, devi->iorv); + devi->iorv = NULL; + } + if (devi->irqrv) { + BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, SYS_RES_IRQ, + 0, devi->irqrv); + devi->irqrv = NULL; + } +} + +static device_method_t pccnbk_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pccnbk_probe), + DEVMETHOD(device_attach, pccnbk_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + 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 } +}; + +void +pccnbk_wrap_old_driver(struct pccard_device *drv) +{ + char devnam[128]; + char *nm; + driver_t *driver; + + snprintf(devnam, sizeof(devnam), "pccard-%s", drv->name); + driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT); + if (!driver) + return; + bzero(driver, sizeof(driver_t)); + /* XXX May create a memory leak for load/unload :-( XXX */ + nm = malloc(strlen(devnam) + 1, M_DEVBUF, M_NOWAIT); + strcpy(nm, devnam); + driver->name = nm; + driver->methods = pccnbk_methods; + driver->softc = sizeof(struct pccard_device); + driver->priv = drv; + devclass_add_driver(pccard_devclass, driver); + drv->driver = driver; +} + +#if 0 +static devclass_t pccnbk_devclass; + +static driver_t pccnbk_driver = { + "pccnbk", + pccnbk_methods, + 1, /* no softc */ +}; + +DRIVER_MODULE(pccnbk, pccard, pccnbk_driver, pccnbk_devclass, 0, 0); +#endif