04-10-2018 07:53 PM - edited 04-10-2018 11:34 PM
Hi, I'm trying to understand the architecture about PYNQ Linux drivers. But I can't understand why they can bypass Linux kernel and directly operate hardware registers.
From the source code of PYNQ https://github.com/xilinx/pynq , I find out that the drivers are all built upon some C code that directly calls assembly code to read/write hardware registers, without any interaction with Linux Loadable Kernel Module (LKM) system.
For example, the DMA driver is defined in PYNQ/pynq/lib/dma.py, which calls a shared object libdma.so, whose data structures and functions are defined in PYNQ/pynq/lib/_pynq/_apf/axidma_v9_1/xaxidma.h, which in the end includes some assembly code defined in PYNQ/pynq/lib/_pynq/_apf/include/xpseudo_asm_gcc.h. Nothing is mentioned about Linux kernel module.
How does that work? It seems to me that it totally bypasses the whole Linux memory management system. What have I missed?
04-11-2018 12:42 AM - edited 04-11-2018 03:53 AM
UPDATE: I looked into more of dma.py, xlnk.py, overlay.py and mmio.py. It seems more clear to me.
In dma.py, there is 2 DMA class: LegacyDMA and DMA.
LegacyDMA calls /usr/lib/libsds_lib.so to allocate host buffers and do the phy_addr-virt_addr convertion, and calls libdma.so to operate registers and do the transfers.
The newer DMA needs an array allocated by Xlnk, which still calls /usr/lib/libsds_lib.so to allocate host buffers and do the phy_addr-virt_addr convertion. Mean while, it utilizes Python's built in mmap API to operate registers and do the transfers.
I'm looking for the source code compiling /usr/lib/libsds_lib.so, but with no luck. Does anybody know where to find it?
04-11-2018 12:21 PM
I think you misunderstand what pynq is doing. It is doing nothing more than memory mapping the address space of the IP and programming the registers. Just look at PL and MMIO. They python parses the bd.tcl to get the addresses of the IP blocks and then calls mmap with those addresses. This is the same thing an userspace driver does or commands like devmem do.