diff options
author | Till Straumann <strauman@slac.stanford.edu> | 2005-11-03 02:59:18 +0000 |
---|---|---|
committer | Till Straumann <strauman@slac.stanford.edu> | 2005-11-03 02:59:18 +0000 |
commit | 05a2cc4bd39bcbc1fb0ca785e64f06457ad8142b (patch) | |
tree | 4ba924eba092b1b4fbd30585283baf773b843c5e /c/src/lib/libbsp/i386/shared | |
parent | 2005-11-02 straumanatslacdotstanford.edu (diff) | |
download | rtems-05a2cc4bd39bcbc1fb0ca785e64f06457ad8142b.tar.bz2 |
2005-11-02 straumanatslacdotstanford.edu
* shared/pci/pcibios.c: replaced pci_find_device implementation by a
pcibios call which already provides the functionality
Diffstat (limited to 'c/src/lib/libbsp/i386/shared')
-rw-r--r-- | c/src/lib/libbsp/i386/shared/pci/pcibios.c | 60 |
1 files changed, 11 insertions, 49 deletions
diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.c b/c/src/lib/libbsp/i386/shared/pci/pcibios.c index 88bcc5e7a2..c90ca09d53 100644 --- a/c/src/lib/libbsp/i386/shared/pci/pcibios.c +++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.c @@ -273,55 +273,17 @@ int BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid, int instance, int *pbus, int *pdev, int *pfun ) { - int sig; - unsigned int d = 0; - unsigned short s = 0; - unsigned char bus; - unsigned char dev; - unsigned char fun; - unsigned char hd = 0; - - for (bus=0; bus<pci_bus_count(); 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; + int sig, rval; + + rval = pcib_find_by_devid(vendorid, deviceid, instance, &sig); + + if ( PCIB_ERR_SUCCESS == rval ) { + *pbus = PCIB_DEVSIG_BUS(sig); + *pdev = PCIB_DEVSIG_DEV(sig); + *pfun = PCIB_DEVSIG_FUNC(sig); + } + + return rval; } /* |