pcibios.h
Hugo
hv at uninova.pt
Mon Sep 8 12:05:34 UTC 2003
Hi!
I am trying to use pcibios.h but so far I have been unable.
In the end of this message I show the part of the code that scans the
PCI.
Everytime I use pcib_conf_write32 I get the return -6.
Could anyone please tell me what I am doing wrong?!
Many thanks
HV
Here's the code:
#define PCI_CONFIG_ADDR 0x0CF8
#define PCI_CONFIG_DATA 0x0CFC
int pcibios_read_config_dword (unsigned char bus, unsigned char dev,
unsigned char fun, unsigned int *val) {
int res;
int sig = PCIB_DEVSIG_MAKE( bus, dev, fun );
res = pcib_conf_write32( sig, PCI_CONFIG_ADDR, *val );
if ( res < 0 ) {
perror("write32.");
return -1;
}
res = pcib_conf_read32( sig, PCI_CONFIG_DATA, val );
if ( res < 0 ) {
perror("read32.");
return -2;
}
return 0;
}
int find_pci( ) {
int pci_bus =0;
int pci_dev;
int pci_fun;
int dev_num = 0;
int res = pcib_init();
printf( "INIT: %d\n", res );
for( pci_dev=0; pci_dev<32; pci_dev++ ) {
for( pci_fun=0; pci_fun<8; pci_fun++ ) {
unsigned int pci_id = 0;
pcibios_read_config_dword( pci_bus, pci_dev, pci_fun, &pci_id );
if ( pci_id == 0xFFFFFFFF ) {
continue;
}
dev_num++;
printf( "Found pci_id: %x\n", pci_id );
}
}
return 0;
}
More information about the users
mailing list