summaryrefslogtreecommitdiffstats
path: root/sys/amd64/pci
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-09-28 00:37:32 +0000
committerpeter <peter@FreeBSD.org>2000-09-28 00:37:32 +0000
commit04e4b06d1c30bb8e2745b21af81279b6781b63f8 (patch)
tree679d118c3dc7d5fa696d505cff5e769004bc90d9 /sys/amd64/pci
parent3ebe63e32735ecf4534ed4218f679d30169d966a (diff)
downloadFreeBSD-src-04e4b06d1c30bb8e2745b21af81279b6781b63f8.zip
FreeBSD-src-04e4b06d1c30bb8e2745b21af81279b6781b63f8.tar.gz
Get out the roto-rooter and clean up the abuse of nexus ivars by the
i386/isa/pcibus.c. This gets -current running again on multiple host->pci machines after the most recent nexus commits. I had discussed this with Mike Smith, but ended up doing it slightly differently to what we discussed as it turned out cleaner this way. Mike was suggesting creating a new resource (SYS_RES_PCIBUS) or something and using *_[gs]et_resource(), but IMHO that wasn't ideal as SYS_RES_* is meant to be a global platform property, not a quirk of a given implementation. This does use the ivar methods but does so properly. It also now prints the physical pci bus that a host->pci bridge (pcib) corresponds to.
Diffstat (limited to 'sys/amd64/pci')
-rw-r--r--sys/amd64/pci/pci_bus.c25
-rw-r--r--sys/amd64/pci/pci_cfgreg.c25
2 files changed, 12 insertions, 38 deletions
diff --git a/sys/amd64/pci/pci_bus.c b/sys/amd64/pci/pci_bus.c
index 2dd6694..cd7d062 100644
--- a/sys/amd64/pci/pci_bus.c
+++ b/sys/amd64/pci/pci_bus.c
@@ -38,6 +38,7 @@
#include <pci/pcireg.h>
#include <i386/isa/pcibus.h>
#include <isa/isavar.h>
+#include <machine/nexusvar.h>
#include <machine/segments.h>
#include <machine/pc/bios.h>
@@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int pcifunchigh;
int found824xx = 0;
device_t child;
- int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (strcmp(device_get_name(devs[i]),
"pcib") != 0)
continue;
- ivar = device_get_ivars(devs[i]);
- if (ivar == NULL)
- continue;
- if (busnum == *ivar)
+ if (nexus_get_pcibus(devs[i]) == busnum)
s = NULL;
}
free(devs, M_TEMP);
@@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
-
- ivar = malloc(sizeof ivar[0], M_DEVBUF,
- M_NOWAIT);
- if (ivar == NULL)
- panic("out of memory");
- device_set_ivars(child, ivar);
- ivar[0] = busnum;
+ nexus_set_pcibus(child, busnum);
found = 1;
if (id == 0x12258086)
@@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
- ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
- if (ivar == NULL)
- panic("out of memory");
- device_set_ivars(child, ivar);
- ivar[0] = 0;
+ nexus_set_pcibus(child, 0);
}
}
@@ -703,7 +690,7 @@ nexus_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 = nexus_get_pcibus(dev);
return 0;
}
return ENOENT;
@@ -715,7 +702,7 @@ nexus_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;
+ nexus_set_pcibus(dev, value);
return 0;
}
return ENOENT;
diff --git a/sys/amd64/pci/pci_cfgreg.c b/sys/amd64/pci/pci_cfgreg.c
index 2dd6694..cd7d062 100644
--- a/sys/amd64/pci/pci_cfgreg.c
+++ b/sys/amd64/pci/pci_cfgreg.c
@@ -38,6 +38,7 @@
#include <pci/pcireg.h>
#include <i386/isa/pcibus.h>
#include <isa/isavar.h>
+#include <machine/nexusvar.h>
#include <machine/segments.h>
#include <machine/pc/bios.h>
@@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int pcifunchigh;
int found824xx = 0;
device_t child;
- int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (strcmp(device_get_name(devs[i]),
"pcib") != 0)
continue;
- ivar = device_get_ivars(devs[i]);
- if (ivar == NULL)
- continue;
- if (busnum == *ivar)
+ if (nexus_get_pcibus(devs[i]) == busnum)
s = NULL;
}
free(devs, M_TEMP);
@@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
-
- ivar = malloc(sizeof ivar[0], M_DEVBUF,
- M_NOWAIT);
- if (ivar == NULL)
- panic("out of memory");
- device_set_ivars(child, ivar);
- ivar[0] = busnum;
+ nexus_set_pcibus(child, busnum);
found = 1;
if (id == 0x12258086)
@@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
- ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
- if (ivar == NULL)
- panic("out of memory");
- device_set_ivars(child, ivar);
- ivar[0] = 0;
+ nexus_set_pcibus(child, 0);
}
}
@@ -703,7 +690,7 @@ nexus_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 = nexus_get_pcibus(dev);
return 0;
}
return ENOENT;
@@ -715,7 +702,7 @@ nexus_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;
+ nexus_set_pcibus(dev, value);
return 0;
}
return ENOENT;
OpenPOWER on IntegriCloud