| 1 |
#include "libdha.h" |
| 2 |
#include "pci_names.h" |
| 3 |
#include <stdio.h> |
| 4 |
#include <string.h> |
| 5 |
#include <stdlib.h> |
| 6 |
#include <inttypes.h> /* for __WORDSIZE */ |
| 7 |
|
| 8 |
int main( void ) |
| 9 |
{ |
| 10 |
pciinfo_t lst[MAX_PCI_DEVICES]; |
| 11 |
unsigned i,num_pci; |
| 12 |
int err; |
| 13 |
err = pci_scan(lst,&num_pci); |
| 14 |
if(err) |
| 15 |
{ |
| 16 |
printf("Error occured during pci scan: %s\n",strerror(err)); |
| 17 |
return EXIT_FAILURE; |
| 18 |
} |
| 19 |
else |
| 20 |
{ |
| 21 |
printf(" Bus:card:func vend:dev base0 :base1 :base2 :baserom :irq:pin:gnt:lat\n"); |
| 22 |
for(i=0;i<num_pci;i++) |
| 23 |
#if __WORDSIZE > 32 |
| 24 |
printf("%04X:%04X:%04X %04X:%04X %16X:%16X:%16X:%16X:%02X :%02X :%02X :%02X\n" |
| 25 |
#else |
| 26 |
printf("%04X:%04X:%04X %04X:%04X %08X:%08X:%08X:%08X:%02X :%02X :%02X :%02X\n" |
| 27 |
#endif |
| 28 |
,lst[i].bus,lst[i].card,lst[i].func |
| 29 |
,lst[i].vendor,lst[i].device |
| 30 |
,lst[i].base0,lst[i].base1,lst[i].base2,lst[i].baserom |
| 31 |
,lst[i].irq,lst[i].ipin,lst[i].gnt,lst[i].lat); |
| 32 |
printf("Additional info:\n"); |
| 33 |
printf("================\n"); |
| 34 |
printf("base3 :base4 :base5 :name (vendor)\n"); |
| 35 |
for(i=0;i<num_pci;i++) |
| 36 |
{ |
| 37 |
const char *vname,*dname; |
| 38 |
dname = pci_device_name(lst[i].vendor,lst[i].device); |
| 39 |
dname = dname ? dname : "Unknown chip"; |
| 40 |
vname = pci_vendor_name(lst[i].vendor); |
| 41 |
vname = vname ? vname : "Unknown chip"; |
| 42 |
printf("%08X:%08X:%08X:%s (%s)\n" |
| 43 |
,lst[i].base3,lst[i].base4,lst[i].base5 |
| 44 |
,dname,vname); |
| 45 |
} |
| 46 |
} |
| 47 |
return EXIT_SUCCESS; |
| 48 |
} |