I'm trying to understand how to instruct the CPU to instruct a PCI device to map its memory to the physical address of the CPU.
I've read https://wiki.osdev.org/PCI#Memory_Mapped_PCI_Configuration_Space_Access and I understand how to configure a PCI device through the IO ports of the CPU:
Two 32-bit I/O locations are used, the first location (0xCF8) is named CONFIG_ADDRESS, and the second (0xCFC) is called CONFIG_DATA. CONFIG_ADDRESS specifies the configuration address that is required to be accesses, while accesses to CONFIG_DATA will actually generate the configuration access and will transfer the data to or from the CONFIG_DATA register.
So in order to configure a PCI device I just need to put the configuration address that I want to configure and CONFIG_DATA is where I put the data. Both of these are I/O locations, so I ise I/O instructions in the CPU.
These two I/O locations give me access to a 256byte "big register" that I can use to configure the PCI device. All the fields of this big register are described in the OSDEV page. These 2 bits are of interest:
Memory Space - If set to 1 the device can respond to Memory Space accesses; otherwise, the device's response is disabled.
I/O Space - If set to 1 the device can respond to I/O Space accesses; otherwise, the device's response is disabled.
However apart from this, it's not clear on how to get or set the physical address space where each PCI device is going to respond