Split device_t and softc for pci(4).

This commit is contained in:
cube 2008-03-23 16:40:12 +00:00
parent 25b10dbb15
commit 55ee8b25d0
3 changed files with 23 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci.c,v 1.114 2008/03/21 07:47:43 dyoung Exp $ */
/* $NetBSD: pci.c,v 1.115 2008/03/23 16:40:12 cube Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.114 2008/03/21 07:47:43 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.115 2008/03/23 16:40:12 cube Exp $");
#include "opt_pci.h"
@ -111,7 +111,7 @@ pcirescan(device_t self, const char *ifattr, const int *locators)
}
static int
pcimatch(device_t parent, struct cfdata *cf, void *aux)
pcimatch(device_t parent, cfdata_t cf, void *aux)
{
struct pcibus_attach_args *pba = aux;
@ -142,6 +142,8 @@ pciattach(device_t parent, device_t self, void *aux)
PCICF_DEV_DEFAULT, PCICF_FUNCTION_DEFAULT
};
sc->sc_dev = self;
pci_attach_hook(parent, self, pba);
aprint_naive("\n");
@ -164,7 +166,7 @@ do { \
sep = ", "; \
} while (/*CONSTCOND*/0)
aprint_verbose_dev(self, " ");
aprint_verbose_dev(self, "");
if (io_enabled)
PRINT("i/o space");
@ -198,9 +200,9 @@ do { \
sc->sc_intrtag = pba->pba_intrtag;
sc->sc_flags = pba->pba_flags;
device_pmf_driver_set_child_register(&sc->sc_dev, pci_child_register);
device_pmf_driver_set_child_register(sc->sc_dev, pci_child_register);
pcirescan(&sc->sc_dev, "pci", wildcard);
pcirescan(sc->sc_dev, "pci", wildcard);
fail:
if (!pmf_device_register(self, NULL, NULL))
@ -361,7 +363,7 @@ pci_probe_device(struct pci_softc *sc, pcitag_t tag,
locs[PCICF_DEV] = device;
locs[PCICF_FUNCTION] = function;
subdev = config_found_sm_loc(&sc->sc_dev, "pci", locs, &pa,
subdev = config_found_sm_loc(sc->sc_dev, "pci", locs, &pa,
pciprint, config_stdsubmatch);
sc->PCI_SC_DEVICESC(device, function) = subdev;
ret = (subdev != NULL);
@ -384,7 +386,7 @@ pcidevdetached(device_t self, device_t child)
psc->PCI_SC_DEVICESC(d, f) = 0;
}
CFATTACH_DECL2(pci, sizeof(struct pci_softc),
CFATTACH_DECL2_NEW(pci, sizeof(struct pci_softc),
pcimatch, pciattach, pcidetach, NULL, pcirescan, pcidevdetached);
int
@ -447,7 +449,7 @@ pci_find_device(struct pci_attach_args *pa,
for (i = 0; i < pci_cd.cd_ndevs; i++) {
pcidev = pci_cd.cd_devs[i];
if (pcidev != NULL &&
pci_enumerate_bus((struct pci_softc *)pcidev, wildcard,
pci_enumerate_bus(device_private(pcidev), wildcard,
match, pa) != 0)
return (1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_usrreq.c,v 1.14 2007/03/04 06:02:25 christos Exp $ */
/* $NetBSD: pci_usrreq.c,v 1.15 2008/03/23 16:40:12 cube Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.14 2007/03/04 06:02:25 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.15 2008/03/23 16:40:12 cube Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -56,15 +56,14 @@ __KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.14 2007/03/04 06:02:25 christos Exp
#include <dev/pci/pciio.h>
static int
pciopen(dev_t dev, int flags, int mode,
struct lwp *l)
pciopen(dev_t dev, int flags, int mode, struct lwp *l)
{
struct pci_softc *sc;
device_t dv;
int unit;
unit = minor(dev);
sc = device_lookup(&pci_cd, unit);
if (sc == NULL)
dv = device_lookup(&pci_cd, unit);
if (dv == NULL)
return (ENXIO);
return (0);
@ -73,7 +72,8 @@ pciopen(dev_t dev, int flags, int mode,
static int
pciioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
struct pci_softc *sc = device_lookup(&pci_cd, minor(dev));
struct pci_softc *sc =
device_lookup_private(&pci_cd, minor(dev));
struct pciio_bdf_cfgreg *bdfr = (void *) data;
struct pciio_businfo *binfo = (void *) data;
pcitag_t tag;
@ -113,7 +113,7 @@ static paddr_t
pcimmap(dev_t dev, off_t offset, int prot)
{
#if 0
struct pci_softc *sc = device_lookup(&pci_cd, minor(dev));
struct pci_softc *sc = device_lookup_private(&pci_cd, minor(dev));
/*
* Since we allow mapping of the entire bus, we

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcivar.h,v 1.78 2008/03/21 07:47:43 dyoung Exp $ */
/* $NetBSD: pcivar.h,v 1.79 2008/03/23 16:40:12 cube Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -157,7 +157,7 @@ struct pci_quirkdata {
#define PCI_QUIRK_SKIP_FUNC7 PCI_QUIRK_SKIP_FUNC(7)
struct pci_softc {
struct device sc_dev;
device_t sc_dev;
bus_space_tag_t sc_iot, sc_memt;
bus_dma_tag_t sc_dmat;
bus_dma_tag_t sc_dmat64;
@ -168,7 +168,7 @@ struct pci_softc {
pcitag_t sc_intrtag;
int sc_flags;
/* accounting of child devices */
struct device *sc_devices[32*8];
device_t sc_devices[32*8];
#define PCI_SC_DEVICESC(d, f) sc_devices[(d) * 8 + (f)]
};