I am attempting to make use of some features on the IO Hub/ South Bridge on my SBC, but I can only seem to write a value of 0x03 to any of the bytes in the PCI configuration space. I have verified that this is the case with both my PCI reading routines and the pci -vvv comand.
QNX 6.3.2
Intel x86
[code]void pci_write()
{
void* hdl;
int phdl;
struct pci_dev_info inf;
unsigned char pciBuffer[100];
int readReturn;
unsigned long vendor;
unsigned long device;
unsigned long index;
unsigned long start;
unsigned long num;
unsigned long size;
// attach to the PCI Server
phdl = pci_attach(0);
if(phdl == -1)
{
printf("cannot access PCI Server\n");
pci_detach(phdl);
return;
}
memset(&inf, 0, sizeof(inf));
getval_ul(&vendor);
getval_ul(&device);
getval_ul(&index);
inf.VendorId = vendor;
inf.DeviceId = device;
hdl = pci_attach_device(NULL, PCI_SHARE | PCI_SEARCH_VENDEV, index, &inf);
if(hdl == NULL)
{
printf("cannot access PCI Device\n");
pci_detach_device(hdl);
pci_detach(phdl);
return;
}
getval_ul(&start);
getval_ul(&num);
getval_ul(&size);
if((size != 1) && (size != 2) && (size != 4))
{
printf("size parameter must be 1, 2 or 4\n");
pci_detach_device(hdl);
pci_detach(phdl);
}
int i, j;
for(i = 0; i < num; ++i);
{
unsigned long data;
getval_ul(&data);
for(j = 0; j < size; ++j)
{
pciBuffer[(i * size) + j] = ((unsigned char*)(&data))[j];
printf("byte %d = 0x%02x, 0x%02x\n", j, ((unsigned char*)(&data))[j], pciBuffer[(i * size) + j]);
}
for(j = size; j < 4; ++j)
{
printf("byte %d = 0x%02x, 0x%02x\n", j, ((unsigned char*)(&data))[j], pciBuffer[(i * size) + j]);
}
}
readReturn = pci_write_config(hdl, start, num, size, &(pciBuffer[0]));
if(readReturn != PCI_SUCCESS)
{
printf("unable to write to PCI config space\n");
pci_detach_device(hdl);
pci_detach(phdl);
return;
}
pci_detach_device(hdl);
pci_detach(phdl);
}
[/code]