I'm currently working on developing an operating system, and I'm trying to implement PCI. Specifically, I'm trying to implement an RTL8139 driver, not that that detail matters. Anyways, as far as I'm aware, I'm supposed to use I/O and not memory mapping to address the different registers, and I'm having a bit of trouble understanding one thing in particular:
The Base Address Registers in PCI configuration space are of 32-bit width. To my understanding, the x86 I/O bus uses 16-bit port numbers. I can't seem to find an explanation for how to use the BARs properly, other than to configure them and use that address, which, knowing this, doesn't make sense. I'm aware of the requirement to align by 4 (for I/O), but I'm not sure how to work with the addresses. Am I supposed to use only the lower 16 bits? Is there some other operation I need to do?
I would appreciate it if this could be clarified. Thanks in advance.