From 04dbb408657b49acc40aa27e1d59bf01074c8021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Mon, 27 Feb 1995 17:17:14 +0000 Subject: [PATCH] First try to add support for PCI-PCI bridge chips (written for the DEC 21050 chip in particular, don't have specs of other such chips). This should add support for Multiple-Ethernet PCI cards (e.g. Znyx 314). Reviewed by: se Submitted by: Wolfgang Stanglmeier --- sys/dev/pci/pci.c | 99 ++++++++++++++++++++++++++++++++++---------- sys/dev/pci/pcivar.h | 14 ++++++- sys/pci/pci.c | 99 ++++++++++++++++++++++++++++++++++---------- sys/pci/pcivar.h | 14 ++++++- 4 files changed, 180 insertions(+), 46 deletions(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index e17b7f53a96b..2b2debf68f0f 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,6 +1,6 @@ /************************************************************************** ** -** $Id: pci.c,v 1.15 1995/02/22 14:17:15 se Exp $ +** $Id: pci.c,v 1.16 1995/02/25 17:26:22 se Exp $ ** ** General subroutines for the PCI bus on 80*86 systems. ** pci_configure () @@ -36,7 +36,7 @@ *************************************************************************** */ -#define PCI_PATCHLEVEL "pl3 95/02/25" +#define PCI_PATCHLEVEL "pl5 95/02/27" #include #if NPCI > 0 @@ -103,6 +103,19 @@ static vm_offset_t pmap_mapdev (vm_offset_t paddr, vm_size_t vsize); **======================================================== */ +/*-------------------------------------------------------- +** +** Limit for pci bus numbers. +** +**-------------------------------------------------------- +*/ + +#ifndef PCI_MAX_BUS +#define PCI_MAX_BUS (256) +#endif + +static u_long pci_bus_max = 1; + /*-------------------------------------------------------- ** ** The pci devices can be mapped to any address. @@ -174,16 +187,17 @@ static u_long pci_irq = PCI_IRQ; static void not_supported (pcici_t tag, u_long type); -static unsigned long pci_seen[NPCI]; +static unsigned long pci_seen[PCI_MAX_BUS]; static int pci_conf_count; +static int pci_info_done; void pci_configure() { - u_char device,last_device; + u_char device,max_device; u_short bus; pcici_t tag; - pcidi_t type; + pcidi_t type, type8, type16; u_long data; int unit; int pci_mechanism; @@ -213,19 +227,24 @@ void pci_configure() pci_mechanism = pcibus.pb_mode (); if (!pci_mechanism) return; - last_device = pci_mechanism==1 ? 31 : 15; + max_device = pci_mechanism==1 ? 32 : 16; /* ** hello world .. */ pci_pold=pci_paddr; - for (bus=0;bus= 8) { - pcici_t tag0; - pcidi_t type0; - tag0 = pcibus.pb_tag (bus, device & 0x07, 0); - type0 = pcibus.pb_read (tag0, PCI_ID_REG); - if (type==type0) { + if (device & 0x08) { + pcici_t mtag; + mtag = pcibus.pb_tag (bus, device & ~0x08, 0); + type8 = pcibus.pb_read (mtag, PCI_ID_REG); + } else type8 = 0; + if (device & 0x10) { + pcici_t mtag; + mtag = pcibus.pb_tag (bus, device & ~0x10, 0); + type16 = pcibus.pb_read (mtag, PCI_ID_REG); + } else type16 = 0; + if ((type==type8) || (type==type16)) { #ifndef PCI_QUIET - if (dvp==NULL) continue; - printf ("%s? <%s> mirrored on pci%d:%d\n", - dvp->pd_name, name, bus, device); + if (dvp==NULL) continue; + printf ("%s? <%s> mirrored on pci%d:%d\n", + dvp->pd_name, name, bus, device); #endif - continue; - }; + continue; }; if (dvp==NULL) { @@ -699,7 +722,7 @@ domap: break; }; - if (data==0xffffffff) { + if ((data==0xffffffff) && !oldmap) { printf ("\t(possible mapping problem: " "at 0x%x read 0xffffffff)\n", (unsigned) paddr); @@ -717,6 +740,38 @@ domap: return (1); } +/*----------------------------------------------------------------------- +** +** Map new pci bus. (XXX under construction) +** +** PCI-Specification: ____________? +** +**----------------------------------------------------------------------- +*/ + +int pci_map_bus (pcici_t tag, u_long bus) +{ + if (bus >= PCI_MAX_BUS) { + printf ("pci_map_bus failed: bus number %d too big.\n", + (int) bus); + return (0); + }; + + if (bus >= pci_bus_max) + pci_bus_max = bus + 1; + +#ifndef PCI_QUIET + /* + ** display values. + */ + + printf ("\tmapped pci bus %d.\n", + (int) bus); +#endif + + return (1); +} + /*------------------------------------------------------------ ** ** Interface functions for the devconf module. diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index b0712dba9171..73ce43e09638 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** $Id: pcireg.h,v 1.2 1994/11/02 23:47:14 se Exp $ +** $Id: pcivar.h,v 1.1 1995/02/01 22:56:55 se Exp $ ** ** Declarations for pci device drivers. ** @@ -37,6 +37,8 @@ #ifndef __PCI_VAR_H__ #define __PCI_VAR_H__ + +#define PCIVAR_H_PATCHLEVEL "pl1 95/02/27" /*----------------------------------------------------------------- ** @@ -160,6 +162,16 @@ struct pci_externalize_buffer { }; +/*----------------------------------------------------------------- +** +** Register an additional pci bus for probing. +** Called by pci-pci bridge handlers. +** +**----------------------------------------------------------------- +*/ + +int pci_map_bus (pcici_t tag, u_long bus); + /*----------------------------------------------------------------- ** ** Map a pci device to physical and virtual memory. diff --git a/sys/pci/pci.c b/sys/pci/pci.c index e17b7f53a96b..2b2debf68f0f 100644 --- a/sys/pci/pci.c +++ b/sys/pci/pci.c @@ -1,6 +1,6 @@ /************************************************************************** ** -** $Id: pci.c,v 1.15 1995/02/22 14:17:15 se Exp $ +** $Id: pci.c,v 1.16 1995/02/25 17:26:22 se Exp $ ** ** General subroutines for the PCI bus on 80*86 systems. ** pci_configure () @@ -36,7 +36,7 @@ *************************************************************************** */ -#define PCI_PATCHLEVEL "pl3 95/02/25" +#define PCI_PATCHLEVEL "pl5 95/02/27" #include #if NPCI > 0 @@ -103,6 +103,19 @@ static vm_offset_t pmap_mapdev (vm_offset_t paddr, vm_size_t vsize); **======================================================== */ +/*-------------------------------------------------------- +** +** Limit for pci bus numbers. +** +**-------------------------------------------------------- +*/ + +#ifndef PCI_MAX_BUS +#define PCI_MAX_BUS (256) +#endif + +static u_long pci_bus_max = 1; + /*-------------------------------------------------------- ** ** The pci devices can be mapped to any address. @@ -174,16 +187,17 @@ static u_long pci_irq = PCI_IRQ; static void not_supported (pcici_t tag, u_long type); -static unsigned long pci_seen[NPCI]; +static unsigned long pci_seen[PCI_MAX_BUS]; static int pci_conf_count; +static int pci_info_done; void pci_configure() { - u_char device,last_device; + u_char device,max_device; u_short bus; pcici_t tag; - pcidi_t type; + pcidi_t type, type8, type16; u_long data; int unit; int pci_mechanism; @@ -213,19 +227,24 @@ void pci_configure() pci_mechanism = pcibus.pb_mode (); if (!pci_mechanism) return; - last_device = pci_mechanism==1 ? 31 : 15; + max_device = pci_mechanism==1 ? 32 : 16; /* ** hello world .. */ pci_pold=pci_paddr; - for (bus=0;bus= 8) { - pcici_t tag0; - pcidi_t type0; - tag0 = pcibus.pb_tag (bus, device & 0x07, 0); - type0 = pcibus.pb_read (tag0, PCI_ID_REG); - if (type==type0) { + if (device & 0x08) { + pcici_t mtag; + mtag = pcibus.pb_tag (bus, device & ~0x08, 0); + type8 = pcibus.pb_read (mtag, PCI_ID_REG); + } else type8 = 0; + if (device & 0x10) { + pcici_t mtag; + mtag = pcibus.pb_tag (bus, device & ~0x10, 0); + type16 = pcibus.pb_read (mtag, PCI_ID_REG); + } else type16 = 0; + if ((type==type8) || (type==type16)) { #ifndef PCI_QUIET - if (dvp==NULL) continue; - printf ("%s? <%s> mirrored on pci%d:%d\n", - dvp->pd_name, name, bus, device); + if (dvp==NULL) continue; + printf ("%s? <%s> mirrored on pci%d:%d\n", + dvp->pd_name, name, bus, device); #endif - continue; - }; + continue; }; if (dvp==NULL) { @@ -699,7 +722,7 @@ domap: break; }; - if (data==0xffffffff) { + if ((data==0xffffffff) && !oldmap) { printf ("\t(possible mapping problem: " "at 0x%x read 0xffffffff)\n", (unsigned) paddr); @@ -717,6 +740,38 @@ domap: return (1); } +/*----------------------------------------------------------------------- +** +** Map new pci bus. (XXX under construction) +** +** PCI-Specification: ____________? +** +**----------------------------------------------------------------------- +*/ + +int pci_map_bus (pcici_t tag, u_long bus) +{ + if (bus >= PCI_MAX_BUS) { + printf ("pci_map_bus failed: bus number %d too big.\n", + (int) bus); + return (0); + }; + + if (bus >= pci_bus_max) + pci_bus_max = bus + 1; + +#ifndef PCI_QUIET + /* + ** display values. + */ + + printf ("\tmapped pci bus %d.\n", + (int) bus); +#endif + + return (1); +} + /*------------------------------------------------------------ ** ** Interface functions for the devconf module. diff --git a/sys/pci/pcivar.h b/sys/pci/pcivar.h index b0712dba9171..73ce43e09638 100644 --- a/sys/pci/pcivar.h +++ b/sys/pci/pcivar.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** $Id: pcireg.h,v 1.2 1994/11/02 23:47:14 se Exp $ +** $Id: pcivar.h,v 1.1 1995/02/01 22:56:55 se Exp $ ** ** Declarations for pci device drivers. ** @@ -37,6 +37,8 @@ #ifndef __PCI_VAR_H__ #define __PCI_VAR_H__ + +#define PCIVAR_H_PATCHLEVEL "pl1 95/02/27" /*----------------------------------------------------------------- ** @@ -160,6 +162,16 @@ struct pci_externalize_buffer { }; +/*----------------------------------------------------------------- +** +** Register an additional pci bus for probing. +** Called by pci-pci bridge handlers. +** +**----------------------------------------------------------------- +*/ + +int pci_map_bus (pcici_t tag, u_long bus); + /*----------------------------------------------------------------- ** ** Map a pci device to physical and virtual memory.