I'm a newbie here so please be gentile.
I'm very confused by the pcie_sample.c file. The following code is found in main and it's an endpoint setting up his inbound address translation.
/* Configure Address Translation */
barCfg.location = pcie_LOCATION_LOCAL;
barCfg.mode = pcie_EP_MODE;
barCfg.base = PCIE_IB_LO_ADDR_S;
barCfg.prefetch = pcie_BAR_NON_PREF;
barCfg.type = pcie_BAR_TYPE32;
barCfg.memSpace = pcie_BAR_MEM_MEM;
barCfg.idx = PCIE_BAR_IDX_S;
if ((retVal = Pcie_cfgBar(handle, &barCfg)) != pcie_RET_OK)
{
System_printf ("Failed to configure BAR!\n");
exit(1);
}
ibCfg.ibBar = PCIE_BAR_IDX_S; /* Match BAR that was configured above*/
ibCfg.ibStartAddrLo = PCIE_IB_LO_ADDR_S;
ibCfg.ibStartAddrHi = PCIE_IB_HI_ADDR_S;
ibCfg.ibOffsetAddr = (uint32_t)pcieConvert_CoreLocal2GlobalAddr ((uint32_t)dstBuf.buf);
ibCfg.region = PCIE_IB_REGION_S;
I'm confused because the endpoint is setting up his ibStartAddrLo. However, this value should come from the Root Complex, right?
I guess that the sample code has been simplified for teaching purposes by using predefined PCIe address values: 0x7000_0000 for the EP and 0x9000_0000 for the RC. The problem is that the proper technique for an EP to learn his PCIe address is not documented.
Am I right? If so, can you point me to example code that illustrates this process?
Thanks a bunch.