1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Fix pci-pci bridges (I hope).

In the nexus case, there are no ivars for children of nexus devices,
and we were passing data in from before the device existed, hence ivars
are convenient as the softc doesn't really exist yet.
However, for pci->pci bridges, the pcib occupies a pci device itself,
which *does* already have ivars.  However, softc is available and stable
at this point since we've been identified and are locating the bus during
attach.  So, use softc for this version of pcib devices for storing the
physical bus number in.
This commit is contained in:
Peter Wemm 2000-09-03 08:30:10 +00:00
parent cabf13fcdb
commit edc31306f7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=65399

View File

@ -760,18 +760,13 @@ static int pcib_attach(device_t dev)
{
u_int8_t secondary;
device_t child;
int *ivar;
chipset_attach(dev, device_get_unit(dev));
secondary = pci_get_secondarybus(dev);
if (secondary) {
child = device_add_child(dev, "pci", -1);
ivar = malloc(sizeof ivar[0], M_DEVBUF /* XXX */, M_NOWAIT);
if (ivar == NULL)
panic("out of memory");
device_set_ivars(child, ivar);
ivar[0] = secondary;
*(int*) device_get_softc(dev) = secondary;
return bus_generic_attach(dev);
} else
return 0;
@ -782,7 +777,7 @@ pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
switch (which) {
case PCIB_IVAR_BUS:
*result = *(int*) device_get_ivars(dev);
*result = *(int*) device_get_softc(dev);
return 0;
}
return ENOENT;
@ -793,7 +788,7 @@ pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
{
switch (which) {
case PCIB_IVAR_BUS:
*(int*) device_get_ivars(dev) = value;
*(int*) device_get_softc(dev) = value;
return 0;
}
return ENOENT;
@ -859,7 +854,7 @@ static device_method_t pcib_methods[] = {
static driver_t pcib_driver = {
"pcib",
pcib_methods,
1,
sizeof(int),
};
static devclass_t pcib_devclass;