From aaf5afc559ee01cf65d4a7cc2e849052a96534a7 Mon Sep 17 00:00:00 2001 From: gallatin Date: Tue, 12 Oct 1999 22:10:53 +0000 Subject: [PATCH] allow pci_ioctl to work with multi-hose alphas. Rather than teaching pci_ioctl about hoses, we just pass down a magic number & let the platform code figure out what the hose is based on what the bus number is. concept approved by dfr --- sys/alpha/pci/tsunami.c | 16 ++++++++++++---- sys/alpha/pci/tsunami_pci.c | 15 ++++++++++++++- sys/alpha/pci/tsunamivar.h | 1 + sys/dev/pci/pci.c | 4 ++-- sys/pci/pci.c | 4 ++-- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/sys/alpha/pci/tsunami.c b/sys/alpha/pci/tsunami.c index 48cdd457e948..5468a62ca0df 100644 --- a/sys/alpha/pci/tsunami.c +++ b/sys/alpha/pci/tsunami.c @@ -275,9 +275,13 @@ tsunami_check_abort(void) KV(TSUNAMI_CONF(h) | ((b) << 16) | ((s) << 11) | ((f) << 8) | (r)) #define CFGREAD(h, b, s, f, r, op, width, type) \ - int bus = tsunami_bus_within_hose(h, b) ? b : 0; \ - vm_offset_t va = TSUNAMI_CFGADDR(bus, s, f, r, h); \ + int bus; \ + vm_offset_t va; \ type data; \ + if (h == (u_int8_t)-1) \ + h = tsunami_hose_from_bus(b); \ + bus = tsunami_bus_within_hose(h, b) ? b : 0; \ + va = TSUNAMI_CFGADDR(bus, s, f, r, h); \ tsunami_clear_abort(); \ if (badaddr((caddr_t)va, width)) { \ tsunami_check_abort(); \ @@ -289,8 +293,12 @@ tsunami_check_abort(void) return data; #define CFWRITE(h, b, s, f, r, data, op, width) \ - int bus = tsunami_bus_within_hose(h, b) ? b : 0; \ - vm_offset_t va = TSUNAMI_CFGADDR(bus, s, f, r, h); \ + int bus; \ + 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; \ + va = TSUNAMI_CFGADDR(bus, s, f, r, h); \ tsunami_clear_abort(); \ if (badaddr((caddr_t)va, width)) \ return; \ diff --git a/sys/alpha/pci/tsunami_pci.c b/sys/alpha/pci/tsunami_pci.c index 6f7af8820f1f..634260c476d6 100644 --- a/sys/alpha/pci/tsunami_pci.c +++ b/sys/alpha/pci/tsunami_pci.c @@ -41,7 +41,7 @@ static devclass_t pcib_devclass; -int tsunami_hoses[TSUNAMI_MAXHOSES] = {0,0,0,0}; +int tsunami_hoses[TSUNAMI_MAXHOSES+1] = {0,-1,-1,-1,-1}; int tsunami_bus_within_hose(int hose, int bus) @@ -49,6 +49,19 @@ tsunami_bus_within_hose(int hose, int bus) return(bus - tsunami_hoses[hose]); } +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) + return i-1; + } + return i-1; + +} + + static int tsunami_pcib_probe(device_t dev) { diff --git a/sys/alpha/pci/tsunamivar.h b/sys/alpha/pci/tsunamivar.h index f82351f702f2..89cb2aba65cd 100644 --- a/sys/alpha/pci/tsunamivar.h +++ b/sys/alpha/pci/tsunamivar.h @@ -28,3 +28,4 @@ extern void tsunami_init(void); extern int tsunami_bus_within_hose(int, int); +extern int tsunami_hose_from_bus(int); diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 4305b6cfd81b..bfdf9d0452e0 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -845,7 +845,7 @@ pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) case 4: case 2: case 1: - probe.hose = 0; /* XXXXX */ + probe.hose = -1; probe.bus = io->pi_sel.pc_bus; probe.slot = io->pi_sel.pc_dev; probe.func = io->pi_sel.pc_func; @@ -866,7 +866,7 @@ pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) case 4: case 2: case 1: - probe.hose = 0; /* XXXXX */ + probe.hose = -1; probe.bus = io->pi_sel.pc_bus; probe.slot = io->pi_sel.pc_dev; probe.func = io->pi_sel.pc_func; diff --git a/sys/pci/pci.c b/sys/pci/pci.c index 4305b6cfd81b..bfdf9d0452e0 100644 --- a/sys/pci/pci.c +++ b/sys/pci/pci.c @@ -845,7 +845,7 @@ pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) case 4: case 2: case 1: - probe.hose = 0; /* XXXXX */ + probe.hose = -1; probe.bus = io->pi_sel.pc_bus; probe.slot = io->pi_sel.pc_dev; probe.func = io->pi_sel.pc_func; @@ -866,7 +866,7 @@ pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) case 4: case 2: case 1: - probe.hose = 0; /* XXXXX */ + probe.hose = -1; probe.bus = io->pi_sel.pc_bus; probe.slot = io->pi_sel.pc_dev; probe.func = io->pi_sel.pc_func;