The key is the Unix system call – mmap
function.
The idea is to use mmap
function to map a memory-mapped components on FPGA, or a contiguous non-cacheable region of physical memory (not managed by the OS virtual memory) to the current software process's virtual memory space.
Here is an example C++ code.
/dev/mem
device file.mmap
function call requests to map a region of kSdramSize
bytes of physical memory starting at kSdramPhysicalAddress
, to the current program's virtual memory (referenced by sdram_mmap
).mmap
function maps konChipBufferSize
bytes of on-chip buffer starting at kOnChipBufferPhysicalAddressL3
, to the virtual memory (referenced by ocb_mmap
).The rest of the program then moves data back-and-forth between SDRAM and on-chip buffer using the 'memcpy' system call.