From eda3ab65365eda15e04a893a46c7244b53638c94 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 28 May 2000 16:35:57 +0000 Subject: Encapsulate the old PCI compatability support and APIs completely under "options COMPAT_OLDPCI". This option already existed, but now also tidies up the declarations in #include . It is amazing how much stuff was using the old pre-FreeBSD 3.x names and going silently undetected. --- sys/dev/pci/pci.c | 106 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 104 deletions(-) (limited to 'sys/dev/pci/pci.c') diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index aa58b8a..1d47e84 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -52,9 +52,9 @@ #include #include /* For the Alpha */ +#include #include #include -#include #ifdef __alpha__ #include @@ -86,13 +86,6 @@ struct pci_quirk pci_quirks[] = { #define PCI_MAPMEMP 0x02 /* prefetchable memory map */ #define PCI_MAPPORT 0x04 /* port map */ -struct pci_devinfo { - STAILQ_ENTRY(pci_devinfo) pci_links; - struct resource_list resources; - pcicfgregs cfg; - struct pci_conf conf; -}; - static STAILQ_HEAD(devlist, pci_devinfo) pci_devq; u_int32_t pci_numdevs = 0; static u_int32_t pci_generation = 0; @@ -857,101 +850,6 @@ static struct cdevsw pcicdev = { #include "pci_if.h" -static devclass_t pci_devclass; - -#ifdef COMPAT_OLDPCI -/* - * A simple driver to wrap the old pci driver mechanism for back-compat. - */ - -static int -pci_compat_probe(device_t dev) -{ - struct pci_device *dvp; - struct pci_devinfo *dinfo; - pcicfgregs *cfg; - const char *name; - int error; - - dinfo = device_get_ivars(dev); - cfg = &dinfo->cfg; - dvp = device_get_driver(dev)->priv; - - /* - * Do the wrapped probe. - */ - error = ENXIO; - if (dvp && dvp->pd_probe) { - name = dvp->pd_probe(cfg, (cfg->device << 16) + cfg->vendor); - if (name) { - device_set_desc_copy(dev, name); - /* Allow newbus drivers to match "better" */ - error = -200; - } - } - - return error; -} - -static int -pci_compat_attach(device_t dev) -{ - struct pci_device *dvp; - struct pci_devinfo *dinfo; - pcicfgregs *cfg; - int unit; - - dinfo = device_get_ivars(dev); - cfg = &dinfo->cfg; - dvp = device_get_driver(dev)->priv; - - unit = device_get_unit(dev); - if (unit > *dvp->pd_count) - *dvp->pd_count = unit; - if (dvp->pd_attach) - dvp->pd_attach(cfg, unit); - device_printf(dev, "driver is using old-style compatability shims\n"); - return 0; -} - -static device_method_t pci_compat_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, pci_compat_probe), - DEVMETHOD(device_attach, pci_compat_attach), - - { 0, 0 } -}; - -/* - * Create a new style driver around each old pci driver. - */ -int -compat_pci_handler(module_t mod, int type, void *data) -{ - struct pci_device *dvp = (struct pci_device *)data; - driver_t *driver; - - switch (type) { - case MOD_LOAD: - driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT); - if (!driver) - return ENOMEM; - bzero(driver, sizeof(driver_t)); - driver->name = dvp->pd_name; - driver->methods = pci_compat_methods; - driver->size = sizeof(struct pci_devinfo *); - driver->priv = dvp; - devclass_add_driver(pci_devclass, driver); - break; - case MOD_UNLOAD: - printf("%s: module unload not supported!\n", dvp->pd_name); - return EOPNOTSUPP; - default: - break; - } - return 0; -} -#endif /* * New style pci driver. Parent device is either a pci-host-bridge or a @@ -1504,5 +1402,5 @@ static driver_t pci_driver = { pci_methods, 1, /* no softc */ }; - +static devclass_t pci_devclass; DRIVER_MODULE(pci, pcib, pci_driver, pci_devclass, pci_modevent, 0); -- cgit v1.1