72
73
} pcilib_dma_flags_t;
76
PCILIB_STREAMING_STOP = 0, /**< stop streaming */
77
PCILIB_STREAMING_CONTINUE = 1, /**< wait the default DMA timeout for a new data */
78
PCILIB_STREAMING_WAIT = 2, /**< wait the specified timeout for a new data */
79
PCILIB_STREAMING_CHECK = 3, /**< do not wait for the data, bail out imideatly if no data ready */
80
PCILIB_STREAMING_FAIL = 4, /**< fail if data is not available on timeout */
81
PCILIB_STREAMING_REQ_FRAGMENT = 5, /**< only fragment of a packet is read, wait for next fragment and fail if no data during DMA timeout */
82
PCILIB_STREAMING_REQ_PACKET = 6, /**< wait for next packet and fail if no data during the specified timeout */
83
PCILIB_STREAMING_TIMEOUT_MASK = 3 /**< mask specifying all timeout modes */
84
} pcilib_streaming_action;
88
PCILIB_EVENT_FLAGS_DEFAULT = 0,
89
PCILIB_EVENT_FLAG_RAW_DATA_ONLY = 1,
90
PCILIB_EVENT_FLAG_EOF = 2
91
} pcilib_event_flags_t;
75
94
PCILIB_REGISTER_STANDARD = 0,
76
95
PCILIB_REGISTER_FIFO,
77
96
PCILIB_REGISTER_BITS
99
118
#define PCILIB_EVENT3 8
100
119
#define PCILIB_EVENTS_ALL ((pcilib_event_t)-1)
101
120
#define PCILIB_EVENT_INVALID ((pcilib_event_t)-1)
102
#define PCILIB_EVENT_ID_INVALID 0
121
//#define PCILIB_EVENT_ID_INVALID 0
103
122
#define PCILIB_TIMEOUT_INFINITE ((pcilib_timeout_t)-1)
104
123
#define PCILIB_TIMEOUT_IMMEDIATE 0
105
124
#define PCILIB_TIMEOUT_TRIGGER 0
106
125
#define PCILIB_IRQ_SOURCE_DEFAULT 0
130
uint64_t seqnum; /* we will add seqnum_overflow if required */
131
uint64_t offset; /* nanoseconds */
132
struct timeval timestamp; /* most accurate timestamp */
133
} pcilib_event_info_t;
109
136
* Callback function called when new data is read by DMA streaming function
110
137
* @ctx - DMA Engine context
115
142
* <0 - error, stop streaming (the value is negative error code)
117
* 1 - wait & read next buffer, fail if no data
118
* 2 - wait & read next buffer, but don't fail if timeout expired
119
* 3 - read next buffer if available (don't wait), don't fail
143
* 0 - stop streaming (PCILIB_STREAMING_STOP)
144
* 1 - wait DMA timeout and return gracefuly if no data (PCILIB_STREAMING_CONTINUE)
145
* 2 - wait the specified timeout and return gracefuly if no data (PCILIB_STREAMING_WAIT)
146
* 3 - check if more data is available without waiting, return gracefuly if not (PCILIB_STREAMING_CHECK)
147
* 5 - wait DMA timeout and fail if no data (PCILIB_STREAMING_REQ_FRAGMENT)
148
* 6 - wait the specified timeout and fail if no data (PCILIB_STREAMING_REQ_PACKET)
121
150
typedef int (*pcilib_dma_callback_t)(void *ctx, pcilib_dma_flags_t flags, size_t bufsize, void *buf);
122
typedef int (*pcilib_event_callback_t)(pcilib_event_t event, pcilib_event_id_t event_id, void *user);
151
typedef int (*pcilib_event_callback_t)(pcilib_event_id_t event_id, pcilib_event_info_t *info, void *user);
152
typedef int (*pcilib_event_rawdata_callback_t)(pcilib_event_id_t event_id, pcilib_event_info_t *info, pcilib_event_flags_t flags, size_t size, void *data, void *user);
125
155
pcilib_register_bank_addr_t addr;
242
281
pcilib_register_bank_t pcilib_find_bank(pcilib_t *ctx, const char *bank);
243
282
pcilib_register_t pcilib_find_register(pcilib_t *ctx, const char *bank, const char *reg);
244
283
pcilib_event_t pcilib_find_event(pcilib_t *ctx, const char *event);
284
pcilib_event_data_type_t pcilib_find_event_data_type(pcilib_t *ctx, pcilib_event_t event, const char *data_type);
245
285
pcilib_dma_engine_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direction, pcilib_dma_engine_addr_t dma);
247
287
int pcilib_read(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, void *buf);
265
305
int pcilib_write_register(pcilib_t *ctx, const char *bank, const char *regname, pcilib_register_value_t value);
267
307
int pcilib_reset(pcilib_t *ctx);
268
int pcilib_start(pcilib_t *ctx, pcilib_event_t event_mask, void *callback, void *user);
269
int pcilib_stop(pcilib_t *ctx);
271
308
int pcilib_trigger(pcilib_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
273
pcilib_event_id_t pcilib_get_next_event(pcilib_t *ctx, pcilib_event_t event_mask, pcilib_timeout_t timeout);
311
* The recording of new events will be stopped after reaching max_events records
312
* or when the specified amount of time is elapsed. However, the @pcilib_stop
313
* function should be called still.
314
* NOTE: This options may not be respected if the PCILIB_EVENT_FLAG_RAW_DATA_ONLY
317
int pcilib_configure_autostop(pcilib_t *ctx, size_t max_events, pcilib_timeout_t duration);
319
* Request streaming the rawdata from the event engine. It is fastest way to acuqire data.
320
* No memory copies will be performed and DMA buffers will be directly passed to the user
321
* callback. However, to prevent data loss, no processing should be done on the data. The
322
* user callback is only expected to copy data into the appropriate place and return control
323
* to the event engine.
324
* The performance can be boosted further by disabling any data processing within the event
325
* engine. Just pass PCILIB_EVENT_FLAG_RAW_DATA_ONLY flag to the @pcilib_start function.
327
int pcilib_configure_rawdata_callback(pcilib_t *ctx, pcilib_event_rawdata_callback_t callback, void *user);
329
int pcilib_start(pcilib_t *ctx, pcilib_event_t event_mask, pcilib_event_flags_t flags);
330
int pcilib_stop(pcilib_t *ctx, pcilib_event_flags_t flags);
331
int pcilib_stream(pcilib_t *ctx, pcilib_event_callback_t callback, void *user);
333
int pcilib_get_next_event(pcilib_t *ctx, pcilib_timeout_t timeout, pcilib_event_id_t *evid, pcilib_event_info_t **info);
334
int pcilib_copy_data(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t size, void *buf, size_t *retsize);
335
int pcilib_copy_data_with_argument(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t size, void *buf, size_t *retsize);
274
336
void *pcilib_get_data(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t *size);
275
337
void *pcilib_get_data_with_argument(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size);
277
340
* This function is provided to find potentially corrupted data. If the data is overwritten by
278
* the time return_data is called it will return error.
341
* the time return_data is called it will return error.
280
int pcilib_return_data(pcilib_t *ctx, pcilib_event_id_t event_id);
343
int pcilib_return_data(pcilib_t *ctx, pcilib_event_id_t event_id, void *data);
283
348
* @param data - will be allocated and shuld be freed if NULL, otherwise used and size should contain correct size.