/alps/ipecamera

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/ipecamera

« back to all changes in this revision

Viewing changes to pcilib.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-27 00:28:57 UTC
  • Revision ID: csa@suren.me-20150427002857-82fk6r3e8rfgy4wr
First stand-alone ipecamera implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _PCITOOL_PCILIB_H
2
 
#define _PCITOOL_PCILIB_H
3
 
 
4
 
#define PCILIB_MAX_BANKS 6
5
 
#define PCILIB_MAX_DMA_ENGINES 32
6
 
 
7
 
#include <sys/time.h>
8
 
#include <stdint.h>
9
 
 
10
 
#define pcilib_memcpy pcilib_memcpy32
11
 
#define pcilib_datacpy pcilib_datacpy32
12
 
 
13
 
typedef struct pcilib_s pcilib_t;
14
 
typedef struct pcilib_event_context_s pcilib_context_t;
15
 
typedef struct pcilib_dma_context_s pcilib_dma_context_t;
16
 
 
17
 
 
18
 
typedef struct pcilib_dma_api_description_s pcilib_dma_api_description_t;
19
 
typedef struct pcilib_event_api_description_s pcilib_event_api_description_t;
20
 
typedef struct  pcilib_protocol_description_s pcilib_protocol_description_t;
21
 
typedef unsigned int pcilib_irq_hw_source_t;
22
 
typedef uint32_t pcilib_irq_source_t;
23
 
 
24
 
typedef uint8_t pcilib_bar_t;                   /**< Type holding the PCI Bar number */
25
 
typedef uint8_t pcilib_register_t;              /**< Type holding the register ID within the Bank */
26
 
typedef uint32_t pcilib_register_addr_t;        /**< Type holding the register ID within the Bank */
27
 
typedef uint8_t pcilib_register_bank_t;         /**< Type holding the register bank number */
28
 
typedef uint8_t pcilib_register_bank_addr_t;    /**< Type holding the register bank number */
29
 
typedef uint8_t pcilib_register_size_t;         /**< Type holding the size in bits of the register */
30
 
typedef uint32_t pcilib_register_value_t;       /**< Type holding the register value */
31
 
typedef uint8_t pcilib_dma_engine_addr_t;
32
 
typedef uint8_t pcilib_dma_engine_t;
33
 
typedef uint64_t pcilib_event_id_t;
34
 
typedef uint32_t pcilib_event_t;
35
 
typedef uint64_t pcilib_timeout_t;              /**< In microseconds */
36
 
 
37
 
typedef enum {
38
 
    PCILIB_HOST_ENDIAN = 0,
39
 
    PCILIB_LITTLE_ENDIAN,
40
 
    PCILIB_BIG_ENDIAN
41
 
} pcilib_endianess_t;
42
 
 
43
 
typedef enum {
44
 
    PCILIB_MODEL_DETECT,
45
 
    PCILIB_MODEL_PCI,
46
 
    PCILIB_MODEL_IPECAMERA,
47
 
    PCILIB_MODEL_KAPTURE
48
 
} pcilib_model_t;
49
 
 
50
 
typedef enum {
51
 
    PCILIB_REGISTER_R = 1,
52
 
    PCILIB_REGISTER_W = 2,
53
 
    PCILIB_REGISTER_RW = 3,
54
 
    PCILIB_REGISTER_W1C = 4,            /**< writting 1 resets the flag */
55
 
    PCILIB_REGISTER_RW1C = 5
56
 
} pcilib_register_mode_t;
57
 
 
58
 
typedef enum {
59
 
    PCILIB_DEFAULT_PROTOCOL,
60
 
    IPECAMERA_REGISTER_PROTOCOL
61
 
} pcilib_register_protocol_t;
62
 
 
63
 
typedef enum {
64
 
    PCILIB_EVENT_DATA = 0,              /**< default data format */
65
 
    PCILIB_EVENT_RAW_DATA = 1           /**< raw data */
66
 
} pcilib_event_data_type_t;
67
 
 
68
 
typedef enum {
69
 
    PCILIB_DMA_FLAGS_DEFAULT = 0,
70
 
    PCILIB_DMA_FLAG_EOP = 1,            /**< last buffer of the packet */
71
 
    PCILIB_DMA_FLAG_WAIT = 2,           /**< wait completion of write operation / wait for data during read operation */
72
 
    PCILIB_DMA_FLAG_MULTIPACKET = 4,    /**< read multiple packets */
73
 
    PCILIB_DMA_FLAG_PERSISTENT = 8,     /**< do not stop DMA engine on application termination / permanently close DMA engine on dma_stop */
74
 
    PCILIB_DMA_FLAG_IGNORE_ERRORS = 16  /**< do not crash on errors, but return appropriate error codes */
75
 
} pcilib_dma_flags_t;
76
 
 
77
 
typedef enum {
78
 
    PCILIB_STREAMING_STOP = 0,          /**< stop streaming */
79
 
    PCILIB_STREAMING_CONTINUE = 1,      /**< wait the default DMA timeout for a new data */
80
 
    PCILIB_STREAMING_WAIT = 2,          /**< wait the specified timeout for a new data */
81
 
    PCILIB_STREAMING_CHECK = 3,         /**< do not wait for the data, bail out imideatly if no data ready */
82
 
    PCILIB_STREAMING_FAIL = 4,          /**< fail if data is not available on timeout */
83
 
    PCILIB_STREAMING_REQ_FRAGMENT = 5,  /**< only fragment of a packet is read, wait for next fragment and fail if no data during DMA timeout */
84
 
    PCILIB_STREAMING_REQ_PACKET = 6,    /**< wait for next packet and fail if no data during the specified timeout */
85
 
    PCILIB_STREAMING_TIMEOUT_MASK = 3   /**< mask specifying all timeout modes */
86
 
} pcilib_streaming_action_t;
87
 
 
88
 
 
89
 
typedef enum {
90
 
    PCILIB_EVENT_FLAGS_DEFAULT = 0,
91
 
    PCILIB_EVENT_FLAG_RAW_DATA_ONLY = 1,        /**< Do not parse data, just read raw and pass it to rawdata callback. If passed to rawdata callback, idicates the data is not identified as event (most probably just padding) */
92
 
    PCILIB_EVENT_FLAG_STOP_ONLY = 1,            /**< Do not cleanup, just stop acquiring new frames, the cleanup should be requested afterwards */
93
 
    PCILIB_EVENT_FLAG_EOF = 2,                  /**< Indicates that it is the last part of the frame (not required) */
94
 
    PCILIB_EVENT_FLAG_PREPROCESS = 4            /**< Enables preprocessing of the raw data (decoding frames, etc.) */
95
 
} pcilib_event_flags_t;
96
 
 
97
 
typedef enum {
98
 
    PCILIB_EVENT_INFO_FLAG_BROKEN = 1           /**< Indicates broken frames (if this flag is fales, the frame still can be broken) */
99
 
} pcilib_event_info_flags_t;
100
 
 
101
 
typedef enum {
102
 
    PCILIB_REGISTER_STANDARD = 0,
103
 
    PCILIB_REGISTER_FIFO,
104
 
    PCILIB_REGISTER_BITS
105
 
} pcilib_register_type_t;
106
 
 
107
 
#define PCILIB_BAR_DETECT               ((pcilib_bar_t)-1)
108
 
#define PCILIB_BAR_INVALID              ((pcilib_bar_t)-1)
109
 
#define PCILIB_BAR0                     0
110
 
#define PCILIB_BAR1                     1
111
 
#define PCILIB_DMA_ENGINE_INVALID       ((pcilib_dma_engine_t)-1)
112
 
#define PCILIB_DMA_ENGINE_ALL           ((pcilib_dma_engine_t)-1)
113
 
#define PCILIB_DMA_FLAGS_DEFAULT        ((pcilib_dma_flags_t)0)
114
 
#define PCILIB_DMA_ENGINE_ADDR_INVALID  ((pcilib_dma_engine_addr_t)-1)
115
 
#define PCILIB_REGISTER_INVALID         ((pcilib_register_t)-1)
116
 
#define PCILIB_ADDRESS_INVALID          ((uintptr_t)-1)
117
 
#define PCILIB_REGISTER_BANK_INVALID    ((pcilib_register_bank_t)-1)
118
 
#define PCILIB_REGISTER_BANK0           0
119
 
#define PCILIB_REGISTER_BANK1           1
120
 
#define PCILIB_REGISTER_BANK2           2
121
 
#define PCILIB_REGISTER_BANK3           3
122
 
#define PCILIB_REGISTER_BANK_DMA        128
123
 
#define PCILIB_EVENT0                   1
124
 
#define PCILIB_EVENT1                   2
125
 
#define PCILIB_EVENT2                   4
126
 
#define PCILIB_EVENT3                   8
127
 
#define PCILIB_EVENTS_ALL               ((pcilib_event_t)-1)
128
 
#define PCILIB_EVENT_INVALID            ((pcilib_event_t)-1)
129
 
#define PCILIB_EVENT_DATA_TYPE_INVALID  ((pcilib_event_data_type_t)-1)
130
 
#define PCILIB_TIMEOUT_INFINITE         ((pcilib_timeout_t)-1)
131
 
#define PCILIB_TIMEOUT_IMMEDIATE        0
132
 
#define PCILIB_IRQ_TYPE_ALL             0
133
 
#define PCILIB_IRQ_SOURCE_DEFAULT       0
134
 
#define PCILIB_REGISTER_NO_BITS         0
135
 
#define PCILIB_REGISTER_ALL_BITS        ((pcilib_register_value_t)-1)
136
 
 
137
 
typedef struct {
138
 
    pcilib_event_t type;
139
 
    uint64_t seqnum;                    /**< we will add seqnum_overflow if required */
140
 
    uint64_t offset;                    /**< nanoseconds */
141
 
    struct timeval timestamp;           /**< most accurate timestamp */
142
 
    pcilib_event_info_flags_t flags;    /**< flags */
143
 
} pcilib_event_info_t;
144
 
 
145
 
/**<
146
 
 * Callback function called when new data is read by DMA streaming function
147
 
 * @ctx - DMA Engine context
148
 
 * @flags - DMA Flags
149
 
 * @bufsize - size of data in bytes
150
 
 * @buf - data
151
 
 * @returns 
152
 
 * <0 - error, stop streaming (the value is negative error code)
153
 
 *  0 - stop streaming (PCILIB_STREAMING_STOP)
154
 
 *  1 - wait DMA timeout and return gracefuly if no data (PCILIB_STREAMING_CONTINUE)
155
 
 *  2 - wait the specified timeout and return gracefuly if no data (PCILIB_STREAMING_WAIT)
156
 
 *  3 - check if more data is available without waiting, return gracefuly if not (PCILIB_STREAMING_CHECK)
157
 
 *  5 - wait DMA timeout and fail if no data (PCILIB_STREAMING_REQ_FRAGMENT)
158
 
 *  6 - wait the specified timeout and fail if no data (PCILIB_STREAMING_REQ_PACKET)
159
 
 */
160
 
typedef int (*pcilib_dma_callback_t)(void *ctx, pcilib_dma_flags_t flags, size_t bufsize, void *buf); 
161
 
typedef int (*pcilib_event_callback_t)(pcilib_event_id_t event_id, pcilib_event_info_t *info, void *user);
162
 
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);
163
 
 
164
 
typedef struct {
165
 
    pcilib_register_bank_addr_t addr;
166
 
 
167
 
    pcilib_bar_t bar;                   // optional
168
 
    size_t size;
169
 
    
170
 
    pcilib_register_protocol_t protocol;
171
 
 
172
 
    uintptr_t read_addr;                // or offset if bar specified
173
 
    uintptr_t write_addr;               // or offset if bar specified
174
 
    uint8_t raw_endianess;
175
 
 
176
 
    uint8_t access;
177
 
    uint8_t endianess;
178
 
    
179
 
    const char *format;
180
 
    const char *name;
181
 
    const char *description;
182
 
} pcilib_register_bank_description_t;
183
 
 
184
 
typedef struct {
185
 
    pcilib_register_addr_t addr;
186
 
    pcilib_register_size_t offset;
187
 
    pcilib_register_size_t bits;
188
 
    pcilib_register_value_t defvalue;
189
 
    pcilib_register_value_t rwmask;     /**< 1 - read before write bits, 0 - zero should be written to preserve value 
190
 
                                        Used to define how external bits of PCILIB_REGISTER_BITS registers are treated.
191
 
                                        Currently it is a bit confusing, we may find a better way in the next release */
192
 
    pcilib_register_mode_t mode;
193
 
    pcilib_register_type_t type;
194
 
    
195
 
    pcilib_register_bank_t bank;
196
 
    
197
 
    const char *name;
198
 
    const char *description;
199
 
} pcilib_register_description_t;
200
 
 
201
 
/**
202
 
  * Default mappings
203
 
  */
204
 
typedef struct {
205
 
    uintptr_t start;
206
 
    uintptr_t end;
207
 
    pcilib_register_bank_addr_t bank;
208
 
    long addr_shift;
209
 
} pcilib_register_range_t;
210
 
 
211
 
typedef struct {
212
 
    pcilib_event_t evid;
213
 
    const char *name;
214
 
    const char *description;
215
 
} pcilib_event_description_t;
216
 
 
217
 
typedef struct {
218
 
    pcilib_event_data_type_t data_type;
219
 
    pcilib_event_t evid;
220
 
    const char *name;
221
 
    const char *description;
222
 
} pcilib_event_data_type_description_t;
223
 
 
224
 
typedef enum {
225
 
    PCILIB_DMA_IRQ = 1,
226
 
    PCILIB_EVENT_IRQ = 2
227
 
} pcilib_irq_type_t;
228
 
 
229
 
typedef enum {
230
 
    PCILIB_DMA_TO_DEVICE = 1,
231
 
    PCILIB_DMA_FROM_DEVICE = 2,
232
 
    PCILIB_DMA_BIDIRECTIONAL = 3
233
 
} pcilib_dma_direction_t;
234
 
 
235
 
typedef enum {
236
 
    PCILIB_DMA_TYPE_BLOCK,
237
 
    PCILIB_DMA_TYPE_PACKET,
238
 
    PCILIB_DMA_TYPE_UNKNOWN
239
 
} pcilib_dma_engine_type_t;
240
 
 
241
 
typedef struct {
242
 
    pcilib_dma_engine_addr_t addr;
243
 
    pcilib_dma_engine_type_t type;
244
 
    pcilib_dma_direction_t direction;
245
 
    size_t addr_bits;
246
 
} pcilib_dma_engine_description_t;
247
 
 
248
 
typedef struct {
249
 
    pcilib_dma_engine_description_t *engines[PCILIB_MAX_DMA_ENGINES +  1];
250
 
} pcilib_dma_info_t;
251
 
 
252
 
typedef struct {
253
 
    uint8_t access;
254
 
    uint8_t endianess;
255
 
    
256
 
    pcilib_register_description_t *registers;
257
 
    pcilib_register_bank_description_t *banks;
258
 
    pcilib_register_range_t *ranges;
259
 
    pcilib_event_description_t *events;
260
 
    pcilib_event_data_type_description_t *data_types;
261
 
 
262
 
    pcilib_dma_api_description_t *dma_api;    
263
 
    pcilib_event_api_description_t *event_api;
264
 
} pcilib_model_description_t;
265
 
 
266
 
int pcilib_set_error_handler(void (*err)(const char *msg, ...), void (*warn)(const char *msg, ...));
267
 
 
268
 
pcilib_model_t pcilib_get_model(pcilib_t *ctx);
269
 
pcilib_model_description_t *pcilib_get_model_description(pcilib_t *ctx);
270
 
pcilib_context_t *pcilib_get_implementation_context(pcilib_t *ctx);
271
 
 
272
 
pcilib_t *pcilib_open(const char *device, pcilib_model_t model);
273
 
void pcilib_close(pcilib_t *ctx);
274
 
 
275
 
int pcilib_start_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t flags);
276
 
int pcilib_stop_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t flags);
277
 
 
278
 
    // Interrupt API is preliminary and can be significantly changed in future
279
 
int pcilib_enable_irq(pcilib_t *ctx, pcilib_irq_type_t irq_type, pcilib_dma_flags_t flags);
280
 
int pcilib_acknowledge_irq(pcilib_t *ctx, pcilib_irq_type_t irq_type, pcilib_irq_source_t irq_source);
281
 
int pcilib_disable_irq(pcilib_t *ctx, pcilib_dma_flags_t flags);
282
 
 
283
 
int pcilib_wait_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source, pcilib_timeout_t timeout, size_t *count);
284
 
int pcilib_clear_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source);
285
 
 
286
 
void *pcilib_map_bar(pcilib_t *ctx, pcilib_bar_t bar);
287
 
void pcilib_unmap_bar(pcilib_t *ctx, pcilib_bar_t bar, void *data);
288
 
char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr); // addr is offset if bar is specified
289
 
char *pcilib_resolve_data_space(pcilib_t *ctx, uintptr_t addr, size_t *size);
290
 
 
291
 
pcilib_register_bank_t pcilib_find_bank_by_addr(pcilib_t *ctx, pcilib_register_bank_addr_t bank);
292
 
pcilib_register_bank_t pcilib_find_bank_by_name(pcilib_t *ctx, const char *bankname);
293
 
pcilib_register_bank_t pcilib_find_bank(pcilib_t *ctx, const char *bank);
294
 
pcilib_register_t pcilib_find_register(pcilib_t *ctx, const char *bank, const char *reg);
295
 
pcilib_event_t pcilib_find_event(pcilib_t *ctx, const char *event);
296
 
pcilib_event_data_type_t pcilib_find_event_data_type(pcilib_t *ctx, pcilib_event_t event, const char *data_type);
297
 
pcilib_dma_engine_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direction, pcilib_dma_engine_addr_t dma);
298
 
 
299
 
int pcilib_read(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, void *buf);
300
 
int pcilib_write(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, void *buf);
301
 
int pcilib_write_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf);
302
 
int pcilib_read_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf);
303
 
 
304
 
int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_engine_t dma);
305
 
int pcilib_stream_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, pcilib_timeout_t timeout, pcilib_dma_callback_t cb, void *cbattr);
306
 
int pcilib_push_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, pcilib_timeout_t timeout, void *buf, size_t *written_bytes);
307
 
int pcilib_read_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf, size_t *read_bytes);
308
 
int pcilib_read_dma_custom(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, pcilib_timeout_t timeout, void *buf, size_t *read_bytes);
309
 
int pcilib_write_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf, size_t *written_bytes);
310
 
double pcilib_benchmark_dma(pcilib_t *ctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction);
311
 
 
312
 
int pcilib_read_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, pcilib_register_value_t *buf);
313
 
int pcilib_write_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, pcilib_register_value_t *buf);
314
 
int pcilib_read_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_register_value_t *value);
315
 
int pcilib_write_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_register_value_t value);
316
 
int pcilib_read_register(pcilib_t *ctx, const char *bank, const char *regname, pcilib_register_value_t *value);
317
 
int pcilib_write_register(pcilib_t *ctx, const char *bank, const char *regname, pcilib_register_value_t value);
318
 
 
319
 
int pcilib_reset(pcilib_t *ctx);
320
 
int pcilib_trigger(pcilib_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
321
 
 
322
 
/*
323
 
 * The recording of new events will be stopped after reaching max_events records
324
 
 * or when the specified amount of time is elapsed. However, the @pcilib_stop
325
 
 * function should be called still. 
326
 
 * NOTE: This options may not be respected if the PCILIB_EVENT_FLAG_RAW_DATA_ONLY
327
 
 * is specified.
328
 
 */
329
 
int pcilib_configure_autostop(pcilib_t *ctx, size_t max_events, pcilib_timeout_t duration);
330
 
 
331
 
/*
332
 
 * Request auto-triggering while grabbing
333
 
 */
334
 
int pcilib_configure_autotrigger(pcilib_t *ctx, pcilib_timeout_t interval, pcilib_event_t event, size_t trigger_size, void *trigger_data);
335
 
/*
336
 
 * Request streaming the rawdata from the event engine. It is fastest way to acuqire data.
337
 
 * No memory copies will be performed and DMA buffers will be directly passed to the user
338
 
 * callback. However, to prevent data loss, no processing should be done on the data. The
339
 
 * user callback is only expected to copy data into the appropriate place and return control
340
 
 * to the event engine.
341
 
 * The performance can be boosted further by disabling any data processing within the event
342
 
 * engine. Just pass PCILIB_EVENT_FLAG_RAW_DATA_ONLY flag to the @pcilib_start function.
343
 
 */
344
 
int pcilib_configure_rawdata_callback(pcilib_t *ctx, pcilib_event_rawdata_callback_t callback, void *user);
345
 
 
346
 
/*
347
 
 * Configures maximal number of preprocessing threads. Actual amount of threads 
348
 
 * may be bigger. For instance, additionaly a real-time reader thread will be 
349
 
 * executed for most of hardware
350
 
 */
351
 
int pcilib_configure_preprocessing_threads(pcilib_t *ctx, size_t max_threads);
352
 
 
353
 
 
354
 
int pcilib_start(pcilib_t *ctx, pcilib_event_t event_mask, pcilib_event_flags_t flags);
355
 
int pcilib_stop(pcilib_t *ctx, pcilib_event_flags_t flags);
356
 
 
357
 
int pcilib_stream(pcilib_t *ctx, pcilib_event_callback_t callback, void *user);
358
 
int pcilib_get_next_event(pcilib_t *ctx, pcilib_timeout_t timeout, pcilib_event_id_t *evid, size_t info_size, pcilib_event_info_t *info);
359
 
 
360
 
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);
361
 
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);
362
 
void *pcilib_get_data(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t *size_or_err);
363
 
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_or_err);
364
 
 
365
 
/*
366
 
 * This function is provided to find potentially corrupted data. If the data is overwritten by 
367
 
 * the time return_data is called it will return error. 
368
 
 */
369
 
int pcilib_return_data(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, void *data);
370
 
 
371
 
 
372
 
 
373
 
/*
374
 
 * @param data - will be allocated and shuld be freed if NULL, otherwise used and size should contain correct size.
375
 
 *   In case of failure the content of data is undefined.
376
 
 * @param timeout - will be autotriggered if NULL
377
 
 */
378
 
int pcilib_grab(pcilib_t *ctx, pcilib_event_t event_mask, size_t *size, void **data, pcilib_timeout_t timeout);
379
 
 
380
 
#endif /* _PCITOOL_PCILIB_H */