diff options
author | gallatin <gallatin@FreeBSD.org> | 1999-12-14 17:35:08 +0000 |
---|---|---|
committer | gallatin <gallatin@FreeBSD.org> | 1999-12-14 17:35:08 +0000 |
commit | 06a35cd8cdb620e14f713e892ae2e237c5f8f542 (patch) | |
tree | c058b02c61dabc105b9800e0fe6da7248f0827c6 /sys/alpha/pci/tsunami_pci.c | |
parent | 6ef9746e27784bf07538a73466c346ed579759e4 (diff) | |
download | FreeBSD-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.
Diffstat (limited to 'sys/alpha/pci/tsunami_pci.c')
-rw-r--r-- | sys/alpha/pci/tsunami_pci.c | 82 |
1 files changed, 73 insertions, 9 deletions
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; } |