PCI Configuration space

Hi all
I read the configuration space of a PCI Serial Comm card through a programme. There are 6 DWORD resisters for Base Address Registers.
I got the values like this:
Base Address Register[0] = 0
Base Address Register[1] = cc00H
Base Address Register[2] = cc08H
Base Address Register[3] = cc…H
Base Address Register[4] = 0
Base Address Register[5] = 0

My doubt is
A) Why there are Three Base values I m getting?
B) To check Memory mapped/IO mapped which value to use in the PCI_IS_IO(address)/PCI_IS_MEM() Macro.

Can anybody please answer.

A) Probably because there is 3 serial port ont he card?

B) if ( PCI_IS_IO(xxx ) ) {
puts( “I’m IO based” );
if ( PCI_IS_MEM( xxx) ) {
puts(“I’m memory based” );

A) I guess you should read documentation on your PCI serial comm card; perhaps Mario is right and you have 3 i/o based UART-like sets of registers.
B) You have to use value which is actually stored in PCI config space. I.e pci_read_config32( … offset=0x14… ) will probably return something like 0xcc01, bit 0 set to 1 means it is I/O space and base address is 0xcc00 (to get I/O address you must clear two lower bits which have specific meanings). Those macros are provided for your convinience. If bit 0 set to 0, that means you have memory mapped space, and you have to analyse bits 1 and 2 (at least), if they are 00 you have 32-bit address; 10 means the address is 64 bits wide and you have to consider two consecurive 32-bit BARs as a pointer. Of course, to get physical memory address, you must clear lower 4 bits (which have special meaning described above) of the value read from config space. If you need more details, please read PCI local bus specification, chapter 6 is all about config space.

P.S. I didn’t pay attention you ask this is QNX4/2 forum, please use corresponding replacement for pci_read_config32() - PCI spec is the same, no matter which OS you use :slight_smile: