summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-07-18 15:52:41 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-07-18 15:52:41 +0000
commit0ffa407a2deec2d04caa6a22e57816f645038207 (patch)
tree05dd95cc0b73159167425b63ff76c5a5eca53cf8
parent2003-07-18 Greg Menke <gregory.menke@gsfc.nasa.gov> (diff)
downloadrtems-0ffa407a2deec2d04caa6a22e57816f645038207.tar.bz2
2003-07-16 Greg Menke <gregory.menke@gsfc.nasa.gov>
PR 428/bsps PR 432/bsps * pci/pcibios.c, pci/pcibios.h: Added BSP_pci_Find_Device() which is copied from motorola_shared.
-rw-r--r--c/src/lib/libbsp/i386/shared/ChangeLog7
-rw-r--r--c/src/lib/libbsp/i386/shared/pci/pcibios.c63
-rw-r--r--c/src/lib/libbsp/i386/shared/pci/pcibios.h4
3 files changed, 74 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/i386/shared/ChangeLog b/c/src/lib/libbsp/i386/shared/ChangeLog
index 4141b79ca5..5936a5c021 100644
--- a/c/src/lib/libbsp/i386/shared/ChangeLog
+++ b/c/src/lib/libbsp/i386/shared/ChangeLog
@@ -1,3 +1,10 @@
+2003-07-16 Greg Menke <gregory.menke@gsfc.nasa.gov>
+
+ PR 428/bsps
+ PR 432/bsps
+ * pci/pcibios.c, pci/pcibios.h: Added BSP_pci_Find_Device() which
+ is copied from motorola_shared.
+
2003-03-18 Joel Sherrill <joel@OARcorp.com>
* comm/GDB.HOWTO: Updated.
diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.c b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
index ea90c95f60..88736480ea 100644
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.c
+++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
@@ -213,6 +213,69 @@ pcib_find_by_class(int classCode, int idx, int *sig)
+
+#define PCI_MULTI_FUNCTION 0x80
+#define PCI_MAX_DEVICES 16
+#define PCI_MAX_FUNCTIONS 8
+
+
+int
+BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
+ int instance, int *pbus, int *pdev, int *pfun )
+{
+ int sig;
+ unsigned int d;
+ unsigned short s;
+ unsigned char bus,dev,fun,hd;
+
+ for (bus=0; bus<BusCountPCI(); bus++)
+ {
+ for (dev=0; dev<PCI_MAX_DEVICES; dev++)
+ {
+ sig = PCIB_DEVSIG_MAKE(bus,dev,0);
+
+ /* pci_read_config_byte(bus,dev,0, PCI_HEADER_TYPE, &hd); */
+ pcib_conf_read8(sig, 0xe, &hd);
+
+ hd = (hd & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
+
+ for (fun=0; fun<hd; fun++) {
+ /*
+ * The last devfn id/slot is special; must skip it
+ */
+ if( PCI_MAX_DEVICES-1 == dev && PCI_MAX_FUNCTIONS-1 == fun )
+ break;
+
+ /*pci_read_config_dword(bus,dev,fun,PCI_VENDOR_ID,&d); */
+ pcib_conf_read32(sig, 0, &d);
+ if( d == -1 )
+ continue;
+#ifdef PCI_DEBUG
+ printk("BSP_pciFindDevice: found 0x%08x at %d/%d/%d\n",d,bus,dev,fun);
+#endif
+ /* pci_read_config_word(bus,dev,fun,PCI_VENDOR_ID,&s); */
+ pcib_conf_read16(sig, 0, &s);
+ if (vendorid != s)
+ continue;
+
+ /* pci_read_config_word(bus,dev,fun,PCI_DEVICE_ID,&s); */
+ pcib_conf_read16(sig, 0x2, &s);
+ if (deviceid == s) {
+ if (instance--) continue;
+ *pbus=bus;
+ *pdev=dev;
+ *pfun=fun;
+ return 0;
+ }
+ }
+ }
+ }
+ return -1;
+}
+
+
+
+
/*
* Generate Special Cycle
*/
diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.h b/c/src/lib/libbsp/i386/shared/pci/pcibios.h
index 40bc3c861a..a94df84e4c 100644
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.h
+++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.h
@@ -41,6 +41,10 @@ int pcib_conf_write8(int sig, int off, unsigned int data);
int pcib_conf_write16(int sig, int off, unsigned int data);
int pcib_conf_write32(int sig, int off, unsigned int data);
+int
+BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
+ int instance, int *pbus, int *pdev, int *pfun );
+
#endif /* _PCIB_H */