summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgallatin <gallatin@FreeBSD.org>1999-12-14 17:35:08 +0000
committergallatin <gallatin@FreeBSD.org>1999-12-14 17:35:08 +0000
commit06a35cd8cdb620e14f713e892ae2e237c5f8f542 (patch)
treec058b02c61dabc105b9800e0fe6da7248f0827c6
parent6ef9746e27784bf07538a73466c346ed579759e4 (diff)
downloadFreeBSD-src-06a35cd8cdb620e14f713e892ae2e237c5f8f542.zip
FreeBSD-src-06a35cd8cdb620e14f713e892ae2e237c5f8f542.tar.gz
Improve the mapping between the hardware PCI bus numbering on multi-hose
tsunami systems and the PCI bus-numbering system of FreeBSD. Eg, the former allows for 2 PCI bus 2's (one each on hoses 0 and 1) while the latter needs to give each PCI bus a unique monotonically increasing number. It has been fairly well tested and correctly maps machines with a ppb on hose 1 as well as machines with ppbs on both hoses. DS10s remain untested, as I do not have a pci card with a ppb which will pass POST in a tsunami. This is a house of cards.
-rw-r--r--sys/alpha/pci/tsunami.c16
-rw-r--r--sys/alpha/pci/tsunami_pci.c82
2 files changed, 81 insertions, 17 deletions
diff --git a/sys/alpha/pci/tsunami.c b/sys/alpha/pci/tsunami.c
index c9cb3b5..41f67a5 100644
--- a/sys/alpha/pci/tsunami.c
+++ b/sys/alpha/pci/tsunami.c
@@ -62,7 +62,7 @@ struct tsunami_softc {
int junk; /* no softc */
};
-static int num_pchips = 0;
+int tsunami_num_pchips = 0;
static volatile tsunami_pchip *pchip[2] = {pchip0, pchip1};
#define TSUNAMI_SOFTC(dev) (struct tsunami_softc*) device_get_softc(dev)
@@ -279,7 +279,7 @@ tsunami_check_abort(void)
type data; \
if (h == (u_int8_t)-1) \
h = tsunami_hose_from_bus(b); \
- bus = tsunami_bus_within_hose(h, b) ? b : 0; \
+ bus = tsunami_bus_within_hose(h, b); \
va = TSUNAMI_CFGADDR(bus, s, f, r, h); \
tsunami_clear_abort(); \
if (badaddr((caddr_t)va, width)) { \
@@ -296,7 +296,7 @@ tsunami_check_abort(void)
vm_offset_t va; \
if (h == (u_int8_t)-1) \
h = tsunami_hose_from_bus(b); \
- bus = tsunami_bus_within_hose(h, b) ? b : 0; \
+ bus = tsunami_bus_within_hose(h, b); \
va = TSUNAMI_CFGADDR(bus, s, f, r, h); \
tsunami_clear_abort(); \
if (badaddr((caddr_t)va, width)) \
@@ -468,7 +468,7 @@ static void
tsunami_sgmap_invalidate(void)
{
alpha_mb();
- switch (num_pchips) {
+ switch (tsunami_num_pchips) {
case 2:
pchip[1]->tlbia.reg = (u_int64_t)0;
case 1:
@@ -507,7 +507,7 @@ tsunami_init_sgmap(void)
if (!sgtable)
panic("tsunami_init_sgmap: can't allocate page table");
- for(i=0; i < num_pchips; i++){
+ for(i=0; i < tsunami_num_pchips; i++){
pchip[i]->tba[0].reg =
pmap_kextract((vm_offset_t) sgtable);
pchip[i]->wsba[0].reg |= WINDOW_ENABLE | WINDOW_SCATTER_GATHER;
@@ -546,14 +546,14 @@ tsunami_probe(device_t dev)
tsunami0 = dev;
device_set_desc(dev, "21271 Core Logic chipset");
if(cchip->csc.reg & CSC_P1P)
- num_pchips = 2;
+ tsunami_num_pchips = 2;
else
- num_pchips = 1;
+ tsunami_num_pchips = 1;
pci_init_resources();
isa_init_intr();
- for(i = 0; i < num_pchips; i++) {
+ for(i = 0; i < tsunami_num_pchips; i++) {
hose = malloc(sizeof(int), M_DEVBUF, M_NOWAIT);
*hose = i;
child = device_add_child(dev, "pcib", i);
diff --git a/sys/alpha/pci/tsunami_pci.c b/sys/alpha/pci/tsunami_pci.c
index 87ea867..c5301d1 100644
--- a/sys/alpha/pci/tsunami_pci.c
+++ b/sys/alpha/pci/tsunami_pci.c
@@ -41,40 +41,104 @@
static devclass_t pcib_devclass;
-int tsunami_hoses[TSUNAMI_MAXHOSES+1] = {0,-1,-1,-1,-1};
+int tsunami_hoses[TSUNAMI_MAXHOSES+1] = {1,-1,-1,-1,-1};
+
+int tsunami_maxhoseno = 0;
+
+extern int tsunami_num_pchips;
+
+/*
+ * This comment attempts to explain why and how we are mapping from
+ * the DEQ assigned bus numbers to the FreeBSD assigned numbers.
+ *
+ * FreeBSD must number buses with monotonically increasing numbers for a
+ * variety of reasons (pciconf, newbus, etc).
+ *
+ * DEQ numbers them (from what I can tell) on a per-hose bases. And
+ * for some reason they seem to always leave bus 1 unused.
+ *
+ * When generating config space addrs, we need to know if we are
+ * directly on the primary bus on that hose, or if we are behind a ppb.
+ * We keep track of this by assigning hoses monotonically increasing
+ * numbers. This fits nicely with DEQ not using bus number 1; I
+ * assume that is what it as intended for. I guess we'll see if they
+ * come out with a system using more than one pchip..
+ *
+ * Next, we must attempt to map the FreeBSD assigned numbers to the
+ * numbers assigned by DEQ in order to generate proper config space
+ * addrs. We store the next number past the 0th bus of our hose and
+ * do subtraction to determine what the DEQ number should have been,
+ * given a FreeBSD bus number. This is disgusting & quite possibly
+ * wrong.
+ */
int
tsunami_bus_within_hose(int hose, int bus)
{
- return(bus - tsunami_hoses[hose]);
+ if (hose == bus)
+ return 0;
+ else
+ return ( (bus - tsunami_hoses[hose])
+ + (tsunami_num_pchips - 1)); /* XXX */
+ /*
+ * XXX (tsunami_num_pchips - 1) is a just a guess!
+ *
+ * I assume that a ppb in a ds10 will get bus 1
+ * if it is assigned bus 2, then replace
+ * (tsunami_num_pchips - 1) with 1.
+ */
}
+/*
+ * this function supports pciconf ioctls
+ */
+
int
tsunami_hose_from_bus(int bus)
{
int i;
- for(i = 1; i <= TSUNAMI_MAXHOSES && tsunami_hoses[i] != -1; i++){
- if(tsunami_hoses[i] > bus)
+
+ if (bus < tsunami_maxhoseno)
+ return bus;
+
+ for (i = 1; i <= TSUNAMI_MAXHOSES && tsunami_hoses[i] != -1; i++){
+ if(tsunami_hoses[i] >= bus)
return i-1;
}
+
return i-1;
-
}
static int
tsunami_pcib_probe(device_t dev)
{
- static int hoseno = 0;
+ static int error;
device_t child;
+ int lastbus;
device_set_desc(dev, "21271 PCI host bus adapter");
child = device_add_child(dev, "pci", -1);
- if(hoseno)
- tsunami_hoses[hoseno] = device_get_unit(child);
- hoseno++;
+ if (tsunami_maxhoseno) {
+ lastbus = (device_get_unit(child) - 1);
+ if (lastbus == 0) /* didn't have a ppb on hose 0 */
+ lastbus++;
+ tsunami_hoses[tsunami_maxhoseno] = lastbus;
+ }
+ if ((error = device_delete_child(dev, child)))
+ panic("tsunami_pcib_probe: device_delete_child failed\n");
+
+ child = device_add_child(dev, "pci", tsunami_maxhoseno);
+
+ if (tsunami_maxhoseno != device_get_unit(child)) {
+ printf("tsunami_pcib_probe: wanted unit %d ",
+ tsunami_maxhoseno);
+ printf(" got unit %d\n", device_get_unit(child));
+ panic("tsunami_pcib_probe: incorrect bus numbering");
+ }
+ tsunami_maxhoseno++;
return 0;
}
OpenPOWER on IntegriCloud