I am working on an embedded PCIe system where two SoCs are connected together, the Host is a Root Complex, the Slave is an Endpoint. The Host will run Linux.
Typically the Host SoC provides memory windows, where the Endpoint BARs are mapped. This allows a card driver on the Host to read/write to IO or memory on the Slave. Often, the Slave will include a DMAC built into the PCIe IP, that works with a PCIe address and a local address. The Host will setup this DMAC by writing to the memory windows.
In my case, the Endpoint doesn't have a DMAC built in to the PCIe IP, but is does have a system DMAC. So, two questions...
Any help appreciated!
The BARs reside within the legacy confiuration space. As of such, that register can only be reached with a CfgRd or CfgWr. These TLPs (Transaction Layer Packets) can only be originated from an RC. So how would the EP know what are the valid memory addresses of the RC ? tough question, the PCI-Express specification have no answer for that. In reality there are regions that are more likely to be allocated than others, so you can make an educated guess.
Accessing a BAR requires at least 2 TLPs: the request (CfgWr or CfgRd) and the appropriate completion (Cpl or CplD, respectively).
I hope that helps,