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.
This commit is contained in:
Andrew Gallatin 1999-12-14 17:35:08 +00:00
parent 38c05314b4
commit 7c79b9ff14
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54603
2 changed files with 81 additions and 17 deletions

View File

@ -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);

View File

@ -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;
}