/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool
45 by root
North West Logick DMA implementation
1
#ifndef _PCILIB_DMA_H
2
#define _PCILIB_DMA_H
3
241 by Suren A. Chilingaryan
Further adjustments to get ready for independent event plugins
4
#include <pcilib.h>
5
#include <pcilib/bank.h>
6
#include <pcilib/register.h>
7
45 by root
North West Logick DMA implementation
8
#define PCILIB_DMA_BUFFER_INVALID ((size_t)-1)
70 by Suren A. Chilingaryan
Support modifications of DMA engine and allow DMA customizations by Event engine
9
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
10
typedef struct {
11
    int used;					/**< Indicates if buffer has unread data or empty and ready for DMA */
12
    int error;					/**< Indicates if data is complete and correctly transfered or some error occured during the DMA transfer */
13
    int first;					/**< Indicates the first buffer of the packet */
14
    int last;					/**< Indicates the last buffer of the packet */
15
    size_t size;				/**< Indicates number of bytes actually written to the buffer */
16
} pcilib_dma_buffer_status_t;
70 by Suren A. Chilingaryan
Support modifications of DMA engine and allow DMA customizations by Event engine
17
103 by Suren A. Chilingaryan
Provide information about active DMA engines & buffers
18
typedef struct {
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
19
    int started;				/**< Informs if the engine is currently started or not */
20
    size_t ring_size, buffer_size;		/**< The number of allocated DMA buffers and size of each buffer in bytes */
21
    size_t ring_head, ring_tail;		/**< The first and the last buffer containing the data */
265 by Suren A. Chilingaryan
Add fields reporting consumed buffers and space to the dma_engine_status and provide better ipedma benchmarking
22
    size_t written_buffers, written_bytes;	/**< Number of pending buffers and total number of written bytes */
103 by Suren A. Chilingaryan
Provide information about active DMA engines & buffers
23
} pcilib_dma_engine_status_t;
24
236 by Suren A. Chilingaryan
Big redign of model structures
25
typedef enum {
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
26
    PCILIB_DMA_TYPE_BLOCK,			/**< Simple DMA engine */
27
    PCILIB_DMA_TYPE_PACKET,			/**< Streaming (scatter-gather) DMA engine */
236 by Suren A. Chilingaryan
Big redign of model structures
28
    PCILIB_DMA_TYPE_UNKNOWN
29
} pcilib_dma_engine_type_t;
30
31
typedef struct {
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
32
    pcilib_dma_engine_addr_t addr;		/**< Address of DMA engine (from 0) */
33
    pcilib_dma_engine_type_t type;		/**< Type of DMA engine */
34
    pcilib_dma_direction_t direction;		/**< Defines which kind of transfer does engine support: C2S, S2C, or both */
35
    size_t addr_bits;				/**< Number of addressable bits in the system memory (we currently work with 32-bits only) */
236 by Suren A. Chilingaryan
Big redign of model structures
36
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
37
    const char *name;				/**< Defines a short name of engine (its main use, i.e. main, auxilliary, etc.) */
38
    const char *description;			/**< Defines a longer description of the engine */
236 by Suren A. Chilingaryan
Big redign of model structures
39
} pcilib_dma_engine_description_t;
40
41
/*
42
typedef struct {
43
    int ignore_eop;
44
} pcilib_dma_parameters_t;
45
*/
46
47
typedef struct {
48
//    pcilib_dma_parameters_t params;
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
49
    pcilib_t *pcilib;				/**< Reference to the pcilib context */
236 by Suren A. Chilingaryan
Big redign of model structures
50
} pcilib_dma_context_t;
51
52
typedef struct {
253 by Suren A. Chilingaryan
Include version information in all API descriptions
53
    pcilib_version_t version;
54
236 by Suren A. Chilingaryan
Big redign of model structures
55
    pcilib_dma_context_t *(*init)(pcilib_t *ctx, const char *model, const void *arg);
45 by root
North West Logick DMA implementation
56
    void (*free)(pcilib_dma_context_t *ctx);
103 by Suren A. Chilingaryan
Provide information about active DMA engines & buffers
57
    
109 by Suren A. Chilingaryan
Improvements of DMA engine
58
    int (*status)(pcilib_dma_context_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers);
45 by root
North West Logick DMA implementation
59
63 by Suren A. Chilingaryan
Provide IRQ enable/disable call
60
    int (*enable_irq)(pcilib_dma_context_t *ctx, pcilib_irq_type_t irq_type, pcilib_dma_flags_t flags);
61
    int (*disable_irq)(pcilib_dma_context_t *ctx, pcilib_dma_flags_t flags);
88 by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API
62
    int (*acknowledge_irq)(pcilib_dma_context_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)
63
63 by Suren A. Chilingaryan
Provide IRQ enable/disable call
64
    int (*start_dma)(pcilib_dma_context_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t flags);
65
    int (*stop_dma)(pcilib_dma_context_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t flags);
62 by Suren A. Chilingaryan
Suppport DMA modes in console application (not functional yet)
66
67
    int (*push)(pcilib_dma_context_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);
68
    int (*stream)(pcilib_dma_context_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);
45 by root
North West Logick DMA implementation
69
49 by Suren A. Chilingaryan
A bit of renaming
70
    double (*benchmark)(pcilib_dma_context_t *ctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction);
236 by Suren A. Chilingaryan
Big redign of model structures
71
} pcilib_dma_api_description_t;
72
73
74
typedef struct {
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
75
    const pcilib_dma_api_description_t *api;				/**< Defines all API functions for DMA operation */
76
    const pcilib_register_bank_description_t *banks;			/**< Pre-defined register banks exposed by DMA interface, additional banks can be defined during DMA initialization */
77
    const pcilib_register_description_t *registers;			/**< Pre-defined registers exposed by DMA interface, additional registers can be defined during DMA initialization */
78
    const pcilib_dma_engine_description_t *engines;			/**< List of DMA engines exposed by DMA interface, alternatively engines can be added during DMA initialization */
79
    const char *model;							/**< If NULL, the actually used event model is used instead */
80
    const void *args;							/**< Custom DMA-specific arguments. The actual structure may depend on the specified model */
81
    const char *name;							/**< Short name of DMA interface */
82
    const char *description;						/**< A bit longer description of DMA interface */
236 by Suren A. Chilingaryan
Big redign of model structures
83
} pcilib_dma_description_t;
84
85
277 by Suren A. Chilingaryan
Keep C++ compilers happy
86
#ifdef __cplusplus
87
extern "C" {
88
#endif
89
240 by Suren A. Chilingaryan
More structural changes to get ready for stand-alone event engines
90
const pcilib_dma_description_t *pcilib_get_dma_description(pcilib_t *ctx);
236 by Suren A. Chilingaryan
Big redign of model structures
91
pcilib_dma_engine_t pcilib_add_dma_engine(pcilib_t *ctx, pcilib_dma_engine_description_t *desc);
103 by Suren A. Chilingaryan
Provide information about active DMA engines & buffers
92
int pcilib_get_dma_status(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers);
236 by Suren A. Chilingaryan
Big redign of model structures
93
int pcilib_init_dma(pcilib_t *ctx);
94
277 by Suren A. Chilingaryan
Keep C++ compilers happy
95
#ifdef __cplusplus
96
}
97
#endif
45 by root
North West Logick DMA implementation
98
99
#endif /* _PCILIB_DMA_H */