Changeset 734d1c5d in rtems for c/src/lib/libbsp/i386/shared/pci/pcibios.c
- Timestamp:
- Jul 18, 2003, 3:51:38 PM (18 years ago)
- Children:
- 552af999
- Parents:
- 367a0e2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/shared/pci/pcibios.c
r367a0e2 r734d1c5d 212 212 } 213 213 214 215 216 217 #define PCI_MULTI_FUNCTION 0x80 218 #define PCI_MAX_DEVICES 16 219 #define PCI_MAX_FUNCTIONS 8 220 221 222 int 223 BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid, 224 int instance, int *pbus, int *pdev, int *pfun ) 225 { 226 int sig; 227 unsigned int d; 228 unsigned short s; 229 unsigned char bus,dev,fun,hd; 230 231 for (bus=0; bus<BusCountPCI(); bus++) 232 { 233 for (dev=0; dev<PCI_MAX_DEVICES; dev++) 234 { 235 sig = PCIB_DEVSIG_MAKE(bus,dev,0); 236 237 /* pci_read_config_byte(bus,dev,0, PCI_HEADER_TYPE, &hd); */ 238 pcib_conf_read8(sig, 0xe, &hd); 239 240 hd = (hd & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1); 241 242 for (fun=0; fun<hd; fun++) { 243 /* 244 * The last devfn id/slot is special; must skip it 245 */ 246 if( PCI_MAX_DEVICES-1 == dev && PCI_MAX_FUNCTIONS-1 == fun ) 247 break; 248 249 /*pci_read_config_dword(bus,dev,fun,PCI_VENDOR_ID,&d); */ 250 pcib_conf_read32(sig, 0, &d); 251 if( d == -1 ) 252 continue; 253 #ifdef PCI_DEBUG 254 printk("BSP_pciFindDevice: found 0x%08x at %d/%d/%d\n",d,bus,dev,fun); 255 #endif 256 /* pci_read_config_word(bus,dev,fun,PCI_VENDOR_ID,&s); */ 257 pcib_conf_read16(sig, 0, &s); 258 if (vendorid != s) 259 continue; 260 261 /* pci_read_config_word(bus,dev,fun,PCI_DEVICE_ID,&s); */ 262 pcib_conf_read16(sig, 0x2, &s); 263 if (deviceid == s) { 264 if (instance--) continue; 265 *pbus=bus; 266 *pdev=dev; 267 *pfun=fun; 268 return 0; 269 } 270 } 271 } 272 } 273 return -1; 274 } 275 276 214 277 215 278
Note: See TracChangeset
for help on using the changeset viewer.