/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool
7.1.6 by Suren A. Chilingaryan
Provide single header for library
1
#ifndef _PCITOOL_PCILIB_H
2
#define _PCITOOL_PCILIB_H
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
3
4
#define PCILIB_MAX_BANKS 6
43 by root
Enumerate DMA engines
5
#define PCILIB_MAX_DMA_ENGINES 32
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
6
117 by Suren A. Chilingaryan
new event architecture, first trial
7
#include <sys/time.h>
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
8
#include <stdint.h>
9
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
10
#define pcilib_memcpy pcilib_memcpy32
11
#define pcilib_datacpy pcilib_datacpy32
12
13
typedef struct pcilib_s pcilib_t;
117 by Suren A. Chilingaryan
new event architecture, first trial
14
typedef struct pcilib_event_context_s pcilib_context_t;
109 by Suren A. Chilingaryan
Improvements of DMA engine
15
typedef struct pcilib_dma_context_s pcilib_dma_context_t;
16
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
17
45 by root
North West Logick DMA implementation
18
typedef struct pcilib_dma_api_description_s pcilib_dma_api_description_t;
47 by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes
19
typedef struct pcilib_event_api_description_s pcilib_event_api_description_t;
20
typedef struct  pcilib_protocol_description_s pcilib_protocol_description_t;
88 by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API
21
typedef unsigned int pcilib_irq_hw_source_t;
22
typedef uint32_t pcilib_irq_source_t;
45 by root
North West Logick DMA implementation
23
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
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 */
54 by Suren A. Chilingaryan
Support dynamic registers, support register offsets and multiregisters (bitmasks), list NWL DMA registers
26
typedef uint32_t pcilib_register_addr_t;	/**< Type holding the register ID within the Bank */
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
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 */
49 by Suren A. Chilingaryan
A bit of renaming
31
typedef uint8_t pcilib_dma_engine_addr_t;
32
typedef uint8_t pcilib_dma_engine_t;
50 by Suren A. Chilingaryan
Compilation fix
33
typedef uint64_t pcilib_event_id_t;
15 by Suren A. Chilingaryan
Infrastructure for event API
34
typedef uint32_t pcilib_event_t;
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
35
typedef uint64_t pcilib_timeout_t;
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
36
37
typedef enum {
16 by Suren A. Chilingaryan
Prototype of IPECamera image protocol
38
    PCILIB_HOST_ENDIAN = 0,
39
    PCILIB_LITTLE_ENDIAN,
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
40
    PCILIB_BIG_ENDIAN
41
} pcilib_endianess_t;
42
43
typedef enum {
44
    PCILIB_MODEL_DETECT,
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
45
    PCILIB_MODEL_PCI,
46
    PCILIB_MODEL_IPECAMERA
47
} pcilib_model_t;
48
49
typedef enum {
50
    PCILIB_REGISTER_R = 1,
51
    PCILIB_REGISTER_W = 2,
54 by Suren A. Chilingaryan
Support dynamic registers, support register offsets and multiregisters (bitmasks), list NWL DMA registers
52
    PCILIB_REGISTER_RW = 3,
53
    PCILIB_REGISTER_W1C = 4,		/**< writting 1 resets the flag */
54
    PCILIB_REGISTER_RW1C = 5
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
55
} pcilib_register_mode_t;
56
57
typedef enum {
7.1.5 by Suren A. Chilingaryan
Support for FPGA registers
58
    PCILIB_DEFAULT_PROTOCOL,
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
59
    IPECAMERA_REGISTER_PROTOCOL
60
} pcilib_register_protocol_t;
61
15 by Suren A. Chilingaryan
Infrastructure for event API
62
typedef enum {
63
    PCILIB_EVENT_DATA
64
} pcilib_event_data_type_t;
65
45 by root
North West Logick DMA implementation
66
typedef enum {
67
    PCILIB_DMA_FLAGS_DEFAULT = 0,
109 by Suren A. Chilingaryan
Improvements of DMA engine
68
    PCILIB_DMA_FLAG_EOP = 1,		/**< last buffer of the packet */
69
    PCILIB_DMA_FLAG_WAIT = 2,		/**< wait completion of write operation / wait for data during read operation */
70
    PCILIB_DMA_FLAG_MULTIPACKET = 4,	/**< read multiple packets */
71
    PCILIB_DMA_FLAG_PERSISTENT = 8,	/**< do not stop DMA engine on application termination / permanently close DMA engine on dma_stop */
72
    PCILIB_DMA_FLAG_IGNORE_ERRORS = 16	/**< do not crash on errors, but return appropriate error codes */
45 by root
North West Logick DMA implementation
73
} pcilib_dma_flags_t;
74
47 by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes
75
typedef enum {
117 by Suren A. Chilingaryan
new event architecture, first trial
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;
85
86
87
typedef enum {
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;
92
93
typedef enum {
47 by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes
94
    PCILIB_REGISTER_STANDARD = 0,
54 by Suren A. Chilingaryan
Support dynamic registers, support register offsets and multiregisters (bitmasks), list NWL DMA registers
95
    PCILIB_REGISTER_FIFO,
96
    PCILIB_REGISTER_BITS
47 by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes
97
} pcilib_register_type_t;
45 by root
North West Logick DMA implementation
98
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
99
#define PCILIB_BAR_DETECT 		((pcilib_bar_t)-1)
39 by root
Move to new FPGA design
100
#define PCILIB_BAR_INVALID		((pcilib_bar_t)-1)
101
#define PCILIB_BAR0			0
102
#define PCILIB_BAR1			1
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
103
#define PCILIB_DMA_ENGINE_INVALID	((pcilib_dma_engine_t)-1)
65 by Suren A. Chilingaryan
Separate NWL loopback code, provide DMA start/stop interfaces
104
#define PCILIB_DMA_ENGINE_ALL		((pcilib_dma_engine_t)-1)
105
#define PCILIB_DMA_FLAGS_DEFAULT	((pcilib_dma_flags_t)0)
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
106
#define PCILIB_DMA_ENGINE_ADDR_INVALID	((pcilib_dma_engine_addr_t)-1)
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
107
#define PCILIB_REGISTER_INVALID		((pcilib_register_t)-1)
108
#define PCILIB_ADDRESS_INVALID		((uintptr_t)-1)
7.1.2 by Suren A. Chilingaryan
Better handling of register banks
109
#define PCILIB_REGISTER_BANK_INVALID	((pcilib_register_bank_t)-1)
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
110
#define PCILIB_REGISTER_BANK0 		0
7.1.5 by Suren A. Chilingaryan
Support for FPGA registers
111
#define PCILIB_REGISTER_BANK1 		1
112
#define PCILIB_REGISTER_BANK2 		2
113
#define PCILIB_REGISTER_BANK3 		3
43 by root
Enumerate DMA engines
114
#define PCILIB_REGISTER_BANK_DMA	128
16 by Suren A. Chilingaryan
Prototype of IPECamera image protocol
115
#define PCILIB_EVENT0			1
116
#define PCILIB_EVENT1			2
117
#define PCILIB_EVENT2			4
118
#define PCILIB_EVENT3			8
119
#define PCILIB_EVENTS_ALL		((pcilib_event_t)-1)
29 by Suren A. Chilingaryan
Support non-callback way of getting events
120
#define PCILIB_EVENT_INVALID		((pcilib_event_t)-1)
117 by Suren A. Chilingaryan
new event architecture, first trial
121
//#define PCILIB_EVENT_ID_INVALID		0
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
122
#define PCILIB_TIMEOUT_INFINITE		((pcilib_timeout_t)-1)
45 by root
North West Logick DMA implementation
123
#define PCILIB_TIMEOUT_IMMEDIATE	0
86 by Suren A. Chilingaryan
Change timeout definition in Events API from struct timespec to pcilib_timeout_t
124
#define PCILIB_TIMEOUT_TRIGGER		0
88 by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API
125
#define PCILIB_IRQ_SOURCE_DEFAULT	0
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
126
117 by Suren A. Chilingaryan
new event architecture, first trial
127
128
typedef struct {
129
    pcilib_event_t type;
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;
134
109 by Suren A. Chilingaryan
Improvements of DMA engine
135
/**<
136
 * Callback function called when new data is read by DMA streaming function
137
 * @ctx - DMA Engine context
138
 * @flags - DMA Flags
139
 * @bufsize - size of data in bytes
140
 * @buf - data
141
 * @returns 
142
 * <0 - error, stop streaming (the value is negative error code)
117 by Suren A. Chilingaryan
new event architecture, first trial
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)
109 by Suren A. Chilingaryan
Improvements of DMA engine
149
 */
150
typedef int (*pcilib_dma_callback_t)(void *ctx, pcilib_dma_flags_t flags, size_t bufsize, void *buf); 
117 by Suren A. Chilingaryan
new event architecture, first trial
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);
50 by Suren A. Chilingaryan
Compilation fix
153
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
154
typedef struct {
155
    pcilib_register_bank_addr_t addr;
39 by root
Move to new FPGA design
156
157
    pcilib_bar_t bar;			// optional
7.1.2 by Suren A. Chilingaryan
Better handling of register banks
158
    size_t size;
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
159
    
160
    pcilib_register_protocol_t protocol;
161
39 by root
Move to new FPGA design
162
    uintptr_t read_addr;		// or offset if bar specified
163
    uintptr_t write_addr;		// or offset if bar specified
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
164
    uint8_t raw_endianess;
165
166
    uint8_t access;
167
    uint8_t endianess;
7.1.2 by Suren A. Chilingaryan
Better handling of register banks
168
    
39 by root
Move to new FPGA design
169
    const char *format;
7.1.2 by Suren A. Chilingaryan
Better handling of register banks
170
    const char *name;
171
    const char *description;
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
172
} pcilib_register_bank_description_t;
173
174
typedef struct {
175
    pcilib_register_addr_t addr;
15 by Suren A. Chilingaryan
Infrastructure for event API
176
    pcilib_register_size_t offset;
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
177
    pcilib_register_size_t bits;
178
    pcilib_register_value_t defvalue;
54 by Suren A. Chilingaryan
Support dynamic registers, support register offsets and multiregisters (bitmasks), list NWL DMA registers
179
    pcilib_register_value_t rwmask;	/**< 1 - read before write bits, 0 - zero should be written to preserve value */
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
180
    pcilib_register_mode_t mode;
48 by Suren A. Chilingaryan
Include type in the register description
181
    pcilib_register_type_t type;
182
    
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
183
    pcilib_register_bank_t bank;
184
    
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
185
    const char *name;
186
    const char *description;
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
187
} pcilib_register_description_t;
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
188
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
189
/**
190
  * Default mappings
191
  */
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
192
typedef struct {
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
193
    uintptr_t start;
194
    uintptr_t end;
102 by Suren A. Chilingaryan
Accept short addresses for IPECamera FPGA registers
195
    pcilib_register_bank_addr_t bank;
196
    long addr_shift;
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
197
} pcilib_register_range_t;
198
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
199
typedef struct {
117 by Suren A. Chilingaryan
new event architecture, first trial
200
    pcilib_event_t evid;
16 by Suren A. Chilingaryan
Prototype of IPECamera image protocol
201
    const char *name;
202
    const char *description;
203
} pcilib_event_description_t;
204
117 by Suren A. Chilingaryan
new event architecture, first trial
205
typedef struct {
206
    pcilib_event_data_type_t data_type;
207
    pcilib_event_t evid;
208
    const char *name;
209
    const char *description;
210
} pcilib_event_data_type_description_t;
211
41 by root
A bit of DMA infrastructure
212
typedef enum {
63 by Suren A. Chilingaryan
Provide IRQ enable/disable call
213
    PCILIB_DMA_IRQ = 1,
214
    PCILIB_EVENT_IRQ = 2
215
} pcilib_irq_type_t;
216
217
typedef enum {
105 by Suren A. Chilingaryan
Properly perform synchronization of DMA buffers
218
    PCILIB_DMA_TO_DEVICE = 1,
219
    PCILIB_DMA_FROM_DEVICE = 2,
41 by root
A bit of DMA infrastructure
220
    PCILIB_DMA_BIDIRECTIONAL = 3
221
} pcilib_dma_direction_t;
222
223
typedef enum {
224
    PCILIB_DMA_TYPE_BLOCK,
43 by root
Enumerate DMA engines
225
    PCILIB_DMA_TYPE_PACKET,
226
    PCILIB_DMA_TYPE_UNKNOWN
49 by Suren A. Chilingaryan
A bit of renaming
227
} pcilib_dma_engine_type_t;
41 by root
A bit of DMA infrastructure
228
229
typedef struct {
49 by Suren A. Chilingaryan
A bit of renaming
230
    pcilib_dma_engine_addr_t addr;
231
    pcilib_dma_engine_type_t type;
41 by root
A bit of DMA infrastructure
232
    pcilib_dma_direction_t direction;
43 by root
Enumerate DMA engines
233
    size_t addr_bits;
41 by root
A bit of DMA infrastructure
234
} pcilib_dma_engine_description_t;
235
236
typedef struct {
43 by root
Enumerate DMA engines
237
    pcilib_dma_engine_description_t *engines[PCILIB_MAX_DMA_ENGINES +  1];
41 by root
A bit of DMA infrastructure
238
} pcilib_dma_info_t;
15 by Suren A. Chilingaryan
Infrastructure for event API
239
240
typedef struct {
16 by Suren A. Chilingaryan
Prototype of IPECamera image protocol
241
    uint8_t access;
242
    uint8_t endianess;
243
    
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
244
    pcilib_register_description_t *registers;
245
    pcilib_register_bank_description_t *banks;
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
246
    pcilib_register_range_t *ranges;
16 by Suren A. Chilingaryan
Prototype of IPECamera image protocol
247
    pcilib_event_description_t *events;
117 by Suren A. Chilingaryan
new event architecture, first trial
248
    pcilib_event_data_type_description_t *data_types;
41 by root
A bit of DMA infrastructure
249
250
    pcilib_dma_api_description_t *dma_api;    
15 by Suren A. Chilingaryan
Infrastructure for event API
251
    pcilib_event_api_description_t *event_api;
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
252
} pcilib_model_description_t;
253
10 by Matthias Vogelgesang
Set warning handler
254
int pcilib_set_error_handler(void (*err)(const char *msg, ...), void (*warn)(const char *msg, ...));
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
255
7.1.6 by Suren A. Chilingaryan
Provide single header for library
256
pcilib_model_t pcilib_get_model(pcilib_t *ctx);
43 by root
Enumerate DMA engines
257
pcilib_model_description_t *pcilib_get_model_description(pcilib_t *ctx);
31 by Suren A. Chilingaryan
Introduce pcilib_context_t type instead pointer to void
258
pcilib_context_t *pcilib_get_implementation_context(pcilib_t *ctx);
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
259
260
pcilib_t *pcilib_open(const char *device, pcilib_model_t model);
261
void pcilib_close(pcilib_t *ctx);
262
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
263
int pcilib_start_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t flags);
264
int pcilib_stop_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t flags);
88 by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API
265
266
    // Interrupt API is preliminary and can be significantly changed in future
63 by Suren A. Chilingaryan
Provide IRQ enable/disable call
267
int pcilib_enable_irq(pcilib_t *ctx, pcilib_irq_type_t irq_type, pcilib_dma_flags_t flags);
88 by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API
268
int pcilib_acknowledge_irq(pcilib_t *ctx, pcilib_irq_type_t irq_type, pcilib_irq_source_t irq_source);
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
269
int pcilib_disable_irq(pcilib_t *ctx, pcilib_dma_flags_t flags);
270
88 by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API
271
int pcilib_wait_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source, pcilib_timeout_t timeout, size_t *count);
272
int pcilib_clear_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source);
55 by Suren A. Chilingaryan
IRQ support in NWL DMA engine
273
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
274
void *pcilib_map_bar(pcilib_t *ctx, pcilib_bar_t bar);
275
void pcilib_unmap_bar(pcilib_t *ctx, pcilib_bar_t bar, void *data);
43 by root
Enumerate DMA engines
276
char *pcilib_resolve_register_address(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr);	// addr is offset if bar is specified
15 by Suren A. Chilingaryan
Infrastructure for event API
277
char *pcilib_resolve_data_space(pcilib_t *ctx, uintptr_t addr, size_t *size);
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
278
39 by root
Move to new FPGA design
279
pcilib_register_bank_t pcilib_find_bank_by_addr(pcilib_t *ctx, pcilib_register_bank_addr_t bank);
280
pcilib_register_bank_t pcilib_find_bank_by_name(pcilib_t *ctx, const char *bankname);
7.1.2 by Suren A. Chilingaryan
Better handling of register banks
281
pcilib_register_bank_t pcilib_find_bank(pcilib_t *ctx, const char *bank);
282
pcilib_register_t pcilib_find_register(pcilib_t *ctx, const char *bank, const char *reg);
16 by Suren A. Chilingaryan
Prototype of IPECamera image protocol
283
pcilib_event_t pcilib_find_event(pcilib_t *ctx, const char *event);
117 by Suren A. Chilingaryan
new event architecture, first trial
284
pcilib_event_data_type_t pcilib_find_event_data_type(pcilib_t *ctx, pcilib_event_t event, const char *data_type);
49 by Suren A. Chilingaryan
A bit of renaming
285
pcilib_dma_engine_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direction, pcilib_dma_engine_addr_t dma);
7.1.2 by Suren A. Chilingaryan
Better handling of register banks
286
7.1.1 by Suren A. Chilingaryan
Initial support of IPECamera protocol
287
int pcilib_read(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, void *buf);
288
int pcilib_write(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, void *buf);
47 by Suren A. Chilingaryan
Support FIFO reading/writting, code restructurization, few fixes
289
int pcilib_write_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf);
290
int pcilib_read_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf);
291
49 by Suren A. Chilingaryan
A bit of renaming
292
int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_engine_t dma);
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
293
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);
294
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);
58 by Suren A. Chilingaryan
Wait for the completion of DMA operations during writes
295
int pcilib_read_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf, size_t *read_bytes);
109 by Suren A. Chilingaryan
Improvements of DMA engine
296
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);
58 by Suren A. Chilingaryan
Wait for the completion of DMA operations during writes
297
int pcilib_write_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf, size_t *written_bytes);
49 by Suren A. Chilingaryan
A bit of renaming
298
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);
45 by root
North West Logick DMA implementation
299
7.1.4 by Suren A. Chilingaryan
Support writting and reading of register ranges
300
int pcilib_read_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, pcilib_register_value_t *buf);
301
int pcilib_write_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, pcilib_register_value_t *buf);
7.1.2 by Suren A. Chilingaryan
Better handling of register banks
302
int pcilib_read_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_register_value_t *value);
303
int pcilib_write_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_register_value_t value);
304
int pcilib_read_register(pcilib_t *ctx, const char *bank, const char *regname, pcilib_register_value_t *value);
305
int pcilib_write_register(pcilib_t *ctx, const char *bank, const char *regname, pcilib_register_value_t value);
6 by Suren A. Chilingaryan
Initial support for registers, infrastructure only
306
15 by Suren A. Chilingaryan
Infrastructure for event API
307
int pcilib_reset(pcilib_t *ctx);
308
int pcilib_trigger(pcilib_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
309
117 by Suren A. Chilingaryan
new event architecture, first trial
310
/*
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
315
 * is specified.
316
 */
317
int pcilib_configure_autostop(pcilib_t *ctx, size_t max_events, pcilib_timeout_t duration);
318
/*
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.
326
 */
327
int pcilib_configure_rawdata_callback(pcilib_t *ctx, pcilib_event_rawdata_callback_t callback, void *user);
328
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);
332
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);
15 by Suren A. Chilingaryan
Infrastructure for event API
336
void *pcilib_get_data(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t *size);
16 by Suren A. Chilingaryan
Prototype of IPECamera image protocol
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);
117 by Suren A. Chilingaryan
new event architecture, first trial
338
15 by Suren A. Chilingaryan
Infrastructure for event API
339
/*
340
 * This function is provided to find potentially corrupted data. If the data is overwritten by 
117 by Suren A. Chilingaryan
new event architecture, first trial
341
 * the time return_data is called it will return error. 
15 by Suren A. Chilingaryan
Infrastructure for event API
342
 */
117 by Suren A. Chilingaryan
new event architecture, first trial
343
int pcilib_return_data(pcilib_t *ctx, pcilib_event_id_t event_id, void *data);
344
345
15 by Suren A. Chilingaryan
Infrastructure for event API
346
347
/*
348
 * @param data - will be allocated and shuld be freed if NULL, otherwise used and size should contain correct size.
349
 *   In case of failure the content of data is undefined.
350
 * @param timeout - will be autotriggered if NULL
351
 */
86 by Suren A. Chilingaryan
Change timeout definition in Events API from struct timespec to pcilib_timeout_t
352
int pcilib_grab(pcilib_t *ctx, pcilib_event_t event_mask, size_t *size, void **data, pcilib_timeout_t timeout);
15 by Suren A. Chilingaryan
Infrastructure for event API
353
7.1.6 by Suren A. Chilingaryan
Provide single header for library
354
#endif /* _PCITOOL_PCILIB_H */