@Hans
The issue with the SDK in general is that the authors assume that the audience is familiar with the complete history of RKRMs or Amiga programming in general. And that the autodocs and wiki are a guide to what's changed since the 68k era.
In this case, it's the names of the fields in combination with the contents of the autodoc that are confusing.
From the autodoc:
CONFIG AND I/O SPACE ACCESS
Config space access is performed through six methods of the pci_device
interface, namely ReadConfigByte, ReadConfigWord and ReadConfigLong
for reading and WriteConfigByte, WriteConfigWord and WriteConfigLong
for writing. As an example, to read the vendor and device ID from a
device, the following source code could be used:
UWORD VendorID, DeviceID;
struct PCIInterface *pci_device = IPCI->FindDevice(...);
VendorID = pci_device->ReadConfigWord(PCI_VENDOR_ID);
DeviceID = pci_device->ReadConfigWord(PCI_DEVICE_ID);
No special device addressing is needed, no bus/dev/fn numbers
need to be given.
Likewise the access to I/O space is performed through six methods
called InByte, InWord and InLong for reading and OutByte, OutWord
and OutLong for writing.
MEMORY SPACE ACCESS
Memory space access is performed by reading/writing directly to/from
system memory addresses. However, the physical address range needs
to be taken into account. This can be obtained with GetResourceRange
and examining the Physical field in the PCIResourceRange structure.
The "Physical" field is only mentioned in combination with MEMORY SPACE ACCESS.
It tells me that I have to take the "physical address range" into account by obtaining the "Physical" field. It was my assumption that it tells me something about the actualy physical size of the BAR instead of allocated size (Size field). Some cards allow to use the unallocated/unused BAR memory as user defined memory. So up to now, I've ignored this value and always used the BaseAddress. For my drivers, there's no need for the physical address of a BAR anyways. Because PCIe cards come with their own DMA engine which you have to feed with the physical address of a buffer in main memory. Card to card transfers are in general not used/possible with PCIe.
Maybe the physical address is needed for a gfx card if you want to use the host DMA engine to transfer data from host memory to GFX memory. And if it was, I would have obtained it from the MMU in supervisor mode. Just like i do to obtain the physical memory address of a buffer in main memory.
But if you look at this structure in pci.h, the comment makes it clear that it's not a range but a "Physical base address of the range"
Edited by geennaam on 2023/9/13 9:30:34
Edited by geennaam on 2023/9/13 9:37:09