Access PCI-e memory with mmap

I use the PCI-e port on the Freescale MPC8308 processor (which is based on the PowerPC architecture), and I have some problems trying to use it. The final PCI-e device has a memory capacity of 256 MB. I can easily read and write endpoint device configuration space using the pciutils package.

After writing the correct values ​​in the configuration registers and obtaining permission to access memory; I tried to access memory using the "mmap ()" function in C and used the file descriptor located at:

"/ Sys / devices / pci0000: 00/0000: 00: 00,0 / resource0"

which was exactly 256 MB (equal to the memory size of the endpoint device), so it seems that I am using the correct path for the file descriptor. here you can find my code using "mmap ()", as indicated at https://github.com/billfarrow/pcimem :

https://github.com/billfarrow/pcimem/blob/master/pcimem.c

But unfortunately, when I try to use memory space, using the returned address of the function "mmap ()"; I cannot read endpoint device read-only registers correctly. Also, when I read addresses greater than "0x7FFFFFC", the MPC8308 reboots. Given the situation described above, can I not skip any steps to initialize the PCI-e interface? Do I have to change anything in the Linux kernel image or U-Boot codes? Is there anything else for using PowerPC PCI-e with mmap ()? Do you have any sample code that can help me read the PCI-e memory space?

thank

+4
source share
2 answers

mmap() - , PCIe .

, 0 mmap. FPGA-, x86, lspci, pcie. mmap. , BAR , , , lspci.

$ sudo lspci -s 02:00 -v
02:00.0 Memory controller: Xilinx Corporation Device 8028
    Subsystem: Xilinx Corporation Device 0007
    Flags: bus master, fast devsel, latency 0, IRQ 11
    Memory at f7e00000 (32-bit, non-prefetchable) [size=1M]
    Capabilities: [80] Power Management version 3
    Capabilities: [90] MSI: Enable- Count=1/1 Maskable- 64bit+
    Capabilities: [c0] Express Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
+1

: . , . MMAPing ( , ). , , . , . , , .

0

Source: https://habr.com/ru/post/1659690/


All Articles