In the module / driver, memory is allocated for DMA transactions through ioctl ():
kbuf = dma_alloc_coherent(NULL, CRU_DMA_BUF0_SIZE, &dma_handle, 0);
then the physical address is returned to the user space:
ret = put_user(virt_to_phys(kbuf), (unsigned long __user *)arg/*адрес переменной dma_buf в приложении*/);
in the application I try to zamapit this area of memory:
int fd = open("/dev/mem", O_RDWR|O_SYNC); if(mmap_dma = (unsigned long*) mmap(NULL, CRU_DMA_BUF0_SIZE, PROT_READ, MAP_SHARED, fd, dma_buf)) printf("Can't mapping DMA buffer\n");
#define CRU_DMA_BUF0_SIZE (0x00800000)