#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <ngc/core/ngcbAddr.h>#include <ngc/core/ngcbSched.h>Go to the source code of this file.
Classes | |
| struct | ngcb_dma_p_t |
| struct | ngcb_dma_api |
| struct | ngcb_mod_t |
| struct | ngcb_dma_t |
| struct | ngcb_burst_t |
Macros | |
| #define | USE(x) |
| #define | str2str(s1, s2, n) |
| #define | ngcbCOM_DEFAULT_DEVICE "/dev/ngc0_com" |
| #define | ngcbDMA_DEFAULT_DEVICE "/dev/ngc0_dma" |
| #define | ngcbCOM_DEFAULT_TIMEOUT 5 |
| #define | ngcbCOM_FIFO_SIZE 128 |
| #define | ngcbDMA_ERR_FIFO_OVERFLOW 0x1 |
| #define | ngcbDMA_ERR_IPP_OVERRUN 0x2 |
| #define | ngcbPRI_DMA_BURST 20 |
Typedefs | |
| typedef int(* | ngcbDMA_ALLOC) (ngcb_dma_p_t *dma, unsigned char **buffer, int num, size_t size, char *erms) |
| typedef void(* | ngcbDMA_FREE) (ngcb_dma_p_t *dma, unsigned char **buffer, int num) |
| typedef int(* | ngcbDMA_OPEN) (const char *devName, ngcb_dma_p_t *dma, char *erms) |
| typedef int(* | ngcbDMA_CLOSE) (ngcb_dma_p_t *dma, char *erms) |
| typedef int(* | ngcbDMA_INIT) (ngcb_dma_p_t *dma, unsigned char **buffer, int num, size_t size, unsigned int *doneCount, char *erms) |
| typedef int(* | ngcbDMA_STOP) (ngcb_dma_p_t *dma, char *erms) |
| typedef int(* | ngcbDMA_CLR) (ngcb_dma_p_t *dma, char *erms) |
| typedef int(* | ngcbDMA_GETCNT) (ngcb_dma_p_t *dma, unsigned int *cnt, char *erms) |
| typedef int(* | ngcbDMA_WAIT) (ngcb_dma_p_t *dma, uint64_t *ts, char *erms) |
| typedef int(* | ngcbDMA_STAT) (ngcb_dma_p_t *dma, int *err, int *stat, char *erms) |
| typedef int(* | ngcbDMA_OVERFLOW) (ngcb_dma_p_t *dma, char *erms) |
| typedef int(* | ngcbDMA_IPP) (ngcb_dma_p_t *dma, int id, int *param, unsigned int n, char *erms) |
| typedef int(* | ngcbDMA_DEVRD) (ngcb_dma_p_t *dma, unsigned int addr, unsigned int *value, char *erms) |
| typedef int(* | ngcbDMA_DEVWR) (ngcb_dma_p_t *dma, unsigned int addr, unsigned int value, char *erms) |
| typedef int(* | ngcb_dma_select) (const char *devName, ngcb_dma_api *api) |
Functions | |
| int | ngcbComOpen (const char *name, char *erms) |
| int | ngcbComClose (int fd) |
| int | ngcbComGetRev (int fd) |
| int | ngcbComRstDev (int fd) |
| int | ngcbComReset (int fd) |
| int | ngcbComTimeout (int fd, int seconds) |
| int | ngcbComUpLink (int fd, int routeThrough, int rst) |
| int | ngcbComRead (int fd, char *buffer, int size, char *erms) |
| int | ngcbComWrite (int fd, const char *buffer, int size, char *erms) |
| int | ngcbComReadStatus (int fd) |
| int | ngcbComErrStatus (void) |
| void | ngcbComErrStr (int status, char *s) |
| void | ngcbComStatStr (int status, char *s) |
| void | ngcbModInit (ngcb_mod_t *m) |
| int | ngcbModOpen (const char *path, ngcb_mod_t *m, char *erms) |
| int | ngcbModClose (ngcb_mod_t *m, char *erms) |
| int | ngcbModTimeout (ngcb_mod_t *m, int seconds, char *erms) |
| int | ngcbModFifo (ngcb_mod_t *m, int size, char *erms) |
| int | ngcbModRead (ngcb_mod_t *m, int addr, int *buffer, int size, char *erms) |
| int | ngcbModWrite (ngcb_mod_t *m, int addr, const int *buffer, int size, char *erms) |
| int | ngcbModWait (ngcb_mod_t *m, int addr, int mask, int timeout, char *erms) |
| 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 | 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 | ngcbDmaClr (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) |
| int | ngcbDma0Open (const char *devName, ngcb_dma_p_t *dma, char *erms) |
| int | ngcbDma0Close (ngcb_dma_p_t *dma, char *erms) |
| int | ngcbDma0Alloc (ngcb_dma_p_t *dma, unsigned char **buffer, int num, size_t size, char *erms) |
| void | ngcbDma0Free (ngcb_dma_p_t *dma, unsigned char **buffer, int num) |
| int | ngcbDma0Clr (ngcb_dma_p_t *dma, char *erms) |
| int | ngcbDma0Init (ngcb_dma_p_t *dma, unsigned char **buffer, int num, size_t size, unsigned int *doneCount, char *erms) |
| int | ngcbDma0Stop (ngcb_dma_p_t *dma, char *erms) |
| int | ngcbDma0GetCnt (ngcb_dma_p_t *dma, unsigned int *cnt, char *erms) |
| int | ngcbDma0Wait (ngcb_dma_p_t *dma, uint64_t *ts, char *erms) |
| int | ngcbDma0Stat (ngcb_dma_p_t *dma, int *err, int *stat, char *erms) |
| int | ngcbDma0Overflow (ngcb_dma_p_t *dma, char *erms) |
| int | ngcbDma0IppCfg (ngcb_dma_p_t *dma, int id, int *param, unsigned int n, char *erms) |
| int | ngcbDma0DevRd (ngcb_dma_p_t *dma, unsigned int addr, unsigned int *value, char *erms) |
| int | ngcbDma0DevWr (ngcb_dma_p_t *dma, unsigned int addr, unsigned int value, char *erms) |
| int | ngcbDmaBurstInit (ngcb_burst_t *burst, char *erms) |
| void | ngcbDmaBurstRelease (ngcb_burst_t *burst) |
| int | ngcbDmaBurstOpen (const char *devName, ngcb_burst_t *burst, char *erms) |
| int | ngcbDmaBurstClose (ngcb_burst_t *burst, char *erms) |
| int | ngcbDmaBurstAlloc (ngcb_burst_t *burst, size_t size, size_t dmaSize, int numBuf, char *erms) |
| void | ngcbDmaBurstFree (ngcb_burst_t *burst) |
| int | ngcbDmaBurstStart (ngcb_burst_t *burst, char *erms) |
| int | ngcbDmaBurstStop (ngcb_burst_t *burst, char *erms) |
| int | ngcbDmaBurstWait (ngcb_burst_t *burst, char *erms) |
Variables | |
| ngcb_dma_select | ngcbDmaApiSelect |
| ngcb_dma_api | ngcbDma0 |
| ngcb_dma_api | ngcbDmaPci |
| ngcb_dma_api | ngcbAcqTcp |
| ngcb_dma_api | ngcbAcqUdp |
| ngcb_dma_api | ngcbDmaRtSim |
| #define ngcbCOM_DEFAULT_DEVICE "/dev/ngc0_com" |
Default communication device
| #define ngcbCOM_DEFAULT_TIMEOUT 5 |
Default timeout (in seconds)
| #define ngcbCOM_FIFO_SIZE 128 |
FIFO size (in words)
| #define ngcbDMA_DEFAULT_DEVICE "/dev/ngc0_dma" |
Default DMA device
| #define ngcbDMA_ERR_FIFO_OVERFLOW 0x1 |
DMA input FIFO overflow
| #define ngcbDMA_ERR_IPP_OVERRUN 0x2 |
IPP DMA-overrun
| #define ngcbPRI_DMA_BURST 20 |
Burst priority
| #define str2str | ( | s1, | |
| s2, | |||
| n ) |
| #define USE | ( | x | ) |
| typedef int(* ngcb_dma_select) (const char *devName, ngcb_dma_api *api) |
DMA API selection type
| typedef int(* ngcbDMA_ALLOC) (ngcb_dma_p_t *dma, unsigned char **buffer, int num, size_t size, char *erms) |
Allocation function
| typedef int(* ngcbDMA_CLOSE) (ngcb_dma_p_t *dma, char *erms) |
DMA close function
| typedef int(* ngcbDMA_CLR) (ngcb_dma_p_t *dma, char *erms) |
DMA clear function
| typedef int(* ngcbDMA_DEVRD) (ngcb_dma_p_t *dma, unsigned int addr, unsigned int *value, char *erms) |
Function to read a value from an address in the DMA device address space
| typedef int(* ngcbDMA_DEVWR) (ngcb_dma_p_t *dma, unsigned int addr, unsigned int value, char *erms) |
Function to write a value to an address in the DMA device address space
| typedef void(* ngcbDMA_FREE) (ngcb_dma_p_t *dma, unsigned char **buffer, int num) |
Buffer free function
| typedef int(* ngcbDMA_GETCNT) (ngcb_dma_p_t *dma, unsigned int *cnt, char *erms) |
DMA counter function
| typedef int(* ngcbDMA_INIT) (ngcb_dma_p_t *dma, unsigned char **buffer, int num, size_t size, unsigned int *doneCount, char *erms) |
DMA initialization function
| typedef int(* ngcbDMA_IPP) (ngcb_dma_p_t *dma, int id, int *param, unsigned int n, char *erms) |
DMA interrupt post-processor configuration
| typedef int(* ngcbDMA_OPEN) (const char *devName, ngcb_dma_p_t *dma, char *erms) |
DMA open function
| typedef int(* ngcbDMA_OVERFLOW) (ngcb_dma_p_t *dma, char *erms) |
DMA overflow function
| typedef int(* ngcbDMA_STAT) (ngcb_dma_p_t *dma, int *err, int *stat, char *erms) |
DMA status function
| typedef int(* ngcbDMA_STOP) (ngcb_dma_p_t *dma, char *erms) |
DMA stop function
| typedef int(* ngcbDMA_WAIT) (ngcb_dma_p_t *dma, uint64_t *ts, char *erms) |
DMA wait function
| int ngcbComClose | ( | int | fd | ) |
Close the connection to the front-end.
| int ngcbComErrStatus | ( | void | ) |
Return the saved status value of the last faulty I/O. The saved value is reset to zero on each device open/close.
| void ngcbComErrStr | ( | int | status, |
| char * | s ) |
Convert status to an error string
| int ngcbComGetRev | ( | int | fd | ) |
Return the device driver and hardware revsion. The value is a 32-bit integer scalar containing the driver revision in the lower 16 bits and the hardware revision in the upper 16 bits. Both numbers are virtual and reflect only major changes which are relevant for the application SW.
| int ngcbComOpen | ( | const char * | name, |
| char * | erms ) |
Open connection to the front-end.
| int ngcbComRead | ( | int | fd, |
| char * | buffer, | ||
| int | size, | ||
| char * | erms ) |
Read a number of bytes from the device.
| int ngcbComReadStatus | ( | int | fd | ) |
Return the actual value of the communication status register
| int ngcbComReset | ( | int | fd | ) |
Performs a reset of the subsystem.
| int ngcbComRstDev | ( | int | fd | ) |
Performs an interface device reset.
| void ngcbComStatStr | ( | int | status, |
| char * | s ) |
Convert status to a string
| int ngcbComTimeout | ( | int | fd, |
| int | seconds ) |
Sets the timeout for read/write accesses in seconds.
| int ngcbComUpLink | ( | int | fd, |
| int | routeThrough, | ||
| int | rst ) |
Configure the number of nodes to route through and the route-length from the last skipped node to the front-end global reset function.
| int ngcbComWrite | ( | int | fd, |
| const char * | buffer, | ||
| int | size, | ||
| char * | erms ) |
Write a number of bytes to the device.
| int ngcbDma0Alloc | ( | ngcb_dma_p_t * | dma, |
| unsigned char ** | buffer, | ||
| int | num, | ||
| size_t | size, | ||
| char * | erms ) |
Template API for ngcbDmaAlloc().
| int ngcbDma0Close | ( | ngcb_dma_p_t * | dma, |
| char * | erms ) |
Template API for ngcbDmaClose().
| int ngcbDma0Clr | ( | ngcb_dma_p_t * | dma, |
| char * | erms ) |
Template API for ngcbDmaClr().
| int ngcbDma0DevRd | ( | ngcb_dma_p_t * | dma, |
| unsigned int | addr, | ||
| unsigned int * | value, | ||
| char * | erms ) |
Template API for ngcbDmaDevRd().
| int ngcbDma0DevWr | ( | ngcb_dma_p_t * | dma, |
| unsigned int | addr, | ||
| unsigned int | value, | ||
| char * | erms ) |
Template API for ngcbDmaDevWr().
| void ngcbDma0Free | ( | ngcb_dma_p_t * | dma, |
| unsigned char ** | buffer, | ||
| int | num ) |
Template API for ngcbDmaFree().
| int ngcbDma0GetCnt | ( | ngcb_dma_p_t * | dma, |
| unsigned int * | cnt, | ||
| char * | erms ) |
Template API for ngcbDmaGetCnt().
| int ngcbDma0Init | ( | ngcb_dma_p_t * | dma, |
| unsigned char ** | buffer, | ||
| int | num, | ||
| size_t | size, | ||
| unsigned int * | doneCount, | ||
| char * | erms ) |
Template API for ngcbDmaInit().
| int ngcbDma0IppCfg | ( | ngcb_dma_p_t * | dma, |
| int | id, | ||
| int * | param, | ||
| unsigned int | n, | ||
| char * | erms ) |
Template API for ngcbDmaIppCfg().
| int ngcbDma0Open | ( | const char * | devName, |
| ngcb_dma_p_t * | dma, | ||
| char * | erms ) |
Template API for ngcbDmaOpen().
| int ngcbDma0Overflow | ( | ngcb_dma_p_t * | dma, |
| char * | erms ) |
Template API for ngcbDmaOverflow().
| int ngcbDma0Stat | ( | ngcb_dma_p_t * | dma, |
| int * | err, | ||
| int * | stat, | ||
| char * | erms ) |
Template API for ngcbDmaStat().
| int ngcbDma0Stop | ( | ngcb_dma_p_t * | dma, |
| char * | erms ) |
Template API for ngcbDmaStop().
| int ngcbDma0Wait | ( | ngcb_dma_p_t * | dma, |
| uint64_t * | ts, | ||
| char * | erms ) |
Template API for ngcbDmaWait().
| 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 ngcbDmaBurstAlloc | ( | ngcb_burst_t * | burst, |
| size_t | size, | ||
| size_t | dmaSize, | ||
| int | numBuf, | ||
| char * | erms ) |
Allocate a burst buffer of the given size (in bytes) and also a DMA ring-buffer with numBuf elements. The size of each element is dmaSize bytes.
| int ngcbDmaBurstClose | ( | ngcb_burst_t * | burst, |
| char * | erms ) |
Close a DMA-burst device. This will also call the ngcbDmaBurstFree() function.
| void ngcbDmaBurstFree | ( | ngcb_burst_t * | burst | ) |
Free all buffers allocated with ngcbDmaBurstAlloc(). When already freed this function has no further effect.
| int ngcbDmaBurstInit | ( | ngcb_burst_t * | burst, |
| char * | erms ) |
Initialize the ngcb_burst_t object. The function should be called once before using the other functions.
| int ngcbDmaBurstOpen | ( | const char * | devName, |
| ngcb_burst_t * | burst, | ||
| char * | erms ) |
Open a DMA device for burst transfer.
| void ngcbDmaBurstRelease | ( | ngcb_burst_t * | burst | ) |
Release the ngcb_burst_t object. The function should be called once when the object is no longer used. This function must not be called from within a signal handler
| int ngcbDmaBurstStart | ( | ngcb_burst_t * | burst, |
| char * | erms ) |
Start a burst transfer with the parameters as given in the object structure.
| int ngcbDmaBurstStop | ( | ngcb_burst_t * | burst, |
| char * | erms ) |
Stop a burst transfer. It should always be called once when the burst transfer is over.
| int ngcbDmaBurstWait | ( | ngcb_burst_t * | burst, |
| char * | erms ) |
Suspend the process execution until the next chunk of dma data has been put to the burst buffer in the ngcb_burst_t object.
| 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.
| int ngcbModClose | ( | ngcb_mod_t * | m, |
| char * | erms ) |
Close DFE module interface
| int ngcbModFifo | ( | ngcb_mod_t * | m, |
| int | size, | ||
| char * | erms ) |
Set the transfer FIFO size (in 32-bit words). The default FIFO size is 128 words for backwards compatibility reasons. Current maximum is 1024 words. There are various setups in between. To optimize performance, the calling application may adapt the FIFO size depending on the board and revision to be addressed.
| void ngcbModInit | ( | ngcb_mod_t * | m | ) |
Initialze module handle
| int ngcbModOpen | ( | const char * | path, |
| ngcb_mod_t * | m, | ||
| char * | erms ) |
Open and enable path to DFE module
| int ngcbModRead | ( | ngcb_mod_t * | m, |
| int | addr, | ||
| int * | buffer, | ||
| int | size, | ||
| char * | erms ) |
Read a buffer from an address on a DFE-module
| int ngcbModTimeout | ( | ngcb_mod_t * | m, |
| int | seconds, | ||
| char * | erms ) |
Set the timeout for read/write accesses in seconds
| int ngcbModWait | ( | ngcb_mod_t * | m, |
| int | addr, | ||
| int | mask, | ||
| int | timeout, | ||
| char * | erms ) |
Poll address until all bits in mask are set. The timeout is given in seconds. A negative value indicates an infinite timoeut.
| int ngcbModWrite | ( | ngcb_mod_t * | m, |
| int | addr, | ||
| const int * | buffer, | ||
| int | size, | ||
| char * | erms ) |
Write a buffer to an address on a DFE-module
|
extern |
DMA TCP/IP API
DMA API
|
extern |
DMA UDP API
API
|
extern |
DMA template API
|
extern |
External procedure to register application specific DMA APIs
|
extern |
DMA PCI API
|
extern |
DMA Real-Time Simulation API
DMA API