#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <sys/mman.h> #include <sys/types.h> #include <fcntl.h> #include "altera_dma_cmd.h" #include "altera_dma_regs.h" #define BUFFER_LENGTH 40 unsigned int* pDmaUser; int main (int argc ,char** argv) { int i; int rc= 0; int on_chip_size = ( DMASIZE * 4 )*ALTERA_DMA_DESCRIPTOR_NUM ; ssize_t f; f = open ("/dev/pcie40_0_altdma", O_RDWR); if (f == -1) { printf ("Couldn't open the device.\n"); return 0; } else { printf ("Opened the device: file handle #%lu!\n", (long unsigned int)f); } pDmaUser= (unsigned int *) mmap( NULL , on_chip_size , PROT_READ|PROT_WRITE , MAP_SHARED , f , 0x000); rc = ioctl(f, ALTERA_IOCX_START); if (( pDmaUser!= NULL)&(rc >0) ) { for (i= 0 ;i < DMASIZE;i++) printf("0X%08x\n",pDmaUser[i]); } else { printf (" No data available :\n"); if (rc == -1) printf( "DMA too longs\n "); if (rc == -2) printf( "FIFO is empty \n "); } close (f); return 0 ; }