Dear fellow QNX 4.x users
I am working on an embedded pentium board with a PC/104+ PCI bus.
I have a PCI DSP peripheral board I am trying to access which has both a
standard configuration space for memory (PCI BAR0), the same footprint in IO
space (BAR1), and also shared DPSRAM in BAR2.
I can access the configuration space using the PCI_CONFIG functions in C,
but now I need to access the space designated by BAR2. I am pretty sure
either the PCI BIOS or QNX has preconfigured BAR2, but I am unsure.
There is a nonzero value in the BAR2 address vector, and the address is
alligned apropriately to a 32KB block, appropriate for the on board 32KB
DPSRAM. When I try to open a share to it, I can create the share, but when I
try to read it with a pointer pointed within that address space, the
application process gets terminated with some sort of read violation
(SIGSEGV). (I can have my cake, but can’t eat it.)
I have it opened for physical memory with:
if(retval = _CA_PCI_Read_Config_DWord(
bus_num, dev_func_num,
offsetof(struct _pci_config_regs,Base_Address_Regs[2]),
1, (char *)&address2 ) != PCI_SUCCESS)
{
printf(“Error reading PCI BAR 2 address %x\n”,retval);
return -1;
}/if/
/*
…
*/
if( (seg2 = shm_open(“Physical”,O_RDWR,0777)) == -1)
{
printf(“Error shared memory open, PCI BAR 2:\n %s\n”,
strerror(errno));
return -1;
}
else if( (PCI_OVERLAY_DPSRAM_PREALLIGNED =
mmap( 0, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, seg2,
PCI_MEM_ADDR(address2) & ~0xFFF )) == (void *)-1 )
{
printf(“Error shared memory maping, PCI BAR 2:\n %s\n”,
strerror(errno));
return -1;
}
else
{
PCI_OVERLAY_DPSRAM = PCI_OVERLAY_DPSRAM_PREALLIGNED
- (PCI_MEM_ADDR(address2)& 0xFFFF);
};
I’d appreciate it if someone could help me eat my cake.
Thanks,
Steve