#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <string.h>#include <signal.h>#include <errno.h>#include <ngc/core/ngcbDrv.h>Macros | |
| #define | _GNU_SOURCE |
| #define | _REENTRANT |
Functions | |
| int | ngcbDmaOpen (const char *devName, ngcb_dma_t *dma, char *erms) |
| int | ngcbDmaClose (ngcb_dma_t *dma, char *erms) |
| int | ngcbDmaAlloc (ngcb_dma_t dma, unsigned char **buffer, int num, size_t size, char *erms) |
| void | ngcbDmaFree (ngcb_dma_t dma, unsigned char **buffer, int num) |
| int | ngcbDmaClr (ngcb_dma_t dma, char *erms) |
| int | ngcbDmaInit (ngcb_dma_t *dma, unsigned char **buffer, int num, size_t size, unsigned int *doneCount, char *erms) |
| int | ngcbDmaStop (ngcb_dma_t dma, char *erms) |
| int | ngcbDmaGetCnt (ngcb_dma_t dma, unsigned int *cnt, char *erms) |
| int | ngcbDmaWait (ngcb_dma_t dma, char *erms) |
| int | ngcbDmaWait2 (ngcb_dma_t dma, uint64_t *ts, char *erms) |
| int | ngcbDmaWaitTmo (ngcb_dma_t dma, int timeout, char *erms) |
| int | ngcbDmaWaitTmo2 (ngcb_dma_t dma, uint64_t *ts, int timeout, char *erms) |
| int | ngcbDmaStat (ngcb_dma_t dma, int *err, int *stat, char *erms) |
| int | ngcbDmaOverflow (ngcb_dma_t dma, char *erms) |
| int | ngcbDmaIppCfg (ngcb_dma_t dma, int id, int *param, unsigned int n, char *erms) |
| int | ngcbDmaDevRd (ngcb_dma_t dma, unsigned int addr, unsigned int *value, char *erms) |
| int | ngcbDmaDevWr (ngcb_dma_t dma, unsigned int addr, unsigned int value, char *erms) |
Variables | |
| ngcb_dma_select | ngcbDmaApiSelect = (ngcb_dma_select)NULL |
| #define _GNU_SOURCE |
| #define _REENTRANT |
| int ngcbDmaAlloc | ( | ngcb_dma_t | dma, |
| unsigned char ** | buffer, | ||
| int | num, | ||
| size_t | size, | ||
| char * | erms ) |
Allocate DMA ringbuffer elements with the specified size (in bytes). The buffer pointers have to be allocated by the calling application.
| int ngcbDmaClose | ( | ngcb_dma_t * | dma, |
| char * | erms ) |
Close the dma interface driver referred to by the device handle.
| int ngcbDmaClr | ( | ngcb_dma_t | dma, |
| char * | erms ) |
Clear all DMA data FIFOs.
| int ngcbDmaDevRd | ( | ngcb_dma_t | dma, |
| unsigned int | addr, | ||
| unsigned int * | value, | ||
| char * | erms ) |
Read a value from an address in the interface device address space.
| int ngcbDmaDevWr | ( | ngcb_dma_t | dma, |
| unsigned int | addr, | ||
| unsigned int | value, | ||
| char * | erms ) |
Write a value to an address in the interface device address space.
| void ngcbDmaFree | ( | ngcb_dma_t | dma, |
| unsigned char ** | buffer, | ||
| int | num ) |
Free the DMA ringbuffer space previously allocated with ngcbDmaAlloc().
| int ngcbDmaGetCnt | ( | ngcb_dma_t | dma, |
| unsigned int * | cnt, | ||
| char * | erms ) |
Get the current buffer counter. The counter wraps with 0xffffffff.
| int ngcbDmaInit | ( | ngcb_dma_t * | dma, |
| unsigned char ** | buffer, | ||
| int | num, | ||
| size_t | size, | ||
| unsigned int * | doneCount, | ||
| char * | erms ) |
Initiate a sustained ringbuffered DMA-read. The array of buffers has to be passed to the routine. num is the number of ringbuffer elements and size is the size (in bytes) of each buffer element. As current Linux kernel versions do no longer support DMA to user-space memory, the current implementation ignores the buf, num and size parameters and does the DMA to the buffers allocated/mapped in the kernel with ngcbDmaAlloc(). The parameters are left in here as user-space DMA may re-appear again and the applications may benefit from such an implementation. To keep the user space code compatible with such cases it is strongly recommended to pass the buf, num and size values from the ngcbDmaAlloc() routine into here. The doneCount is set by the routine as initial buffer counter. Usually this will be zero, but the value might differ when using future driver versions.
| int ngcbDmaIppCfg | ( | ngcb_dma_t | dma, |
| int | id, | ||
| int * | param, | ||
| unsigned int | n, | ||
| char * | erms ) |
DMA interrupt post-processor configuration.
| int ngcbDmaOpen | ( | const char * | devName, |
| ngcb_dma_t * | dma, | ||
| char * | erms ) |
Opens the dma interface driver with the given device name.
| int ngcbDmaOverflow | ( | ngcb_dma_t | dma, |
| char * | erms ) |
Returns a non zero value if the DMA raised an error flag. When the bit ngcbDMA_ERR_FIFO_OVERFLOW is set in the return value then the DMA input FIFO became full. The ngcbDMA_ERR_IPP_OVERRUN bit indicates an interrupt post-processor (IPP) overrun.
| int ngcbDmaStat | ( | ngcb_dma_t | dma, |
| int * | err, | ||
| int * | stat, | ||
| char * | erms ) |
Get errno and status of the reciever.
| int ngcbDmaStop | ( | ngcb_dma_t | dma, |
| char * | erms ) |
Stops the current DMA.
| int ngcbDmaWait | ( | ngcb_dma_t | dma, |
| char * | erms ) |
Suspends the calling routine until the next DMA-buffer has been received.
| int ngcbDmaWait2 | ( | ngcb_dma_t | dma, |
| uint64_t * | ts, | ||
| char * | erms ) |
Suspends the calling routine until the next DMA-buffer has been received and stores a timestamp for the buffer
| int ngcbDmaWaitTmo | ( | ngcb_dma_t | dma, |
| int | timeout, | ||
| char * | erms ) |
Suspend the calling routine until the next DMA-buffer has been received or the specified timeout (seconds) has been reached. In the latter case a value of -2 is returned. If timeout is zero then no timeout is applied.
| int ngcbDmaWaitTmo2 | ( | ngcb_dma_t | dma, |
| uint64_t * | ts, | ||
| int | timeout, | ||
| char * | erms ) |
Suspend the calling routine until the next DMA-buffer has been received or the specified timeout (seconds) has been reached. In the latter case a value of -2 is returned. If timeout is zero then no timeout is applied. The function storas a timestamp for the buffer.
| ngcb_dma_select ngcbDmaApiSelect = (ngcb_dma_select)NULL |
External procedure to register application specific DMA APIs